logo

SQL queries for flights database

2 Pages515 Words428 Views
   

Added on  2019-09-23

About This Document

This article provides SQL queries for flights database to find the furthest distance destination and aircraft with most number of seats for different numbers of engines.

SQL queries for flights database

   Added on 2019-09-23

ShareRelated Documents
1. Which destination in the flights database is the furthest distance away, based on information in the flights table. Show the SQL query(s) that support your conclusion.Query - SELECT DISTINCT carrier, flight, origin, dest, distance FROM flights WHERE distance = (SELECT MAX(distance) FROM flights);Output - ‘HA','51','JFK','HNL','4983'Therefore, the furthest distance destination is HNL which is Honolulu International airport.2. What are the different numbers of engines in the planes table? For each number of engines, which aircraft have the most number of seats? Show the SQL statement(s) that support your result.Query - SELECT engine FROM planes GROUPBY engine;Output - 4 Cycle Reciprocating Turbo-fan Turbo-jet Turbo-prop Turbo-shaft Therefore, there are 6 different numbers of engines in the plane tableQuery - SELECT DISTINCT model, seats FROM planes WHERE engine = 'Turbo-fan' AND seats = (SELECT MAX(seats) FROM planes WHERE engine = 'Turbo-fan');Output - ‘777-222,'400' , ’777-224,'400'Therefore, aircraft 777-222 and 777-224 has the most number of seats i.e. 400 for engine Turbo-fan.Query - SELECT DISTINCT model, seats FROM planes WHERE engine = 'Turbo-jet' AND seats =(SELECT max(seats) FROM planes WHERE engine = 'Turbo-jet');Output - ‘747-451,'450'Therefore, aircraft 747-451 has the most number of seats i.e. 450 for engine Turbo-jet.Query - SELECT DISTINCT model, seats FROM planes WHERE engine = 'Turbo-prop' AND seats= (SELECT max(seats) FROM planes WHERE engine = 'Turbo-prop');
SQL queries for flights database_1

End of preview

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