SQL之 ORDER BY の CASE WHEN

order by中的case when:

 order by case mnfc_instrct_lot_typ_kbn_nm when 'HOT' then 1 else 2 end asc

查询结果如下

case mnfc_instrct_lot_typ_kbn_nm when 'HOT' then 1 else 2 end asc

意思是: 该字段的值为‘HOT’的排在前面,否则排在后面(‘HOT’之后)。因为1 < 2,不局限于使用1和2,200和12312也可以,任意数字(正,负,小数)都可以使用。

升序asc:数字小的在前面,大的在后面。

降序desc:数字大的在前面,小的在后面。
原文地址:https://www.cnblogs.com/bors/p/bors_orderbycasewhen.html