You never mentioned the subjects.
You have to add them to the query that constructs the basedata (the selects with union all).
with basedata (
name,
addy,
ph,
subject,
grade
) as (
select
name,
addy,
ph,
'Subject 1',
grade1
from
sourcetable
union all
select
name,
addy,
ph,
'Subject 2',
grade2
from
sourcetable
union all
...