0
我正在編寫一個查詢來比較今年提交的年份,我在BigQuery中使用此命令string((year(current_date())))
。
我得到的錯誤" ON clause must be AND of = comparisons of one field name from each table, with all field names prefixed with table name. ."
行(d.month) = String(Month((order.order_timestamp)))
因爲它沒有比較表中的列,而只是使用時間戳的月份。有沒有解決辦法?BigQuery中standardql模式下的年份函數
#standardSQL
SELECT
INTEGER(SUM(order2.demand_amount_usd)),
order2.quarter_name,
order2.year
FROM (
SELECT
order1.demand_amount_usd,
order1.order_timestamp,
d1.quarter_name,
d1.year
FROM
[datamart.order_item_lifecycle] AS order1
INNER JOIN EACH [datamart.date_dim] AS d
ON
(d.month) = STRING(MONTH((order.order_timestamp)))) AS order2
INNER JOIN EACH [datamart.date_dim] AS d2
ON
d2.year = INTEGER(YEAR(order2.order_timestamp))
WHERE
order2.year = STRING(YEAR(CURRENT_DATE()))
GROUP BY
order2.year,
order2.quarter_name;