Oladeji Babatunde
Oladeji Babatunde

Reputation: 1

How do I Fix SQL Query Returning Error on Big Query

I am currently doing the google data analyst course and i am following the instructor but my query keep returning an error in the line 4 (count)

SELECT usertype, CONCAT(start_station_name, " to ", end_station_name) as route COUNT(*) as num_trips, ROUND(avg(cast(tripduration as int64)/60,2) as duration FROM bigquery-public-data.new_york_citibike.citibike_trips group by start_station_name, end_station_name, usertype order by num_trips DESC LIMIT 10

Upvotes: 0

Views: 121

Answers (1)

Kaan
Kaan

Reputation: 5794

Your "select" statement is not written correctly – it needs to follow "select x, y, z, ..." – commas separating each thing. In the query you posted, you're missing a comma after "route", just before "COUNT(*)".

To fix it, change your query from this:

SELECT usertype, 
CONCAT(start_station_name, " to ", end_station_name) as route 
COUNT(*) as num_trips,
...

to this – includes comma after "as route"

SELECT usertype, 
CONCAT(start_station_name, " to ", end_station_name) as route,
COUNT(*) as num_trips,
...

Upvotes: 0

Related Questions