oracle order by 排序
Syntax
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之外的列; order by只能放最后,不能放集合操作的中间;- 集合操作后,不接
order by时按第一列进行升序排序(union all除外); - 集合操作后的列名为第一个
select的内容,order by只能选第一个select中的内容进行操作
select job, avg(sal) "Average Salary"
from emp
group by job
order by "Average Salary" DESC;
posted on 2019-03-24 09:25 Digital_life 阅读(7280) 评论(0) 收藏 举报
浙公网安备 33010602011771号