Re: SQL Query

From: Karsten Weikop <karsten_at_pip.dknet.dk>
Date: Mon, 20 Mar 1995 23:54:00
Message-ID: <karsten.30.0017E722_at_pip.dknet.dk>


In article <D5H07p.2vq_at_hkuxb.hku.hk> kkha_at_hkuxa.hku.hk (Ha Kong Kuen) writes:
>From: kkha_at_hkuxa.hku.hk (Ha Kong Kuen)
>Subject: SQL Query
>Date: Wed, 15 Mar 1995 07:16:36 GMT
 

> I have simple question:
 

> I have a table with several columns, e.g.
 

> Staff No,
> Department No,
> Post Held
> Start Date

> For each staff, it is possible to have the same
> department and post with with different start dates.
> How can I ,say retrieve , those with same staff_no, department
> No and Post Held and yet with the earliest start date or
> the greatest start date?
 

> Thanks for any hints.
 

> Anthony HA

Select *
  from table a
 where ...
   and start_date = (select min(start_date)

                       from table b
                      where a.staff  = b.staff
                        and a.dept   = b.dept
                        and a.post = b.post);

Karsten Received on Mon Mar 20 1995 - 23:54:00 CET

Original text of this message