【发布时间】:2021-06-17 23:35:12
【问题描述】:
尝试在 BigQuery 中进行简单联接。几年没有使用它(生锈),所以可能只是我的语法中的一个小错误。它是标准 SQL。
SELECT
fiscal_week_of_year,
sum(quantity) as units_ordered,
round(sum(item_price),2) as total_item_price,
FROM `order_table`
where brand = "XYZ"
and currency = 'USD'
and sales_channel = 'FakeChannel.com'
and date(purchased_at_PST) between '2021-01-03' and '2021-01-09'
join
on date(order_table.purchased_at_PST) = date_table.date_formatted
;
我得到的错误是:语法错误:预期输入结束,但在 [15:] 处得到关键字 JOIN
purchased_at_PST 是 DATETIME,而 date_formatted 是 DATE 字段
【问题讨论】:
-
1.你有
join,但没有指定要加入的表; 2.where子句应该移到from ... join ... on ...之后 3. 在任何情况下,您的查询都没有多大意义,所以我建议您使用案例的详细信息、输入数据、预期输出、逻辑等来更新您的问题。 -
我的错误,我想通了。我需要按照你说的做,然后正确命名我没有做的表。
-
选择财务周数,总和(数量)作为单位排序,回合(总和(项目价格),2)作为总项目价格,从
order_table加入date_table日期(order_table.purchased_at_PST)=@987654328 @.date_formatted where brand = "XYZ" and currency = 'USD' and sales_channel = 'FakeChannel.com' and date(purchased_at_PST) between '2021-01-03' and '2021-01-09' group by 1 order by 1 ; -
在我进行了所示的修复后它工作了。
标签: google-bigquery