forked from musa-5090-spring-2024/assignment01
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery09.sql
More file actions
29 lines (25 loc) · 716 Bytes
/
query09.sql
File metadata and controls
29 lines (25 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
List all the passholder types and number of trips for each across all years.
In other words, in one query, give a list of all `passholder_type` options
and the number of trips taken by `passholder_type`. Your results should have
two columns: `passholder_type` and `num_trips`.
*/
-- Enter your SQL query here
SELECT
passholder_type,
SUM(num_trips) AS num_trips
FROM (
SELECT
passholder_type,
COUNT(*) AS num_trips
FROM indego.trips_2021_q3
GROUP BY passholder_type
UNION ALL
SELECT
passholder_type,
COUNT(*) AS num_trips
FROM indego.trips_2022_q3
GROUP BY passholder_type
)
GROUP BY passholder_type
ORDER BY passholder_type;