I have a table that looks like this:
|date |category_id|val
|2010-08-09|1 |2
|2010-08-09|2 |45
|2010-08-10|3 |1500
|2010-08-10|2 |4
I would like to select from this table, that each category id is a column so the end result looks like this:
|date |1 |2 |3
|2010-08-09|2 |45 |NULL
|2010-08-10|NULL |4 |1500
Is something like this possible with a single SELECT
statement or stored procedure, without using an extra table and without knowing all category_id values beforehand?