如图所示,要从表中查询出下边所示的结果,使用的sql语句是分组计数。如下所示:
SELECT i_name,
"sum"(case when i_status='y' then 1 else 0 end) AS y,
"sum"(case when i_status='n' then 1 else 0 end) AS n
from qq GROUP BY i_name;
如图所示,要从表中查询出下边所示的结果,使用的sql语句是分组计数。如下所示:
SELECT i_name,
"sum"(case when i_status='y' then 1 else 0 end) AS y,
"sum"(case when i_status='n' then 1 else 0 end) AS n
from qq GROUP BY i_name;