Re: UNION and ORDER BY clause
Date: Thu, 09 Nov 2000 13:49:09 +0100
Message-ID: <3A0A9D45.830EE65F_at_unilog.fr>
shaikh74_at_my-deja.com a écrit :
>
> Dear Oracle gurus:
>
> I have two SQL statements which are run through UNION and UNION ALL,
> and the results are exact same. They contain duplicate rows (rows
> which are in common within two SQLs). I would like to get distinct
> rows in the final result set. Also, in the final set I would them to
> run through ORDER BY clause. Your assistance values a million.
> Thanks a bunch. Please reply to shaikh74_at_visto.com
> Asad
If I well understand, you just want to see what is not common, so try this :
( Select1 UNION Select2 ) MINUS ( Select1 INTERSECT Select2 )
And to sort them, just add :
ORDER BY Col_name /* or Col_number if you don't use aliases and have different names */
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
-- Pierre CHARPENAYReceived on Thu Nov 09 2000 - 13:49:09 CET