Google bigquery BigQuery:派生字段的名称无法识别

Google bigquery BigQuery:派生字段的名称无法识别,google-bigquery,Google Bigquery,我有两张桌子1和2。在表1中,我创建了一个派生字段“actualoutput”,我正在对其使用带有“newgroup”的表2连接作为连接器,以获取字段“finalgroup”,如下所示 因为派生字段不能在同一个select中使用,所以我使用了foll。使用外部查询中的派生字段进行查询。但这是一个错误: 无法识别的名称:actualoutput 查询: select source, detail, CONCAT(IFNULL(source, ''), "-", IFNULL(detail, '')

我有两张桌子1和2。在表1中,我创建了一个派生字段“actualoutput”,我正在对其使用带有“newgroup”的表2连接作为连接器,以获取字段“finalgroup”,如下所示

因为派生字段不能在同一个select中使用,所以我使用了foll。使用外部查询中的派生字段进行查询。但这是一个错误:

无法识别的名称:actualoutput

查询:

select source, detail, CONCAT(IFNULL(source, ''), "-", IFNULL(detail, '')) AS actualoutput, newgroup, finalgroup 
from (
SELECT source, detail from `table1`)
left join (select newgroup,finalgroup from `table2`)
on actualoutput=newgroup
参考图片:以黄色突出显示的列用作键


谁能帮我解决这个问题。

我得到了答案。基本上,我使用了错误的查询,在同一outerquery中使用了表2列以及派生字段“actualoutput”。福勒。查询按预期提供输出:

select source, detail, CONCAT(IFNULL(Source, ''), "-", IFNULL(Detail, '')) AS actualoutput, newgroup,finalgroup
from (
select source, detail, CONCAT(IFNULL(Source, ''), "-", IFNULL(Detail, '')) AS actualoutput
from (
SELECT source, detail from `table1`))
left join (select newgroup,finalgroup from `table2`)
on actualoutput=newgroup

通过此查询,您还可以选择图像中“最终表格”中不存在的
newgroup
列(与“actualoutput”列相同)。一个更简单的版本可以是:选择source、detail、actualoutput、finalgroup from(选择source、detail、CONCAT(IFNULL(source)、“-”、IFNULL(detail)”)作为
mydataset的actualoutput。表1
)左连接
mydataset。表2
关于actualoutput=newgroup;