|
-
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;
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|