分页limit
(n-1) * size,size
group by 分组
使用GROUP BY关键字对查询结果分组
对所有的数据进行分组统计
分组的依据字段可以有多个,并依次分组
与HAVING结合使用,进行分组后的数据筛选
分组一般会与聚合函数avg min max count sum having等一起用
对科目分组,查找科目
select subjectno from result group by subjectno;
求各科目的平均值(将科目分组,再求每科的平均值)
select subjectno,avg(studentresult) from result group by subjectno;
找各科目的最大最小值
select subjectno,min(studentresult) minscore,max(studentresult) maxscore from result group by subjectno;
UNION
select name from car;
select name from qiche;
select name from car union select name from qiche;
select name from car union all select name from qiche;