1,使用ORDER BY子句:
2,当排序列含空值时
ASC:排序列为空值的元组最后显示
DESC:排序列为空值的元组最先显示
eg:
SQL> select * from customers order by dob;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ---------- -------------- ------------
SQL> select * from customers order by dob asc;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ---------- -------------- ------------
SQL> select * from customers order by dob desc;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ---------- -------------- ------------
SQL> select * from customers order by last_name desc;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ---------- -------------- ------------
SQL> select * from customers order by last_name asc;
CUSTOMER_ID FIRST_NAME LAST_NAME DOB PHONE
----------- ---------- ---------- -------------- ------------