Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: DISTINCT in UNION does not work
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
![]() |
![]() |