I have some data that looks like this:
ID NAME COUNT PRODUCTNAME
1 Tom's Garage 5 Brakes
1 Tom's Garage 3 Tail Lights
1 Tom's Garage 3 Mufflers
1 Tom's Garage 2 Spark Plugs
1 Tom's Garage 1 Oil Filters
Needs to look like this
ID NAME COUNT1 PRODUCT1 COUNT2 PRODUCT2 COUNT3 PRODUCT3 COUNT4 PRODUCT4 COUNT5 PRODUCT5
1 Tom's Garage 5 Brakes 3 Tail Lights 3 Mufflers 2 Spark Plugs 1 Oil Filters
I know there is a PIVOT function in SQL 2005 that I have been trying to use but I have been unsuccessful in getting it to work. Any help would be appreciated.
Thanks
ID NAME COUNT PRODUCTNAME
1 Tom's Garage 5 Brakes
1 Tom's Garage 3 Tail Lights
1 Tom's Garage 3 Mufflers
1 Tom's Garage 2 Spark Plugs
1 Tom's Garage 1 Oil Filters
Needs to look like this
ID NAME COUNT1 PRODUCT1 COUNT2 PRODUCT2 COUNT3 PRODUCT3 COUNT4 PRODUCT4 COUNT5 PRODUCT5
1 Tom's Garage 5 Brakes 3 Tail Lights 3 Mufflers 2 Spark Plugs 1 Oil Filters
I know there is a PIVOT function in SQL 2005 that I have been trying to use but I have been unsuccessful in getting it to work. Any help would be appreciated.
Thanks