Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Help in getting the first 4 max values
Hi,
I need help regarding writing an sql query for getting the first 4 max
values in the following scenario.
I have a table which has a data like this:
Row No. Id Date Value 1 1 1/1/2001 15 2 1 1/2/2002 16 3 1 1/3/2003 17 4 1 1/4/2004 18 5 1 1/5/2005 19 6 2 1/6/2006 20.....
Now what I need are the records with the last 4 date values. That is I
need the values in the column "Date" and the values in the column
"value" for the last 4 dates for the Id=1 and similarly for Id=2 and so
on. So in other words I would need the Date and Value records for row
no. 2,3,4 and 5.
Can anyone help me in writing a query for extracting this data.
Thanks in advance.
Cheers
Sandy
Received on Thu Jan 04 2007 - 04:03:47 CST
![]() |
![]() |