英文:
my query won't run, and I think the query is correct, anyone knows what I did wrong?
问题
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
这个查询的一部分在BigQuery上被标记为语法错误(start_station_name,),我按照我的教程中的方式精确复制了它。但它没有返回结果。
英文:
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, end_station, usertype
ORDER BY num_trips DESC LIMIT 10
This part of the query was underlined as a SYNTAX error on the big query (start_station_name,) I copied it the exact way my instructor did on a course. But it didn't return a result.
答案1
得分: 1
修复了你的查询:
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 usertype, start_station_name, end_station_name ORDER BY num_trips DESC LIMIT 10
已经修复了usertype后面的逗号问题,也修复了int64后面的括号问题,以及修正了GROUP BY中的列名。查询现在可以运行并生成结果。
英文:
fixed the query for you:
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
there was a missing comma after usertype. there was missing parenthesis after int64. the group by had the wrong column names.
query runs and produces results.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论