求sql语句,空值和数字混合排序
一张表,如 student 字段 name age sex
现在以age升序排列,但有些age值会是空的,
默认空值排在了最前,现在想把空值排到后面 该怎么写啊
现在以age升序排列,但有些age值会是空的,
默认空值排在了最前,现在想把空值排到后面 该怎么写啊
作者: wishifef 发布时间: 2011-06-15
SQL code
select * from tb order by case when age is null then 1 else 0 end, age
作者: FlySQL 发布时间: 2011-06-15
SQL code
select * from tb order by (case when age is null then 0 else age end) desc
作者: zy112429 发布时间: 2011-06-15