I've got two columns of data as below:
| Client | Type |
|---|---|
| A | Pencil |
| A | Ruler |
| A | Pen |
| B | Pencil |
| B | Ruler |
| C | Pencil |
| C | Pen |
I want to pivot 'Type' and make them the columns and group by 'Client'. Result would look like below:
| Client | Count(Pencil) | Count(Ruler) | Count(Pen) |
|---|---|---|---|
| A | 1 | 1 | 1 |
| B | 1 | 1 | 0 |
| C | 1 | 0 | 1 |
How can I achieve this on SQL Server?
Thanks