Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: DISTINCT in UNION does not work

Re: DISTINCT in UNION does not work

From: Brian Tkatch <SPAMBLOCK.Maxwell_Smart_at_ThePentagon.com.SPAMBLOCK>
Date: Fri, 10 Nov 2000 13:21:30 GMT
Message-ID: <3a0bf52f.862339468@news.alt.net>

On Thu, 09 Nov 2000 17:17:36 GMT, shaikh74_at_my-deja.com wrote:

>SELECT DISTINCT INV.INVEST_SEQ_NBR,
>FROM INVESTIGATION INV
>UNION
>SELECT DISTINCT INV.INVEST_SEQ_NBR,
>FROM INVESTIGATION INV
>
>I am getting duplicate rows back with same INV.INVEST_SEQ_NBR. I was
>wondering how can I apply DISTINCT on the result set returned by
>UNION. As you can see, in above query DISTINCT is appllied to each
>query but on the final result set. Your assitance is appreiciated.

UNION is supposed to do just that. You should not even need the DISTINCT clause at all.

SELECT * FROM Dual
UNION
SELECT * FROM Dual

returns one row, as opposed to:

SELECT * FROM Dual
UNION ALL
SELECT * FROM Dual

which returns two rows.

Brian Received on Fri Nov 10 2000 - 07:21:30 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US