I am attempting to select date based on the condition and populate it in dat_Transformed using the below query. The query gets executed but the dat_Transformed is not getting populated correctly.
Any suggestions to improve the query would be appreciated.
SELECT
dat_Transformed,
CASE
WHEN EXISTS (SELECT date FROM dat_base WHERE dat_base.id= report.id)
THEN (SELECT date FROM dat_base WHERE dat_base .id= report.id)
ELSE ''
END AS dat_new
FROM report;
can do left join and coalesce will throw empty string in case of null