解决方案 »

  1.   

    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  
      

  2.   

     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  
      

  3.   

    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
      

  4.   

    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
      

  5.   

    额错了。。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