I have a problem with formatting the data when doing an query to an Oracle database.
What I want to do is to export some data into the formatbelow into a textfile;
1IN20071001 40005601054910101200 1 65
Currently I'm using the query below, but this is where my SQL knowledge ends...
COLUMN one FORMAT a5 HEADER JUSTIFY RIGHT
COLUMN two FORMAT a8 HEADER two
COLUMN three FORMAT a18 HEADER three JUSTIFY RIGHT
COLUMN four FORMAT a5 HEADER three JUSTIFY RIGHT
SELECT h.fkod AS one, 'IN',
SUBSTR(t.clockindatetime,0,4) ||
SUBSTR(t.clockindatetime,6,2) ||
SUBSTR(t.clockindatetime,9,2) AS two,
i.employeeid AS three
SUBSTR(t.clockindatetime,11,6) || '00 1',
h.fkod AS four
FROM ent_time_card_detail t,
max_employeeid_history i,
ent_hr_employee h
WHERE h.enthremployeeid = t.enthremployeeid
AND h.payrollid = i.userid
AND t.clockindatetime >= i.from_date
AND (t.clockindatetime < i.to_date OR i.to_date IS NULL);
Any SQL-pro's out there that can help me finish the formatting?
Also you can use rpad and lpad to both pad your output and truncate extra chars
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With