DQL(select查询)

 

 

 

 

 

 

 

 

 

 

 

 select sal+ifnull(comn,0) as total from emp

如果comn值为null直接将值替换为0与sal相加,如果不为null就有原值与sal相加

as是相加的加过列名称叫total

 

 order by 列名 asc(默认升序)  desc降序

 

 查询所有雇员,按月薪降序排序,如果月薪相同时,按编号降序排序

select * from emp order by sal desc,empno desc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2021-07-05 17:51  温柔他  阅读(234)  评论(0编辑  收藏  举报