Problems / Custom Sort Priority / Editorial
CASE priority WHEN 'critical' THEN 1 ...
ticket_id
Databases sort by *values*, and string values sort alphabetically — the engine cannot know that low < critical in your domain. Any time an enum has a semantic order (priorities, sizes S/M/L/XL, statuses, weekdays), that order must be materialized as data: an inline CASE for one query, or a rank column in a dimension table when several queries need it. The inline CASE-in-ORDER-BY is the lightweight end of that spectrum; outputting the rank, as here, is one step toward the dimension-table end.
low < critical
Solve Custom Sort Priority yourself →