Screen Link:
Write a query that returns student_id
and a correlated subquery that returns the matching average group-wise writing_score
for each parental_education
category. Alias the result of the correlated subquery as parental_education_avg_writing
.
My Code:
SELECT student_id,
(SELECT AVG(writing_score)
from performance p1 where p1.parental_education = p2.parental_education
group by parental_education) as parental_education_avg_writing
from performance p2;
My Quesiton:
Why do we need to equate p1.parental_education = p2.parental_education ?
Trying to understand the logic.
Thank you!