Advertisement
VladikOtez

task SQL

Dec 28th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.33 KB | None | 0 0
  1. SELECT a.dep_month,
  2.        a.dep_day_of_week,
  3.        AVG(a.flight_distance) AS average_distance
  4.   FROM (
  5.         SELECT dep_month,
  6.               dep_day_of_week,
  7.                dep_date,
  8.                SUM(distance) AS flight_distance
  9.           FROM flights
  10.          GROUP BY 1,2,3
  11.        ) a
  12.  GROUP BY 1,2
  13.  ORDER BY 1,2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement