Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-02 : 11:00:21
Harsh writes "How to find out second last row from a table."

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-02 : 11:15:56

Select top 1 * from(
Select top 2 * from yourTable order by keycol Desc) T
order by keycol Asc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-08-02 : 13:14:05
sorry, the correct response was "There IS no second to last row. SQL does not care what order records are stored in. Go back to Excel."

Yea, i am grouchy today

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page
   

- Advertisement -