小编典典

按低,中,高排序一列?

sql

所以,我有这个:

select ticket_trackingno, ticket_title, ticket_priority_id, ticket_status_id
from hd_tickets
where ticket_priority_id <> 'None'
and ticket_status_id = 'Assigned'
order by ticket_priority_id desc

这样,我的ticket_priority_id列就被排序为med,low,high。我想要的是低,中,高。我想知道如何去做?


阅读 162

收藏
2021-04-28

共1个答案

小编典典

ORDER BY CASE ticket_priority_id
         WHEN 'low' THEN 1
         WHEN 'med' THEN 2
         WHEN 'high' THEN 3 END
2021-04-28