Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: help with SQL Select Statement
how about this (replace c1, c2, c3 with the appropriate column names)
select c1, c2, to_date (null) from emp where c2 not in
(select a.c2 from emp a, emp b
where a.c1=b.c1 and a.c2=b.c2 and b.c3 is not null)
union
select c1, c2, c3 from emp where c3 is not null
In article <7rm4ik$u9d$1_at_nnrp1.deja.com>,
smagadi_at_yahoo.com wrote:
> Hi,
>
> I have a emp table which has data as follows:
>
> Serial No. Start Stop
> 1 11-SEP-85
> 2 12-JAN-86
> 3 18-FEB-86
> 4 18-FEB-86 20-Mar-86
> 5 25-MAY-86
> 6 11-NOV-86
> 7 11-NOV-86 12-NOV-86
> 8 22-MAR-87
> 9 12-SEP-89
>
> I want to write a SQL query which retrives:
>
> Serial No. Start Stop
> 1 11-SEP-85
> 2 12-JAN-86
> 4 18-FEB-86 20-Mar-86
> 5 25-MAY-86
> 7 11-NOV-86 12-NOV-86
> 8 22-MAR-87
> 9 12-SEP-89
>
> As shown in the example above if there are two start dates which are
> same, it should retrive the row with the stop date.
>
> Any help would be appreciated.
>
> Thank you
>
> sashi
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
--
Alex Shterenberg
dictatorships." - Euronymous, Mayhem
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Wed Sep 15 1999 - 21:57:43 CDT
![]() |
![]() |