[英]I am having issues with a SQL query
I was following along with my instructor on the google data analytics course, below is the code I wrote and I keep getting an error我和我的讲师一起参加了谷歌数据分析课程,下面是我写的代码,但我一直收到错误
SELECT
usertype,
CONCAT(start_station_name, " to ", end_station_name) AS route,
COUNT(*) as num_trips,
ROUND(AVG(cast(tripduration as int64)/60).2)
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
The error is Cannot access field 2 on a value with type FLOAT64 at [5:45]错误是在 [5:45] 无法访问类型为 FLOAT64 的值的字段 2
You have a typo in your round function, it is written as ROUND(AVG(cast(tripduration as int64)/60).2)
and it is supposed to be ROUND(AVG(cast(tripduration as int64)/60), 2)
.您的回合 function 中有错字,写为
ROUND(AVG(cast(tripduration as int64)/60).2)
应该是ROUND(AVG(cast(tripduration as int64)/60), 2)
。
The dot represents that you are trying to access the field "2" of the AVG(cast(tripduration as int64)/60)
value, which is a FLOAT64, therefore creating the error "Cannot access field 2 on a value with type FLOAT64 at [5:45]".点表示您正在尝试访问
AVG(cast(tripduration as int64)/60)
值的字段“2”,这是一个 FLOAT64,因此创建错误“无法访问类型为 FLOAT64 的值的字段 2” [5:45]”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.