Non-correlated subqueries 3. What does 'a' stand for?


#1

https://www.codecademy.com/en/courses/sql-table-transformation/lessons/subqueries/exercises/non-correlated-iii?action=resume

SELECT a.dep_month,
       a.dep_day_of_week,
       AVG(a.flight_count) AS average_flights
  FROM (
        SELECT dep_month,
              dep_day_of_week,
               dep_date,
               COUNT(*) AS flight_count
          FROM flights
         GROUP BY 1,2,3
       ) a
 GROUP BY 1,2
 ORDER BY 1,2;

#2

(
        SELECT dep_month,
              dep_day_of_week,
               dep_date,
               COUNT(*) AS flight_count
          FROM flights
         GROUP BY 1,2,3
       ) as a

The a is the so-called selection-alias
which you then use for instance a.flight_count


+++ show all table defintions
select * from sqlite_master;

++++ANALYZE in sqlite
http://stackoverflow.com/questions/17663379/how-to-understand-sqlite-explain-query-plan-result
http://www.sqlite.org/lang_analyze.html
http://www.sqlite.org/docs.html


#3

Thank you I now understand.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.