Is it possible to call nvl when there are subqueries between them? Code is below.
NVL(
(
SELECT
MIN(DATE_TIME)AS EFFECTIVE_DATE
FROM TEMP.DM_ZEXPIDA_FICANT Z
WHERE REGEXP_EXTRACT(CURR_HC,'([^;]+)',0) = TEMP.AB_FICANT.CURR_CODE
AND Z.DATE_TIME > TEMP.AB_FICANT.DATE_TIME
),
(
SELECT
MIN(DATE_TIME)AS EFFECTIVE_DATE
FROM TEMP.DM_ZEXPIDB_FICANT Z
WHERE CURR_CODE = TEMP.AB_FICANT.CURR_CODE
AND Z.DATE_TIME > TEMP.AB_FICANT.DATE_TIME
)
)AS EXPI_DATE,
As we know that the system restrict us for make select inside select: https://cwiki.apache.org/confluence/display/Hive/Subqueries+in+SELECT#space-menu-link-content
Also, we can only use CASE WHEN when the form is like this :
CASE WHEN rr IS NULL THEN kk
ELSE rr
END AS EXPI_DATE
What kind of form I have to try to succeed this?