Delete Data In Table

Delete Data In Table

-- without a join
DELETE FROM comments
WHERE commentID = 2;

-- with a join
DELETE comments
FROM comments
INNER JOIN posts ON comments.postID = posts.postID
WHERE posts.title = 'First Post';

196. Delete Duplicate Emails

/* Write your T-SQL query statement below */

WITH cte AS (
    SELECT email, MIN(id) AS [id]
    FROM Person
    GROUP BY email
)
DELETE FROM Person
WHERE id NOT IN (SELECT id FROM cte);