Summarize aggregated data

前端 未结 5 1822
挽巷
挽巷 2021-01-13 14:27

I have a table like as follows:

SoftwareName    Count    Country
Project         15       Canada
Visio           12       Canada
Project         10       USA
Visi         


        
5条回答
  •  遥遥无期
    2021-01-13 14:45

    SELECT SoftwareName, 
      SUM( CASE Country WHEN 'Canada' THEN [Count] ELSE 0 END ) AS Canada,
      SUM( CASE Country WHEN 'USA'    THEN [Count] ELSE 0 END ) AS USA,
      SUM( [Count] ) AS Total
    FROM [Table] 
    GROUP BY SoftwareName;
    

提交回复
热议问题