SQL Quest › SQL Interview Questions › Querying Basics
Delete the Empty Accounts
Housekeeping: accounts that signed up and never ordered anything are cluttering the customer table.
Delete every customer whose total_orders is 0, then show a single column remaining with the count of customers left.
DELETE FROM table WHERE ... removes whole rows — you never name columns, because you are not deleting a value, you are deleting a record. And the same warning as UPDATE, only worse: DELETE FROM customers with no WHERE empties the table.
A habit that will save you one day: run the WHERE as a SELECT first. If SELECT * FROM customers WHERE total_orders = 0 returns what you expect, the DELETE will too.
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".
Schema
customers
| customer_id | name | signup_date | membership | total_orders | |
|---|---|---|---|---|---|
| 1 | John Smith | john.smith@email.com | 2023-01-15 | Gold | 15 |
| 2 | Emma Wilson | emma.wilson@email.com | 2023-03-20 | Silver | 8 |
| 3 | Michael Brown | michael.brown@email.com | 2023-02-10 | Gold | 12 |
Expected output: remaining = 13
Hint
Concepts
DELETE DML WHERE
Practise the topic: SQL practice questions
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test