Challenge¶
Using the austin_bikeshare public dataset, calculate summary statistics on all the trips. Namely,
- total trips
- min_start_time
- max_start_time
- avg_duration_minutes
How do I access the austin_bikeshare dataset?
Solution¶
SELECT
count(*) as trips,
min(start_time) as min_start_time,
max(start_time) as max_start_time,
avg(duration_minutes) as avg_duration_minutes
FROM `bigquery-public-data.austin_bikeshare.bikeshare_trips`
Explanation
count(*)counts the number of rows in the table.min(start_time) as min_start_timeaggregates thestart_timefield, measuring the minstart_timeand naming the resultmin_start_time.max(start_time) as max_start_timeaggregates thestart_timefield, measuring the maxstart_timeand naming the resultmax_start_time.avg(duration_minutes) as avg_duration_minutesaggregates theduration_minutesfield, measuring the mean duration_minutes and naming the resultavg_duration_minutes.FROM bigquery-public-data.austin_bikeshare.bikeshare_tripsreferences thebikeshare_tripstable in theaustin_bikesharedataset in thebigquery-public-dataproject.