简体   繁体   English

BigQuery SQL 在子查询上给出奇怪的错误

[英]BigQuery SQL giving weird error on subquery

I've been trying to run a subquery in GCP BigQuery but it's giving an error.我一直在尝试在 GCP BigQuery 中运行子查询,但出现错误。 This is part of the Google Data Analytics course.这是 Google 数据分析课程的一部分。 The intent is to "compare the number of bikes available at the station with the average number of bikes available"目的是“将车站可用的自行车数量与可用自行车的平均数量进行比较”

The dataset is bigquery-public-data with 2 tables namely, citibike_stations and citibike_trips.数据集是 bigquery-public-data,有 2 个表,即 citibike_stations 和 citibike_trips。 The only table used is the citibike_stations.唯一使用的表格是 citibike_stations。

The following is my query and subquery:以下是我的查询和子查询:

SELECT station_id, num_bikes_available (SELECT AVG(num_bikes_available) FROM bigquery-public-data.new_york_citibike.citibike_stations) AS avg_num_bikes_available FROM bigquery-public-data.new_york_citibike.citibike_stations;

You are simply missing a comma.您只是缺少一个逗号。 See the comma highlighted on line 3. You are using the subquery as a column in the outer SELECT , so you simply need a comma separating all the output columns.请参阅第 3 行突出显示的逗号。您将子查询用作外部SELECT中的列,因此您只需要一个逗号分隔所有 output 列。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM