Wednesday, 15 July 2015

sql server - How to create table with data stored in columns instead of rows? -


I have a table with 3 columns: Store ID, Product type, Product volume like this:

  store1 shirt 3 store1 hat 2 store2 shirt 1 store3 hat4   

I want to change this table in the following format (caption in shirt volume and column 3 in column 2 With volume):

  store1 3 2 store2 1 - store3 - 4   

To do this I used my select statement How do i write Thank you. Try multiple aggregates on rows:

Try multiple aggregations on rows:

  select store, amount (Case when the product = 'shirt' then the quantity ELSE 0 END) AS shirt, yoga (in case the product = 'cap' then the quantity ELSE 0 END) cap from the store of your tomb group   

If it is not what you mean, you have to provide more information.

No comments:

Post a Comment