要求查询指定的一些系的学生姓名和性别,我想着可不可以用分组查询,结果查询出来是这样,并没有分组显示,应该怎么写这类功能的语句啊,求解!!!
group by sdept 不可以么
select sname,ssex from student where sdept in('IS','MA','CS') order by sdept;
你可以试试,希望能帮上你
只有一张表吗?只有一张表的话可以用楼上的方式,多张表要把表全部贴出来啊
按二楼写法,分组请用group by
按系别进行分组记录:
group by SDEPT
有兴趣可以看看:MySQL如何优化GROUP BY http://www.data.5helpyou.com/article237.html
select distinct sname,ssex from student where sdept in('IS','MA','CS') order by sdept