Daily Shaarli

All links of one day in a single page.

Previous day

September 19, 2022

Next day

DELETE TOP x rows with an ORDER BY – SQL Undercover
thumbnail

Using a CTE
The second solution involves using a CTE to select all the rows that we want to delete and then deleting everything from the CTE. Let’s have a look at what that code looks like…

WITH ToDelete
AS
(SELECT TOP 10 id, first_name, last_name, email, gender, DOB
FROM people
WHERE gender = 'Female'
ORDER BY DOB ASC)

DELETE FROM ToDelete