Re: Help with SQL Select statement

From: <wasim_ahmed_at_my-deja.com>
Date: Fri, 17 Sep 1999 11:31:37 GMT
Message-ID: <7rt8qq$2j3$1_at_nnrp1.deja.com>


Try using

 select a.serial, a.start_date, a.stop_date  from emp a
 where a.start_date not in
   ( select b.start_date
    from emp b
   where b.start_date = a.start_date
   and b.serial <> a.serial
   )
 or exists
   (select 1

     from emp c
      where c.start_date = a.start_date
      and c.serial = a.serial
      and c.stop_date is not null

   )

hope this helps.

In article <37E12B52.BE357A29_at_theleme.com>,   Yann Chevriaux <chevriaux_at_theleme.com> wrote:
>
> select serial_number, start_date, stop_date
> from emp
> where stop_date is not null
> order by serial_number
>
> It should work ....
>
> smagadi_at_yahoo.com a écrit :
>
> > 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.
>
>

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't. Received on Fri Sep 17 1999 - 13:31:37 CEST

Original text of this message