December 13, 2007 at 1:34 am
I need to do- two select at union, and the result at DESC ( from the newest to oldest)
I will be very glad if anyone can help me.
thenks.
ofir.
December 13, 2007 at 1:45 am
you can use order by at the end of the querry
December 13, 2007 at 1:47 am
ORDER BY applies to the result of the UNION not the individual SELECT's so you can do this
SELECT 1 AS [Result]
UNION
SELECT 2 AS [Result]
ORDER BY Result DESC
Or did you mean you wanted each SELECT to be ORDERED separately from the other
Far away is close at hand in the images of elsewhere.
Anon.
December 14, 2007 at 3:09 am
put both your query in an inline view then order the view...
Select * from
(
SELECT a, b, c from TableA
UNION
SELECT a, b, c from Table B
) RESULTS
ORDER BY a DESC
Hope this helps.
Regards,
TBS.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply