Please answer in SQL: List all airlines. For every airline, compute the number of regional airports (full name of airport contains the string 'Regional') from which that airline does NOT fly, considering source airport only. Sort by airport count in descending order. airlines dataset Id : unique identifier of the airline Name : full name of the airline Abbr : abbreviated name of the airline Country : country of the airline airports dataset City : location of the airport Code : unique three-letter airport code Name : name of the airport Country : country of the airport CAbbr : abbreviation of the country flights dataset Airline : airline that manages the flight FlightNo : flight number (unique for each airline, may repeat for different airlines) Source : Code for the airport from which the flight originates Destination : Code for the airport at which the flight terminates Attempted (but incorrect) code: SELECT airlines.Name, COUNT(airports.Code) as num_airlines FROM airlines, airports WHERE airports.Name LIKE '%regional%' AND airports.Code NOT IN (SELECT source FROM flights) GROUP BY airlines.Id ORDER BY num_airlines DESC
Please answer in SQL: List all airlines. For every airline, compute the number of regional airports (full name of airport contains the string 'Regional') from which that airline does NOT fly, considering source airport only. Sort by airport count in descending order. airlines dataset Id : unique identifier of the airline Name : full name of the airline Abbr : abbreviated name of the airline Country : country of the airline airports dataset City : location of the airport Code : unique three-letter airport code Name : name of the airport Country : country of the airport CAbbr : abbreviation of the country flights dataset Airline : airline that manages the flight FlightNo : flight number (unique for each airline, may repeat for different airlines) Source : Code for the airport from which the flight originates Destination : Code for the airport at which the flight terminates Attempted (but incorrect) code: SELECT airlines.Name, COUNT(airports.Code) as num_airlines FROM airlines, airports WHERE airports.Name LIKE '%regional%' AND airports.Code NOT IN (SELECT source FROM flights) GROUP BY airlines.Id ORDER BY num_airlines DESC
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please answer in SQL:
List all airlines. For every airline, compute the number of regional airports (full name of airport contains the string 'Regional') from which that airline does NOT fly, considering source airport only. Sort by airport count in descending order.
airlines dataset
Id : unique identifier of the airline
Name : full name of the airline
Abbr : abbreviated name of the airline
Country : country of the airline
Name : full name of the airline
Abbr : abbreviated name of the airline
Country : country of the airline
airports dataset
City : location of the airport
Code : unique three-letter airport code
Name : name of the airport
Country : country of the airport
CAbbr : abbreviation of the country
Code : unique three-letter airport code
Name : name of the airport
Country : country of the airport
CAbbr : abbreviation of the country
flights dataset
Airline : airline that manages the flight
FlightNo : flight number (unique for each airline, may repeat
for different airlines)
Source : Code for the airport from which the flight originates
Destination : Code for the airport at which the flight terminates
FlightNo : flight number (unique for each airline, may repeat
for different airlines)
Source : Code for the airport from which the flight originates
Destination : Code for the airport at which the flight terminates
Attempted (but incorrect) code:
SELECT airlines.Name, COUNT(airports.Code) as num_airlines
FROM airlines, airports
WHERE airports.Name LIKE '%regional%'
AND airports.Code NOT IN (SELECT source FROM flights)
GROUP BY airlines.Id
ORDER BY num_airlines DESC
FROM airlines, airports
WHERE airports.Name LIKE '%regional%'
AND airports.Code NOT IN (SELECT source FROM flights)
GROUP BY airlines.Id
ORDER BY num_airlines DESC
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education