SELECT
a.nid,
CASE a.REPAIR_PROGRESS
WHEN 1 THEN '待驗證'
WHEN 2 THEN '待維修'
WHEN 3 THEN '重新維修'
WHEN 20 THEN '待派單'
WHEN 21 THEN '待接單'
WHEN 4 THEN '駁回'
WHEN 5 THEN '已完成'
END AS REPAIR_PROGRESS_Name
FROM
NC_EQU_MAINTAIN a
WHERE
a.IS_DELETE = 0
ORDER BY
CASE a.REPAIR_PROGRESS
WHEN 3 THEN 1 -- 待驗證
WHEN 2 THEN 2 -- 待維修
WHEN 6 THEN 3 -- 重新維修
WHEN 20 THEN 4 -- 待派單
WHEN 21 THEN 5 -- 待接單
WHEN 4 THEN 6 -- 駁回
WHEN 5 THEN 7 -- 已完成
ELSE 8 -- 其他狀態
END;
請注意這裡的CASE