Oracle查询语句——排序

本文记录Oracle学习过程中遇到的Oracle查询语句——排序~

语句格式:

select *|{olumn,...} from table order by column1 asc|desc, column2 asc|desc;

示例代码:

select * from emp order by sal;
select * from emp order by sal desc;
select * from emp order by sal asc, hiredate desc;

注意:order by语句要放到SQL的最后。

空值问题

当排序时,可能列的取值为null,这时可以使用nulls first,nulls last来指定null值显示的位置。

示例代码:

select * from emp order by sal nulls first;
select * from emp order by sal desc nulls last;

标签: none