Created
June 4, 2019 14:44
-
-
Save technillogue/fa60d9243a31e6a3ef7709982441916b to your computer and use it in GitHub Desktop.
example of average cost per minute of flights involving various airports
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
| sqlite> # departure_airport, arrival_airport, cost (EUR), travel_time (minutes) | |
| sqlite> SELECT * FROM flights;AMS|KBP|329|170 | |
| AMS|OTP|308|165 | |
| BRU|KBP|70|165 | |
| BRU|OTP|110|165 | |
| CDG|KBP|201|185 | |
| CDG|OTP|160|170 | |
| CDG|AMS|588|80 | |
| CDG|BRU|287|55 | |
| KBP|AMS|423|185 | |
| KBP|CDG|293|205 | |
| KBP|BRU|191|185 | |
| OTP|AMS|229|180 | |
| OTP|BRU|313|170 | |
| sqlite> # airport, # of flights involving that airport, average cost per minute of flights involving that airport | |
| sqlite> SELECT airport, COUNT(COST), SUM(COST)*1.0/SUM(travel_time) AS avg_cost_per_minute FROM (SELECT departure_airport AS airport, cost, travel_time FROM flights UNION ALL SELECT arrival_airport AS airport, cost, travel_time FROM flights) GROUP BY airport ORDER BY avg_cost_per_minute; | |
| BRU|5|1.31216216216216 | |
| OTP|5|1.31764705882353 | |
| KBP|6|1.37625570776256 | |
| CDG|5|2.2 | |
| AMS|5|2.40641025641026 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment