单一字段排序 order by 字段名称
作用:通过哪个或哪些字段进行排序
含义:排序采用 order by 子句,order by 后面跟上排序字段,排序字段可以放多个,多个采用逗号间隔,order by默认采用升序(asc),如果存在 where 子句,那么 order by 必须放到where 询句后面。
1)按照薪水由小到大排序(系统默认由小到大)
select ename,sal from emp order by sal;
2)取得job为MANAGER的员工,按照薪水由小到大排序(系统默认由小到大)
select ename,job,sal from emp where job = „MANAGER‟order by sal;
如果包含 where 语句 order by 必须放到where后面,如果没有where语句order by放到表的后面;
3)以下询法是错诣的:
a) select * from emp order by sal where
b) select * from emp order by sal where job = ‘MANAGER’;