Screen Link: https://app.dataquest.io/m/543/subqueries/7/practice-integrating-a-subquery-with-the-outer-query
My Code:
SELECT Major, Major_category, CAST(Sample_size AS FLOAT)/Total AS ratio
FROM recent_grads
WHERE ratio > (SELECT AVG(CAST(Sample_size AS FLOAT)/Total) AS avg_ratio
FROM recent_grads);
Replace this line with your code
What I expected to happen: https://dev.mysql.com/doc/refman/8.0/en/problems-with-alias.html
From this website, it said Standard SQL disallows references to column aliases in a WHERE
clause. So my question is why the answer includes “WHERE ratio > (SELECT AVG(CAST(Sample_size AS FLOAT)/Total) AS avg_ratio
FROM recent_grads);” ? Thanks a lot!
What actually happened:
Replace this line with the output/error