PostgreSQL 按指定顺序排序
SELECT stage, pln_status FROM project ORDER BY CASE WHEN pln_status = '规划' THEN 1 WHEN pln_status = '初选' THEN 2 WHEN pln_status = '查勘' THEN 3 WHEN pln_status = '评审' THEN 4 WHEN pln_status = '批复' THEN 5 WHEN pln_status = '初设' THEN 6 WHEN pln_status = '开工' THEN 7 END
SELECT * FROM person ORDER BY CASE constellation WHEN '白羊' THEN 1 WHEN '金牛' THEN 2 WHEN '双子' THEN 3 WHEN '巨蟹' THEN 4 WHEN '狮子' THEN 5 WHEN '处女' THEN 6 WHEN '天秤' THEN 7 WHEN '天蝎' THEN 8 WHEN '射手' THEN 9 WHEN '摩羯' THEN 10 WHEN '水瓶' THEN 11 WHEN '双鱼' THEN 12 END DESC