I have a table that actually already is neatly structured, but I need to change the output format. The initial table is of the format
Class Type Value
c1 t1 1
c2 t1 2
c3
c1 t2 3
c2 t2 2
c3 t2 5
c2 t3 1
c3 t4 6
c1 t1 9
c2 t1 2
I need to dynamically create a table that has the different classes as rows, the types as columns and sums the values. the types are not fixed, so I can't build a static table. How can I dynamically create a table that looks like
class t1 t2 t3 t4
c1 10 3 0 0
c2 4 2 1 0
c3 0 5 0 6
Is there a way to do that rather easily with sql?
As I was pointed to pivot, I had a look into it just to learn that mysql is not supporting this. what is the easiest and most straightforward way in sql to mimic pivot?