Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: help with query
Hi All,
Pls look at the following.
SQL> select * from test order by id;
ID CHK_DT AMOUNT
---------- --------- ---------- 1 04-AUG-00 100 1 04-AUG-00 50 1 04-AUG-00 200 2 04-AUG-00 100 2 04-AUG-00 50
SQL> l
1 select id, max(amount)
2 from test
3* group by id
SQL> /
ID MAX(AMOUNT)
---------- -----------
1 200 2 100
Hope it helps
Thanks
Vidya
From: Ashish Shah <ar_shah_at_yahoo.com>
To: dbalist <ORACLE-L_at_fatcity.com>, lazydba <oracledba_at_quickdoc.co.uk>
Subject: help with query
Date: Fri, 4 Aug 2000 07:42:08 -0700 (PDT)
Hi all,
Here is the data..
id date amount
1 15-jul-00 100 1 15-jul-00 50 1 15-jul-00 200 <<<<<<<< 2 15-jul-00 50 2 15-jul-00 100 <<<<<<<<
I need to get a row with max(date) (Date field is with time so we can get last row that was inserted) for each user..
so my output should be
1 15-jul-00 200 2 15-jul-00 100
Any idea??
TIA