I want to generate a fixed width file format.
I am trying to cast brith_day, birth_month and birth_year with fixed length but if any of these fields are null should remain the space using coalesce function.
The second part of the query (LastGiftDate and LastContactDate) somehow does not get the fixed width output. I want to use cast(coalesce...
select cast(birth_day , ' ') as char(2))||
cast(birth_month, ' ') as char(2))||
cast(birth_year, ' ') as char(4))||
cast(coalesce(gender, ' ') as char(2))||
to_Char(LastGiftDate,'yyyymmdd')||
to_Char(LastContactDate,'yyyymmdd')||
from table_t1
Data Type
BIRTH_YEAR NUMBER (4)
BIRTH_MONTH NUMBER (2)
BIRTH_DAY NUMBER (2)
LASTGIFTDATE DATE
LASTCONTACTDATE DATE