ORDER BY { column-Name | ColumnPosition | Expression }
[ ASC | DESC ]
[ NULLS FIRST | NULLS LAST ]
[ , column-Name | ColumnPosition | Expression
[ ASC | DESC ]
[ NULLS FIRST | NULLS LAST ]
] *
order by
后面可以接列号(数字)、列名、别名、表达式、函数、分组函数order by
对空值的处理,DESC
空值在前,ASC
空值在后;order by
子句中可以不含select
中的列;select distinct
或group by
时,order by
不能使用select之外的列;select job, avg(sal) "Average Salary"
from emp
group by job
order by "Average Salary" DESC;
原文:https://www.cnblogs.com/hyang0/p/10587003.html