Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tsql - delete last row

Tags:

tsql

I want to delete the last row from the table that satisfies some condition.

DELETE TOP 1 FROM SOME_TABLE
WHERE SOME_COULMN = @VALUE
ORDER BY 1 DESC
like image 757
šljaker Avatar asked Feb 12 '10 11:02

šljaker


1 Answers

DELETE FROM SOME_TABLE
WHERE UNIQUE_ID = 
(SELECT TOP 1 UNIQUE_ID
FROM SOME_TABLE
WHERE SOME_COLUMN = @VALUE
ORDER BY SOMETHING DESC)
like image 105
Chris Latta Avatar answered Oct 17 '22 19:10

Chris Latta