在hive中使用nvl(),()作为列

hl0ma9xz  于 2021-04-02  发布在  Hive
关注(0)|答案(1)|浏览(564)

我必须将我的pl/sql数据翻译成hive,主要格式如下。
NVL(SELECT FROM (SELECT)),(SELECT FROM (SELECT)) AS EXPI_DATE
我的原始数据是这样的:

NVL(
(SELECT MIN(DATE_TIME)AS EF_DATE
    FROM (SELECT C,
                  S,
                  DATE_TIME FROM(SELECT C,
                                      S,
                                      DATE_TIME,
                                      CASE
                                      WHEN lead over ( order by ) IS NULL
                                        THEN 'Y'
                                        ELSE 'N'
                                      END AS flag
                                        FROM table_1 
                            )aihiscur
          WHERE flag = 'Y') Z
          AND Z.DATE_TIME                                        > A.DATE_TIME
),
(SELECT
      MIN(DATE_TIME)AS EF_DATE
        FROM (SELECT  C,
                      S,
                      DATE_TIME 
                        FROM (SELECT C,
                          S,
                          DATE_TIME,
                                      CASE
                                      WHEN lead over ( order by ) IS NULL
                                        THEN 'Y'
                                        ELSE 'N'
                                      END AS flag
                          FROM table_2
                              )aicuri
                WHERE flag = 'Y') Z
      WHERE CU_CODE = A.cR_CODE 
      AND Z.DATE_TIME     > A.DATE_TIME
      )aicurin 
) AS EXPI_DATE

我的问题是。
既然hive禁止使用nvl(),(),有什么有效的方法可以做到这一点?
所有的帮助和想法将被感激!

1sbrub3j

1sbrub3j1#

在这种情况下,"COALESCE "对你有用吗?

SELECT COALESCE(
    (SELECT MIN(DATE_TIME) FROM (SELECT ...)),
    (SELECT MIN(DATE_TIME) FROM (SELECT ...))
) AS EXPI_DATE

相关问题