#995

Users With Paid Orders

Marketing is building a list of users who have at least one order with status = 'paid'. Rewrite the report without the nested list check and return unique user id values sorted by id.

Original query
SELECT u.id FROM users u WHERE u.id IN (SELECT user_id FROM orders WHERE status = 'paid') ORDER BY u.id

Esempio di output atteso

Ecco come appare una risposta corretta — il suo numero di righe è a sé stante, non deve corrispondere alle tabelle dello schema.

id
1
2

Il risultato della tua query apparirà qui