Sort by a status priority, not alphabetically
SQLMedium12 min
Your task
List orders with paid first, then pending, then refunded, and within each group by id. Return id and status.
Tables
customer| idINTEGER | nameTEXT | countryTEXT | signed_upTEXT |
|---|
| 1 | Anka | DE | 2025-12-20 |
| 2 | Bo | US | 2025-12-14 |
| 3 | Cy | US | 2026-01-05 |
| 4 | Dara | JP | 2026-02-01 |
orders| idINTEGER | customer_idINTEGER | placed_onTEXT | total_centsINTEGER | statusTEXT |
|---|
| 1 | 1 | 2026-01-04 | 12000 | paid |
| 2 | 1 | 2026-01-19 | 3500 | refunded |
| 3 | 2 | 2026-01-21 | 89000 | paid |
| 4 | 2 | 2026-02-02 | 15000 | paid |
| 5 | 3 | 2026-02-14 | 4200 | pending |
| 6 | 2 | 2026-02-28 | 22000 | paid |
More rows not shown Model answerRun