Changing Data · Problem 110 of 118

Delete Old One-Star Reviews

EasyChanging DataShop data

Delete the reviews with rating 1 that were written before 2025-01-01 (review_date). Keep everything else.

Check query. After your statements run, this query is run on the changed data and its result is compared with the expected one:

SELECT rating, COUNT(*) AS reviews
FROM reviews
GROUP BY rating
ORDER BY rating;
Hint 1

Combine the two conditions with AND.

Reference solution

DELETE FROM reviews
WHERE rating = 1
  AND review_date < '2025-01-01';

DELETE has the same shape as a SELECT's WHERE: it removes exactly the rows that the condition selects. Before running a delete in real life, run SELECT COUNT(*) ... WHERE <same condition> and check that the number is what you expect. Deletion cannot be undone once it is committed, which is why people also take a backup or work inside a transaction.