分组查询--group by
select stuClass,stuName,stuSubject from studentScore group by stuName,stuSubject,stuClass
一般用在聚合函数,如看看每个班有多少人
select count(stuClass) from studentScore group by stuClass
分组后再进行筛选--having 如分完组成不想看到己查出的某列,可进行再次筛选,加入having claName!='计算机五班'
select claName,count(stuClass) from studentScore ,stuClass where stuClass=claID group by stuClass,claName having claName!='计算机系五班'
阅读(1621) | 评论(0) | 转发(0) |