Course Content
Intermediate SQL
2. Nested Subqueries
4. Left, Right, and Inner Joins
Intermediate SQL
Challenge: Average Ride Time for Each Subway Line
Note
AVG(column)
function returns the average value of some column.The
ORDER BY
clause can sort the data in descending order. To do this, we need to specify the keywordDESC
.
Task
You have to count the average ride time (create a new column, named average_time
using time_to_next_station
and AVG()
function) of the driving of each subway line (line_name
column). Order the result by the average_time
column in descending order.
Here's a short example of the relation
table:
relation_id | line_name | station_name | time_to_next_station |
1 | Green | Angrignon | 10 |
2 | Green | Monk | 16 |
3 | Green | Verdun | 9 |
... | ... | ... | ... |
21 | Yellow | Longueuil | 10 |
Everything was clear?
Section 1. Chapter 4