SQL语法错误-CONCAT,控制台-BigQuery [关闭]
Posted
技术标签:
【中文标题】SQL语法错误-CONCAT,控制台-BigQuery [关闭]【英文标题】:SQL syntax error -CONCAT ,Console-BigQuery [closed] 【发布时间】:2021-11-09 19:47:51 【问题描述】:此代码在CONCAT
处显示错误。我是这个领域的新手,我自己学习。如果有人能解决我的问题并分享这个问题的原因,我会很高兴。
SELECT
Warehouse.warehouse_id
CONCAT(Warehouse.state,' :',Warehouse.warehouse_alias) AS warehouse_name,
COUNT(Orders.order_id) AS number_of_orders
(SELECT COUNT(*)
FROM warehouse_orders.Orders Orders) AS total_orders,
CASE
WHEN COUNT(Ordes.order_id) / (SELECT COUNT(*) FROM warehouse_orders.Orders Orders) <= 0.20
THEN "fulfilled 0-20% of Orders"
WHEN COUNT(Ordes.order_id) / (SELECT COUNT(*) FROM warehouse_orders.Orders Orders) > 0.20
AND COUNT(Ordes.order_id) / (SELECT COUNT(*) FROM warehouse_orders.Orders Orders) <= 0.60
THEN "fulfilled 21-60% of Orders"
ELSE "fulfilled more than 60% of Orders"
END AS fulfillment_summary
FROM
warehouse_orders.Orders Warehouse
LEFT JOIN
warehouse_orders.Orders Orders ON Orders.warehouse_id = Warehouse.warehouse_id
GROUP BY
Warehouse.warehouse_id, warehouse_name
HAVING
COUNT(Orders.order_id) > 0
【问题讨论】:
轻松帮您,去掉不相关的部分。 【参考方案1】:可能是因为您缺少逗号。
select
Warehouse.warehouse_id,
CONCAT(Warehouse.state,' :',Warehouse.warehouse_alias) AS warehouse_name,
COUNT(Orders.order_id) AS number_of_orders,
【讨论】:
它仍然显示错误。下一步该怎么做? 使用更新的数据打开一个新问题,或编辑此问题,因为此问题已关闭,您必须对其进行编辑才能重新打开它。 错误是什么?【参考方案2】:我认为您在warehouse_id 之后缺少逗号。假设 CONCAT 中的错误是因为缺少逗号。
--Warehouse.warehouse_id,
【讨论】:
以上是关于SQL语法错误-CONCAT,控制台-BigQuery [关闭]的主要内容,如果未能解决你的问题,请参考以下文章