Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

top question 1

Status
Not open for further replies.

lfc77

Programmer
Aug 12, 2003
218
GB
I want to be able to view the last 50 records in a table, in both ascending and descending order. My problem is that

SELECT TOP 50 * FROM CALL_LOG ORDER BY ID DESC

gives the last 50 in descending order, but

SELECT TOP 50 * FROM CALL_LOG ORDER BY ID ASC

gives the FIRST 50 in ascending order.

How do I get the LAST 50 in ascending order?


Thanks,

Mike

 
SELECT * FROM CALL_LOG
WHERE ID IN
(SELECT TOP 50 ID FROM CALL_LOG ORDER BY ID DESC)
ORDER BY ID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top