I have the following table :
group_id amount type
1 10 1
1 2 1
1 5 2
1 4 3
2 5 1
and I am looking for a view that will aggregate the data in this table such that the view produces something like this and can hopefully do it in a dynamic way:
group_id type1_amount type2_amount type3_amount
1 12 5 4
2 1 NULL NULL
My preference is to use a view in MySQL (if you have a better option I am open to hear it) and the big restriction of views in MySQL is that sub selects in the FROM clause are not allowed.
1 Answer