Course Content
Intermediate SQL
2. Nested Subqueries
4. Left, Right, and Inner Joins
Intermediate SQL
More Complex Filtering
But we can also make more complicated filtering, for example, by two columns. Let's see the syntax of such filtering.
It will be easier to understand it in practice!
Task
You have to find the subway lines (line_name
column) with a total ride time (using the time_to_next_station column
and SUM()
function create new one, named total_time
) of more than 50 minutes and total number of stations (using the station_name column
and COUNT()
function create new one, named number_of_stations
) on this line is greater than 5.
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 8