I'm trying to solve this question Delete all but top n from database table in SQL but the accepted answer's subquery is executed for every row in the table.
Does this happen to my attempt? The subquery could change depending on what rows get deleted. If so how can you fix that?
DELETE FROM patients
WHERE patient_id >=
(SELECT patient_id FROM patients
ORDER BY patient_id
LIMIT 1 OFFSET 10);
SELECT * FROM patients;
I was using the data from https://www.sql-practice.com/