【发布时间】:2017-12-15 20:46:55
【问题描述】:
我有一个简单的查询来获取创建交易时使用的货币汇率:
SELECT t.orderid, t.date,
(SELECT rate FROM sources.currency_rates r WHERE currencyid=1 AND
r.date>=t.date ORDER BY date LIMIT 1) rate
FROM sources.transactions t
这会触发错误:
Error: Correlated subqueries that reference other tables are not
supported unless they can be de-correlated, such as by transforming
them into an efficient JOIN.'
我尝试了几种类型的连接和命名子查询,但似乎都没有。实现这一目标的最佳方法是什么?似乎是一个非常常见的场景,应该很容易在 BQ 的标准 Sql 中实现。
【问题讨论】:
标签: google-bigquery