首页 > 解决方案 > 任何 SQL 专家都可以检查我的 SQL 查询吗,它没有用

问题描述

SELECT 
usertype,
CONCAT(start_station_name, " to", end_station_name) AS route
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_trip desc 
LIMIT 100

标签: sqlgoogle-bigquery

解决方案


I was just going to post this as a comment, but wanted to offer some formatting advice too

SELECT 
    usertype,
    CONCAT(start_station_name, " to", end_station_name) AS route,
    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_trip DESC 
LIMIT 100

I think your issue was just the missing commas in the SELECT and GROUP BY sections, but I also recommend capitalizing all syntax and separating lists by indented new lines -- these things help spot errors


推荐阅读