Created
June 6, 2013 05:32
-
-
Save rodriguezd/5719521 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Select the price of a flight | |
| SELECT price FROM flight WHERE id = 3; | |
| 2) Select the departing and arriving time of a flight | |
| SELECT departure_time, arrival_time FROM flight WHERE id = 3; | |
| 3) Select all flights that have only one stop. | |
| SELECT * FROM flight WHERE stops = 1; | |
| 4) Select all flights by any given airline. | |
| SELECT * FROM flight WHERE airline = 'American'; | |
| 5) How many flights does that airline list (using SQL!)? | |
| SELECT COUNT(*) FROM flight WHERE airline = 'American'; | |
| 6) How many of that airlines flights have wifi? | |
| SELECT COUNT(*) FROM flight WHERE wifi = 1; | |
| 7) What is the average cost of a flight? | |
| SELECT AVG(price) FROM flight; | |
| 8) Select all flights sorted by price. | |
| SELECT * FROM flight ORDER BY price; | |
| 9) How many flights leaving from JFK are shorter than 23 hours long? | |
| SELECT COUNT(*) FROM flight WHERE duration < 23; | |
| 10) What do you think the qualifications for the "best" flight would be? Do you need wifi? What is the max time you're willing to fly? Airline? Airport? Construct a SQL query that meets all the criteria and returns any flights that might match it. | |
| SELECT * FROM flight WHERE stops = 1 AND duration < 20 AND wifi = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment