34,575
社区成员
发帖
与我相关
我的任务
分享
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 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