Re: SQL help with MAX function and group by

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Thu, 17 Nov 2005 06:39:17 +0100
Message-ID: <437c1784$0$22725$626a14ce_at_news.free.fr>


<jeffchirco_at_gmail.com> a écrit dans le message de news: 1132189873.991794.316300_at_o13g2000cwo.googlegroups.com...
|I need help with a sql statment using max function. It should be
| simple but I am not seeing it.
| Example:
| EMP DATE GOAL
| 1 11/16/2005 5
| 1 11/15/2005 3
| 2 11/16/2005 8
| 3 11/15/2005 4
| 2 11/15/2005 9
|
| I want to get the MAX(GOAL) per emp, and I want to display all fields.
| So I should see the results as
| EMP DATE GOAL
| 1 11/16/2005 5
| 2 11/15/2005 9
| 3 11/15/2005 4
|
| I can get the correct results without displaying the date by doing;
| select dbemp, MAX(dbnumber) FROM test
| GROUP BY dbemp;
|
| Its when I add the date field and have to group by it, it gets messed
| up.
|
| Thanks for any help.
|

Have a look at rank analytic function:
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions95a.htm#1003189

Regards
Michel Cadot Received on Thu Nov 17 2005 - 06:39:17 CET

Original text of this message