I have a table with columns sales(int), month(int). I want to retrieve sum of sales corresponding to every month. I need ouput in form of 12 columns corresponding to each month in which there will be a single record containing sales for for each column(month).
I have a table with columns sales(int) , month(int) . I want to retrieve
Share
You should take a look at PIVOT for switching rows with columns. This prevents a select statement for each month. Something like this: