我目前正在尝试在google BigQuery上创建一个视图,但我不断收到错误:
无法保存视图。 JOIN中的歧义字段名称“别名”。请在字段名称前使用表限定符。
我正在尝试创建一个视图,其中用户可以为每个player_id查看计算的month_difference的每个指定值的total_deposit_amount的总和。
我在内联视图中加入了3个表,我可以正常运行查询但是我收到了错误,有什么理由为什么以及如何解决这个问题?
select
player_id,
round(sum(if(month_difference_M = 1, converted_deposit_amount, 0)),2) as M1_real_deposit_gbp,
round(sum(if(month_difference_M = 2, converted_deposit_amount, 0)),2) as M2_real_deposit_gbp,
round(sum(if(month_difference_M = 3, converted_deposit_amount, 0)),2) as M3_real_deposit_gbp,
round(sum(if(month_difference_M > 2, converted_deposit_amount, 0)),2) as M2_plus_deposit_gbp
FROM
(
select
pl.player_id as player_id,
(12 * YEAR(pf.date) + MONTH(pf.date)) - (12 * YEAR(pl.ftd_date) + MONTH(pl.ftd_date)) + IF (DAY(pf.date) >= DAY(pl.ftd_date), 0, -1) + 1 as month_difference_M,
(case
when pf.currency = 'CAD' then pf.deposit_real_funds_amount*er.cad
when pf.currency = 'NZD' then pf.deposit_real_funds_amount*er.nzd
when pf.currency = 'EUR' then pf.deposit_real_funds_amount*er.eur
when pf.currency = 'AUD' then pf.deposit_real_funds_amount*er.aud
when pf.currency = 'NOK' then pf.deposit_real_funds_amount*er.nok
when pf.currency = 'SEK' then pf.deposit_real_funds_amount*er.sek
when pf.currency = 'USD' then pf.deposit_real_funds_amount*er.usd
else pf.deposit_real_funds_amount
end) as converted_deposit_amount
from [enigma-1180:Tableau.PlayerFinancials] pf
join [enigma-1180:Tableau.PlayerLookup] pl
on pl.player_id = pf.player_id
join [enigma-1180:Tableau.ExchangeRates] er
on er.date = pf.date
) src
group by player_id