what database are you using? if you are using SQL Server, you can try something likeselect
sum(case when class = 1 then 1 else 0 end) as 1班,
sum(case when class = 2 then 1 else 0 end) as 2班,
sum(case when class = 3 then 1 else 0 end) as 3班,
count(*) as 小计
from student
sum(case when class = 1 then 1 else 0 end) as 1班,
sum(case when class = 2 then 1 else 0 end) as 2班,
sum(case when class = 3 then 1 else 0 end) as 3班,
count(*) as 小计
from student
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货