#1002

Two Paths to Orders

The report needs orders for user_id = 1 plus all orders with status = 'paid'. Rewrite the slow mixed filter as two independent result sets, then return one de-duplicated result sorted by id.

Original query
SELECT * FROM orders WHERE user_id = 1 OR status = 'paid' ORDER BY id

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables.

idstatususer_idcreated_at
10paid12024-02-01T10:00:00
11paid12024-02-03T12:00:00
12paid22024-02-04T09:00:00

Your query result will appear here