I am trying to prioritize my query by the ticket_priority_id
.
The IDs are categorized as ASAP
, HIGH
, MED
, LOW
.
When I order by ticket_priority_id
it always puts it in alphabetical order (LOW
is ahead of MED
).
How can I make it so I can order by ticket_priority_id
but not alphabetically but by importance. I want the order to go (from top to bottom) ASAP
- HIGH
- MED
- LOW
You can use a case statement in your order by like this
ORDER BY
CASE WHEN ticket_priority_id = 'ASAP' THEN 1
WHEN ticket_priority_id = 'HIGH' THEN 2
WHEN ticket_priority_id = 'MED' THEN 3
WHEN ticket_priority_id = 'LOW' THEN 4
ELSE 5
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With