Order by
用来对数据库的一组数据进行排序,
desc:降序 ,记住用语(大的往上升,数据大到小下降)
sql语句:select number,name from Students order by number desc 降序
asc:升序,记住用语(少的往上升,数据小到大上升)
sql语句:select number,name from Students order by number asc 升序
Group by
指定的规则对数据进行分组,所谓的分组就是将一个“数据集”划分成若干个“小区域”,然后针对若干个“小区域”进行数据处理。
分类汇总
select lei ,SUM(sun) as sun from aaa group by lei
员工表
薪水表
Group by 和 Order by 组合用
查询当前每个部门,薪水最高的员工
select a.dept_no,a.emp_no,Max(b.salary) as maxsalary
from dept_emp as a
join salaries as b
on a.emp_no = b.emp_no
Group by dept_no order by dept_no
常见的聚合函数:
相关文章
暂无评论...