Hi,
I want to know that how can we fetch last 2 records from the table having only one column name as 'ename' ?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
SenthilkumarPosted Apr 17, 2012, 1:01 AM
1) SELECT TOP 2 * FROM (SELECT * FROM table_name WHERE ename ORDER BY ASC) tab
2) SELECT TOP 2 ename,
If you have any issues then reply me back.
Jignesh TrivediPosted Apr 17, 2012, 12:04 AM
It is quite difficult if your column data type is varchar.
but try,
select * from tableName where ename not in (select top ((select count(*) from tableName) - 2) ename from tableName)
above query is not working properly when your table contain duplicate value.
hope this help.
brunda kPosted Apr 15, 2012, 7:53 AM
) dt