简体   繁体   English

使用 with 子句时出错我收到消息“语法错误:预期的关键字 AS 但在 [7:14] 得到了“(”

[英]Error using the with clause I received message " Syntax error: Expected keyword AS but got "(" at [7:14]"

I am having an issue locating the error in my code我在查找代码中的错误时遇到问题

I am practicing the WITH CLAUSE IN Big Query and I am trying to create two temporary tables to eventually join我正在练习 WITH CLAUSE IN Big Query 并且我正在尝试创建两个临时表以最终加入

  1. first table would for the sum total sales from all the stores (grouping by storeid)第一张表是所有商店的总销售额(按 storeid 分组)
  2. second table would be to get the average of those sum total stores第二张表是获取这些总商店的平均值
  3. the main query would be to find which stores are greater than the average sum total store主要查询是查找哪些商店大于商店的平均总和

here is what I was able to code:这是我能够编写的代码:

WITH Total_sales as 
    (SELECT s.storeid,
            sum(Unitprice)as sum_sale 
            FROM `g-mail-1234.SALES.sales_info` as s
            GROUP BY storeid),

    AVG_Sale (average_s_sales) as
    (SELECT ROUND(avg(sum_sale),2) as average_s_sales 
      FROM total_sales)

    SELECT * FROM total_sales as ts
    JOIN avg_sale as av
    ON ts.sum_sale > av.average_s_sale

but when I run the code I get a message: Syntax error: Expected keyword AS but got "(" at [7:14]但是当我运行代码时,我收到一条消息:语法错误:预期的关键字 AS 但在 [7:14] 处得到“(”

what I would like to know is:我想知道的是:

  1. Where is the error?错误在哪里?
  2. In the future in BigQuery the 'at [7:14]' is this trying to tell me the line the error code is on?将来在 BigQuery 中,“at [7:14]”是否试图告诉我错误代码所在的行? because it is on neither line 7 or line 14因为它既不在第 7 行也不在第 14 行

I don't believe BQ CTE syntax allows you to list the columns that the CTE will return.我不相信 BQ CTE 语法允许您列出 CTE 将返回的列。 So this line:所以这一行:

    AVG_Sale (average_s_sales) as

should just be:应该只是:

    AVG_Sale as

暂无
暂无

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

相关问题 语法错误:应为“(”或“,”或关键字 SELECT 但脚本结束 - Syntax error: Expected "(" or "," or keyword SELECT but got end of script 新的 Xcode 14 beta 我收到了这个错误:QOS_CLASS_USER_INITIATED waiting on a lower QoS thread running at QOS_CLASS_DEFAULT - New Xcode 14 beta I got this error: QOS_CLASS_USER_INITIATED waiting on a lower QoS thread running at QOS_CLASS_DEFAULT 切换到 Xcode 14 beta 后,我收到此错误:QOS_CLASS_USER_INITIATED 正在等待以 QOS_CLASS_DEFAULT 运行的较低 QoS 线程 - After switching to Xcode 14 beta I got this error: QOS_CLASS_USER_INITIATED waiting on a lower QoS thread running at QOS_CLASS_DEFAULT Gitlab CI 出现错误 selenium.common.exceptions.WebDriverException:消息:当我运行我的简单 pro 时,'chromedriver' 可执行文件需要在 PATH 中 - Gitlab CI got error selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH when I running my simple pro pandas.to_gbq() 返回“ArrowTypeError: Expected bytes, got a 'datetime.date' object”错误 - pandas.to_gbq() returning "ArrowTypeError: Expected bytes, got a 'datetime.date' object" error 使用 flutter 在实时数据库中显示相关下拉列表中的数据时出现错误 - I got an error while displaying data in dependent drop down in real time database using flutter 将 JSON 数据插入 BigQuery 错误:读取数据时出错,错误消息:JSON 从 position 0 开始的行中解析错误 - Insert JSON Data into BigQuery ERROR: Error while reading data, error message: JSON parsing error in row starting at position 0: Expected key 使用 StreamBuilder 和 bool 实时更新 UI -ERROR 预期类型为“地图”的值<dynamic, dynamic> ',但得到了“_JsonDocumentSnapshot”类型之一</dynamic,> - Realtime Update of UI with StreamBuilder and bool -ERROR Expected a value of type 'Map<dynamic, dynamic>', but got one of type '_JsonDocumentSnapshot' client.get_bucket() 返回错误:api_request() 得到了一个意外的关键字参数“extra_api_info” - client.get_bucket() returns error: api_request() got an unexpected keyword argument 'extra_api_info' 我想使用 flutter 中的未来构建器在下拉按钮中显示来自云 Firestore 的文档 ID,但出现错误 - I want to Display document ids from cloud firestore in drop down button using future builder in flutter but got error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM