I am trying to do a select which would return a blank '' when a join is not successfull
(when a blank '' or a '-' is encountered in column)
and return column value when it is successfull. I am using case for this but not succeeding until now. Anyone can advise a better query ?
select a.EmpName,a.deptcode,(a.deptcode||' '||(SELECT CASE(a.deptcode) WHEN a.deptcode='-' THEN '' ELSE b.deptname)) as FULLDEPTNAME from table1 a LEFT OUTER JOIN tableB b on a.deptcode=b.deptcode WHERE a.empNo=12;