How to FETCH the second Last record in a table without any identity column?

 Posted by vishalneeraj-24503 on 2/3/2015 | Category: Sql Server Interview questions | Views: 1288 | Points: 40

We have to write below query:-
declare @count int; 

select @count = count(*) from tableName;

select * from tableName
select top(@count - 2) * from tableName;

without using any identity column and ORDER BY clause we can get last 2 records from a table by using above code.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response