Group Summary Statistics In SQL | Dataquest
SELECT Major_category, SUM(Women) AS Total_women, AVG(ShareWomen) AS Mean_women, SUM(Total) * Mean_women AS Estimate_women FROM recent_grads GROUP BY Major_category;
I expected code to execute however I receive an error. When I replace “Mean_women” by AVG(ShareWomen) in the following line of code, it works.
SUM(Total) * AVG(ShareWomen) AS Estimate_women
My query is why is the code not working using the alias defined previously ?