0% found this document useful (0 votes)
198 views

Intro To BigQuery Solutions

This document provides solutions to introductory BigQuery queries on London bicycle rental data. It includes 5 queries that find the station names a bike started from, count the number of bikes ending at a specific station, lookup a station ID and name by name and ID, and count bikes with trip durations over 40 minutes. The solutions demonstrate basic BigQuery syntax like SELECT, FROM, WHERE, and COUNT(DISTINCT).

Uploaded by

Ani778
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views

Intro To BigQuery Solutions

This document provides solutions to introductory BigQuery queries on London bicycle rental data. It includes 5 queries that find the station names a bike started from, count the number of bikes ending at a specific station, lookup a station ID and name by name and ID, and count bikes with trip durations over 40 minutes. The solutions demonstrate basic BigQuery syntax like SELECT, FROM, WHERE, and COUNT(DISTINCT).

Uploaded by

Ani778
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Intro to BigQuery solutions

These are the solutions to the Intro to BigQuery activity. You can refer to this document if you
are troubleshooting your own queries. You can also copy and paste these solutions to test them
in your own BigQuery console.

1. From which station names has bike_id 1710 started?


SELECT
DISTINCT start_station_name
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
bike_id = 1710;

2. How many bike_ids have ended at "Moor Street, Soho"?

SELECT
COUNT (DISTINCT bike_id) AS num_of_bikes
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
end_station_name = 'Moor Street, Soho';

3. What is the station_id for "Canton Street, Poplar"?

SELECT
DISTINCT start_station_id --can also use end_station_id
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
start_station_name = 'Canton Street, Poplar' --can also use end_station_name

4. What is the name of the station whose ID is 111?

SELECT
DISTINCT start_station_name --can also use end_station_name
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
start_station_id = 111 --can also use end_station_id

5. How many distinct bike_ids had trip durations greater than 2400 seconds (or 40
minutes)?

SELECT
COUNT(DISTINCT bike_id) AS num_of_bike_trips
FROM
`bigquery-public-data.london_bicycles.cycle_hire`
WHERE
duration > 2400 --schema indicates that trip duration is recorded in seconds

You might also like