select sum(case when depart = 'Physical' then 1 else 0 end) PhyTotal, sum(case when depart = 'Chemistry' then 1 else 0 end) CheTotal, sum(case when depart = 'Math' then 1 else 0 end ) MathTotal from student
select sum(case when depart = 'Physical' then 1 else 0 end) PhyTotal, sum(case when depart = 'Chemistry' then 1 else 0 end) CheTotal, sum(case when depart = 'Math' then 1 else 0 end ) MathTotal from student
转载于:https://www.cnblogs.com/ligongzi/p/4459787.html