I have a table that look like this.
ID_ACTIVITY ID_CLASS EXEC_VALUE
ACT_III A 450
ACT_I B 550
ACT_II A 750
ACT_III B 550
ACT_II A 650
ACT_I A 750
ACT_I B 750
ACT_III A 950
ACT_III A 150
I'd like to create a report based on this table into some kind of pivot table. This should be the report output
ID_ACTIVITY A_COUNT B_COUNT AB_SUM
ACT_I 1 2 2050
ACT_II 2 NULL 1500
ACT_III 3 1 2100
Note :
A_COUNT
andB_COUNT
are dynamic based on the value inID_CLASS
AB_SUM
is based on the value ofEXEC_VALUE
in eachID_ACTIVITY
in eachID_CLASS
I have done it using PHP, but I wonder is it possible do it in MySQL way and is it faster to generate with around thousand of data?