select articleid, count(case when typeID=1 then 1 else null end) as down, count(case when typeID=2 then 1 else null end) as read, count(case when typeID=3 then 1 else null end) as show from a group by articleID
select count(CASE WHEN typeID=1 THEN 1 ELSE 0 END) as down, count(CASE WHEN typeID=2 THEN 1 ELSE 0 END) as read, count(CASE WHEN typeID=3 THEN 1 ELSE 0 END) as show from a group by articleID
select articleID, max(case when typeID=1 then count (typeID)else 0 end ) as [down], max(case when typeID=2 then count (typeID) else 0 end) as [read], max(case when typeID=3 then count (typeID) else 0 end) as [show] from a group by articleID
select sum(case typeid when 1 then 1 else 0 end) down, sum(case typeid when 2 then 1 else 0 end) read, sum(case typeid when 3 then 1 else 0 end) show, from a
额错了。。select count(CASE WHEN typeID=1 THEN 1 ELSE null END) as down, count(CASE WHEN typeID=2 THEN 1 ELSE null END) as read, count(CASE WHEN typeID=3 THEN 1 ELSE null END) as show from a group by articleID -- select SUM(CASE WHEN typeID=1 THEN 1 ELSE 0 END) as down , SUM(CASE WHEN typeID=2 THEN 1 ELSE 0 END) as READ , SUM(CASE WHEN typeID=3 THEN 1 ELSE 0 END) as show from a group by articleID
count(case when typeID=1 then 1 else null end) as down,
count(case when typeID=2 then 1 else null end) as read,
count(case when typeID=3 then 1 else null end) as show
from a
group by articleID
max(case when typeID=1 then count (typeID)else 0 end ) as [down],
max(case when typeID=2 then count (typeID) else 0 end) as [read],
max(case when typeID=3 then count (typeID) else 0 end) as [show]
from a group by articleID
sum(case typeid when 2 then 1 else 0 end) read,
sum(case typeid when 3 then 1 else 0 end) show,
from a
--
select SUM(CASE WHEN typeID=1 THEN 1 ELSE 0 END) as down
, SUM(CASE WHEN typeID=2 THEN 1 ELSE 0 END) as READ
, SUM(CASE WHEN typeID=3 THEN 1 ELSE 0 END) as show
from a group by articleID