I am using Oracle and am trying to build out some sql for the following scenario:
On EMPLOYEES table, if employee has ADDRESS3 not equal to ' ', populate this field with ADDRESS2 else, populate this field with ADDRESS1.
...
, ADDRESS_LINE2 = NVL((
SELECT (CASE t2.ADDRESS3 != ' ' THEN t2.ADDRESS2 ELSE t2.ADDRESS1 END)
FROM EMPLOYEES t2
WHERE t2.EMPLID = PS_Z_EXS_EMP_TBL_T.EMPLID
), t2.ADDRESS1)
...
but it keeps giving me an error message about missing the right parenthesis. When I comment this bit out though it runs fine. DOes anyone know what I'm doing wrong?
CASE WHEN t2.ADDRESS3 != ' ' THEN t2.ADDRESS2 ELSE t2.ADDRESS1 ENDorCASE t2.ADDRESS3 WHEN != ' ' THEN t2.ADDRESS2 ELSE t2.ADDRESS1 END