默认:ASC 升序。DESC,降序。
没有order by,默认随机顺序。
order by在select语句的最后。
select expr from table [where condition(s)] [order by {column,expr} [ASC|DESC];
order by 指定被检索行的显示顺序。
select last_name,job_id,hire_date from employees order by hire_date DESC;
升序指:
1 数字先显示最小值,如1-999.
2 日期先显示最早的值。如01-JAN-92 显示在01-JAN-95之前。
3 字符按字母顺序。A-Z
4 空值在升序时显示在最后,降序时显示在最前。
--按列别名排序 select employee_id,last_name,salary*12 annsal from employees order by annsal;
--多个列排序,order by 列表的顺序就是排列的顺序。
--即使不在select 列表中,仍可按该列排序。 select last_name,salary from employees order by department_id,salary DESC;