41.排序查询总结

select  查询列表

form 表

where 筛选条件

order by paixu列表  asc/desc

1.asc 代表升序,desc带表降序

如果不写默认升序

order  by可以支持单个字段,多个字段,表达式,函数,别名

一般在最后

 

案例1:查询员工信息,从低到高排

select*from employees order by salary desc;

select*from emplouess oder by salary asc;

 

查询员工的姓名和年薪,按案例年薪降序,姓名升序

select lat_name,salary *12(1+ifnull(commission_pct,0))from employee order by salary   desc,lat_name 

 asc;

select last_name,salary from employee where  salary not between 8000 and

17000 oder by salary desc;

select*from  where email like"%e%" order by  length(email) desc,department_id

asc;

posted @ 2022-07-07 11:07  langpo  阅读(28)  评论(0)    收藏  举报