logo

Flights Database Queries

   

Added on  2019-09-23

6 Pages319 Words295 Views
 | 
 | 
 | 
Q1. Show the total number of flightsSELECT count(*) FROM FLIGHTS WHERE dep_time is not null;Q2. Show the total number of flights by airline (carrier)SELECT CARRIER, COUNT(*) TOTAL_FLIGHTS FROM FLIGHTS WHERE CARRIER IN(SELECT CARRIER FROM AIRLINES) GROUP BY CARRIER;
Flights Database Queries_1

Q3. Show all of the airlines, ordered by number of flights in descending orderSELECT CARRIER, COUNT(*) TOTAL_FLIGHTS FROM FLIGHTS WHERE CARRIER IN(SELECT CARRIER FROM AIRLINES) GROUP BY CARRIER ORDER BY TOTAL_FLIGHTS DESC;Q4. Show only the top 5 airlines, by number of flights, ordered by number of flights in descending orderSELECT CARRIER, COUNT(*) TOTAL_FLIGHTS FROM FLIGHTSWHERE CARRIER IN(SELECT CARRIER FROM AIRLINES)GROUP BY CARRIERORDER BY TOTAL_FLIGHTS DESC LIMIT 5;
Flights Database Queries_2

Q5. Show only the top 5 airlines, by number of flights of distance 1,000 miles or greater, ordered by number offlights in descending orderSELECT CARRIER, COUNT(*) TOTAL_FLIGHTS, DISTANCE FROM FLIGHTSWHERE CARRIER IN(SELECT CARRIER FROM AIRLINES) AND DISTANCE >= 1000GROUP BY CARRIERORDER BY TOTAL_FLIGHTS DESC LIMIT 5;
Flights Database Queries_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents