How can I group pivot query by the category. I can achieve this in Excel but I wanted to do in SQL Oracle query.
Let say we have data like this:-
I can simply pivot to get grade count by subject
select * from (select studentID, subject, grade from table_student)
PIVOT
(
sum (grade) FOR (subject) IN ('A','B','C')
)
order by studentID;
and get grade count by category
select * from (select studentID, category, grade from table_student)
PIVOT
(
sum (grade) FOR (category) IN ('Common','Science')
)
order by studentID;
But my question can I combine these query and get result like below using SQL?
Thank you!!