Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Statement
Dear Rajesh M,
you can try in this way
select a.orderno,a.orderdate,a.customer
from tablex a
where a.orderdate = '20-10-98'
union
select b.orderno,b.orderdate,b.customer
from tablex b
where b.orderdate <> '20-10-98'
and exists (select 1 from tablex c
where c.customer = b.customer
and c.orderdate = '20-10-98').
Write me back with the result.
bye Giovanni.
Rajesh M ha scritto nel messaggio <362cb89c.0_at_news.euroconnect.dk>...
>Hi,
> I have problem with SQL. Could somebody please help !!!
>
>Table X
>OrderNo OrderDate Customer
>-----------------------------------------------
>1 20-10-98 1000
>2 19-10-98 1000
>3 20-10-98 2000
>4 17-10-98 3000
>
>I would like to have a single query which returns
>all the OrderNo dated '20-10-98' (i.e., Customer 1000,2000) and OrderNo
>dated before '20-10-98' for customer with OrderDate='20-10-98'.
>
>The expected result for the query is as follows :
>OrderNo OrderDate Customer
>-----------------------------------------------
>1 20-10-98 1000
>2 19-10-98 1000
>3 20-10-98 2000
>
>Please help and thanks in advance,
>
>Rajesh
>
>
Received on Tue Oct 20 1998 - 00:00:00 CDT