Home » SQL & PL/SQL » SQL & PL/SQL » How to get the last two records
How to get the last two records [message #9668] Fri, 28 November 2003 07:47 Go to next message
Alex van Es
Messages: 1
Registered: November 2003
Junior Member
How to get out of a history table the last two dates

for example :
Table 1
Name orderdate
Jones 1-may-03
Jones 1-sep-03
Jones 1-dec-03

i only want to see the last two orderdates from each person.

can someone help me
thanx in advance

Alex
Re: How to get the last two records [message #9671 is a reply to message #9668] Fri, 28 November 2003 15:54 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select name, orderdate
  from (select name, orderdate, row_number() over (partition by name order by hiredate desc) rn
          from t1)
 where rn <= 2;
Previous Topic: clob display problem
Next Topic: how to create a select staement for this problem
Goto Forum:
  


Current Time: Thu Mar 28 13:24:49 CDT 2024