course content

Course Content

Intermediate SQL

Challenge: The Shortest Ride of Each Subway LineChallenge: The Shortest Ride of Each Subway Line

Note

MIN(column) function returns the smallest value in a particular column.

The LIMIT clause helps you to get a certain number of rows.

Task

You have to find the shortest trip (create a new column, named min_time using time_to_next_station and MIN() function) of each subway line (line_name column). Order it by the min_time column in ascending order and print the first three rows.

Here's a short example of the relation table:

relation_idline_namestation_nametime_to_next_station
1GreenAngrignon10
2GreenMonk16
3GreenVerdun9
............
21YellowLongueuil10

Everything was clear?

Section 1. Chapter 5
toggle bottom row