如何避免基间错误'Column Unknown'



InterBase 2020数据库中有两个表:t1和t2。

t1 fields: i1 integer,
f1 float
t2 fields: i2 integer,
f2 float 

派生表(dt1(在IB和FB上正常工作,但此完整代码仅在IB服务器上返回错误:

"未知F1列">

select
i1 as i3,
sum(f1) as f3

From
(select
i1,
sum(f1) as f1
from t1
group by i1

union all

select
i2,
sum(f2) as f2
from t2
group by i2) dt1
group by i1

如何避免这个错误?

外部查询只有派生表列名的专有技术。因此,在"的派生表定义期间限定列名;dt1";,因此"dt1(i1,f1(";。

select
i1 as i3,
sum(f1) as f3

From
(select
i1,
sum(f1) as f1
from t1
group by i1

union all

select
i2,
sum(f2) as f2
from t2
group by i2) dt1 (i1, f1)
group by i1;

最新更新