Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: query question for sql experts

Re: query question for sql experts

From: Art S. Kagel <kagel_at_bloomberg.com>
Date: 1998/01/21
Message-ID: <34C61F1A.2496@bloomberg.com>#1/1

L. Tseng wrote:
>
> Hi, SQL experts,
>
> Your help on the following qestion will be much appreciated.
> For example:
>
> TableA contains:
>
> EmpID GroupID CrDate
> 22 4 1/20/98
> 24 3 1/19/98
> 25 4 1/18/98
> 25 6 1/17/98
> 24 5 1/16/98
> 22 3 1/15/98
>
> how do I get a query output like the following with pure SQL code:
> (Group by EmpID and order by the lastest crdate first within each EmpID)
>
> EmpID GroupID CrDate
> 22 4 1/20/98
> 22 3 1/15/98
> 24 3 1/19/98
> 24 5 1/16/98
> 25 4 1/18/98
> 25 6 1/17/98

I assume from you sample output that you mean order by CrDate descending within EmpID and not group by EmpID. Hence:

SELECT EmpID, GroupID, CrDate
FROM TableA
ORDER BY EmpID, CrDate DESC;

Art S. Kagel Received on Wed Jan 21 1998 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US