Originally posted by tamilselvan
Select a.id, a.name, a.tdate
from ( select id, name, to_char(logdate, 'MON DD YYYY') tdate
from test order by logdate) a
union
Select b.id, b.name, b.tdate
from ( select id, name, to_char(logdate, 'MON DD YYYY') tdate
from test order by logdate) b
;
The result from the above query will not be sorted by logdate. It will be sorted by ID first, then by NAME and lastly by TDATE.

If you want to sort by LOGDATE, but do not LOGDATE to be includet into the resultset, then you should use:
Code:
select id, name, tdate 
from
(select id, name, to_char(logdate, 'MON DD YYYY') tdate, logdate
from table1
union
select id, name, to_char(logdate, 'MON DD YYYY') tdate, logdate
from table2
)
order by logdate;