I have these 2 tables:
Table Users:
id | name
---------
1 | Joe
2 | Sara
3 | Michael
Table Sales:
id | product | user_id
------------------------
1 | Car | 2
2 | Truck | 3
3 | motorcycle| 1
4 | Car | 2
5 | Truck | 1
6 | Car | 3
7 | Car | 2
8 | Truck | 3
9 | Car | 2
10 | Car | 3
I want the following:
User Name | Car | Truck | Motorcycle
Joe | 0 | 1 | 1
Sara | 4 | 0 | 0
Michael | 2 | 2 | 0
Any help would be appreciated