This can be done in SQL, although this is probably not the best tool for the job, as others commented already.
The logic is to use conditional aggregation… and a lot of typing. Here is an example for 3 columns (col1
, col2
and col3
) and two days ('Mon'
and 'Tue'
):
select class,
max(case when day = 'Mon' then col1 end) mon_1,
max(case when day = 'Mon' then col2 end) mon_2,
max(case when day = 'Mon' then col3 end) mon_3,
max(case when day = 'Tue' then col1 end) tue_1,
max(case when day = 'Tue' then col2 end) tue_2,
max(case when day = 'Tue' then col3 end) tue_3
from mytable
group by class_id, class
You can then expand the same logic for the other days and columns.
CLICK HERE to find out more related problems solutions.