How to get second last row SQL Server
Many times we have seen interviewer asked how to get second height salary in Sql Server but now interview asked how to get second the last row in sql server
Table
So we can get second the last row using order by
SELECT TOP 1 * From
(select Top 2 * from record ORDER BY record_id DESC) x
ORDER BY record_id
Out-Put:-
Second last row with only one select in SQL Server
select * from record where record_id=(select max(record_id)-1 from record)
Out-Put:-
How to get second last row SQL Server
Reviewed by NEERAJ SRIVASTAVA
on
11:11:00 AM
Rating:
No comments: