CASE WHEN .... THEN ...END
in the SQL query.
I have this construction (essential SQL snippet):
case
when "osoba"."orz_kraj"='PL' and "osoba"."orz_dat_wyd" is not null then "osoba"."orz_dat_wyd"
when not("osoba"."orz_kraj"='PL' and "osoba"."orz_dat_wyd" is not null) and ("niepelnospr"."orz_kraj"='PL' and "niepelnospr"."orz_data" is not null) then "niepelnospr"."orz_data"
end as "orz_data1",
"osoba"."orz_dat_wyd", "niepelnospr"."orz_data"
The condition is based on date fields and as a result also gives a date field as a result.... theoretically....
Unfortunately, as a result, I get an INTEGER field (which somewhat corresponds to the date, but that's not what I mean). And I can't get SQL to return data as a date for anything, the CAST(...as Date) function doesn't change anything in this case. Whatever I would do, I still get the result as in the picture below. As you can see, the fields included in the condition are dates, but the result, unfortunately, is not.
The conditions work as they should, but the format of the result is incorrect. How to force SQL to return the result as a date?
