I'd like to get something a little bit strange.
Let me start with what I want:
day Code0 Code1 ... ... CodeN
01/01/2016 20 23 3
02/01/2016 16 18 7
etc
Given that I have a table Codes this is what I have so far:
select [day], SUM(value) as Total, code into #tablaTemporal1
from Codes
group by [day], code
Which gives me:
day Total Code
01/01/2016 20 Code0
01/01/2016 23 Code1
01/01/2016 3 CodeN
02/01/2016 16 Code0
02/01/2016 18 Code1
02/01/2016 7 CodeN
etc
It's important to say that the number of different codes N is limitless; and by limitless I mean that they might change.
Is there any way to instead of getting a row for each day and code I get a single row per day but giving me the total for each code in the columns?