Hi. I have a question about using non- related subqueries.
In the given exercise, the given proper solution is
AVG(a.flight_distance) AS average_distance
sum(distance) AS flight_distance
GROUP BY 1,2,3
GROUP BY 1,2
ORDER BY 1,2;
But as I was coding, I sprung up with the idea that the whole subquery was unnecessary, so I wrote my own code without the subquery as below.
AVG(SUM(flight_distance)) AS average_distance
GROUP BY 1, 2;
but the query did not work at all.
I don’t see the difference between the two and super confused
somebody help me