简体   繁体   English

我遇到 SQL 查询问题

[英]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.

相关问题 在 bigqquery 中编写 sql 查询时出现错误 - I am having error while writing a sql query in bigqquery 我在导入 cloud_firestore 时出错 - I am having an error upon importing cloud_firestore 我是否有在 BigQuery 中注入 SQL 的风险? - Am I at risk for SQL injection in BigQuery? 在使用 pandas 在 python 中执行 SQL 查询时,我遇到了错误:TypeError: __init__() got multiple values for argument 'schema' - While performing SQL query in python using pandas i am facing the error : TypeError: __init__() got multiple values for argument 'schema' Android Studio 模拟器有问题 - Having issues with Android Studio Emulators 将表上传到 BigQuery 时遇到问题 - Having Issues Uploading Table to BigQuery 为什么在 Google BigQuery 上安排查询时出现错误? - Why am I getting an error when scheduling a query on Google BigQuery? 为什么我收到 TypeErrors 'x' is not a function with firebase 集合查询? - Why am I getting TypeErrors 'x' is not a function with firebase collection query? 为什么我没有从 firestore 获得查询结果? - Why am I not getting query results from firestore? Elasticsearch _delete_by_query 哪里出错了? - Where am I going wrong with Elasticsearch _delete_by_query?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM