Sunday, February 10, 2013

How to select last two rows of an Oracle table?


select * from (
select ROW_NUMBER()
   OVER (PARTITION BY employee_name ORDER BY emp_code desc) rnum,emp_code from your_table where employee_name='Test'
)
where rnum<=2

No comments:

Post a Comment