Sort tickets by business priority, not alphabetically (telecom)
Sort Urgent, High, Medium, Low (in that order), then oldest first within each priority.
- Level
- intermediate
- Time
- ~8 min
- Task
- Build the query
- Access
- Free — no account needed
Loading the practice workspace…
About this exercise
What you'll practise
Sort by a custom order using a rank from a list.
Lumen Mobile (fictional) logs customer support tickets and exports them for the weekly operations review.
Steps
- Sort tickets by
Priorityin the order Urgent, High, Medium, Low. - Within the same priority, sort by
Openedascending (yyyy-mm-dd text sorts correctly), then byTicketIDascending. - Keep exactly the original columns (no helper column in the result). Row order is graded.
Your result must
- Urgent tickets first, Low last
- Oldest first within a priority
- No extra columns
Input
- Tickets (table)
- TicketID: text
- Opened: text
- Closed: text (nullable)
- Priority: text
- Channel: text
- Agent: text
- Topic: text
Expected output columns
TicketID (text), Opened (text), Closed (text (some rows null)), Priority (text), Channel (text), Agent (text), Topic (text)
| TicketID | Opened | Closed | Priority | Channel | Agent | Topic |
|---|---|---|---|---|---|---|
| T1004 | 2026-02-17 | 2026-02-19 | Urgent | Kalani | Billing | |
| T1000 | 2026-04-07 | null | Urgent | Phone | Lena | Upgrade |
| T1006 | 2026-03-07 | 2026-03-10 | Medium | Kalani | Router |