如何避免 Interbase 错误 'Column Unknown'
How to avoid Interbase error 'Column Unknown'
InterBase 2020 数据库中有 2 个 table:t1 和 t2。
t1 fields: i1 integer,
f1 float
t2 fields: i2 integer,
f2 float
Derived table (dt1) 在 IB 和 FB 上正常工作,但是这个完整代码 returns 一个错误 仅在 IB 服务器上:
'Column Unknown 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
如何避免这个错误?
您的外部查询只知道派生的 table 列名称。因此,在“dt1”的派生 table 定义期间限定您的列名; "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;
InterBase 2020 数据库中有 2 个 table:t1 和 t2。
t1 fields: i1 integer,
f1 float
t2 fields: i2 integer,
f2 float
Derived table (dt1) 在 IB 和 FB 上正常工作,但是这个完整代码 returns 一个错误 仅在 IB 服务器上:
'Column Unknown 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
如何避免这个错误?
您的外部查询只知道派生的 table 列名称。因此,在“dt1”的派生 table 定义期间限定您的列名; "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;