sql查询

student    kemu

A             语文

A             语文

A             数学

B             语文

B             数学

如何实现查询:

student     语文     数学

A              2          1

B              1          1

SQL:

select student ,sum(case kemu when '语文' then 1 esle 0 end) 语文,

                      sum(case kemu when '数学then 1 esle 0 end) 数学

                      from table group by student

原文地址:https://www.cnblogs.com/zhuhoumo/p/2854444.html