<p>I have a table like as follows:</p>

<pre>
SoftwareName    Count    Country
Project         15       Canada
Visio           12       Canada
Project         10       USA
Visio           5        USA
</pre>

<p>How do I query it to give me a summary like...</p>

<pre>
SoftwareName    Canada    USA    Total
Project         15        10     25
Visio           12        5      17
</pre>

<p>How to do in T-SQL?</p>

```
```
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;
```
```