1、默认升序asc
2、order by 后面可以 + 列、表达式、别名、序号
别名:select empno,ename,sal,sal*12 年薪 from emp order by 年薪 desc;
序号:select empno,ename,sal,sal*12 from emp order by 4 desc;
3、多个列排序:
select * from emp order by deptno,sal;
先按第一个列升序,然后第二个列相同的话,按第二个降序排列
select * from emp order by deptno,sal desc;
总结:
order by作用于后面所有列,先
desc只作用于理他最近的列
4、null值在order by中显示:oracle中null最大
5、让null在最后显示select * from emp order by comm nulls last;