我有一个如何在 Oracle 中执行此操作?
select a.field1 || '_' ||
b.field2 || '_' ||
sum(c.field3)
from table1 a,
table2 b,
table3 c
where a.field1 || '_' ||
b.field2 || '_' ||
sum(c.field3) not in (select d.field1 || '_' ||
e.field2 || '_' ||
sum(f.field3)
from table4 d,
table5 e,
table6 f
where conditional_info_to_join_the_tables
group by d.field1, e.field2)
and conditional_info_to_join_the_tables
group by a.field1, b.field2
我得到的错误是我不能在 where 子句中使用 sum
我试过使用
select a.field1 || '_' ||
b.field2 || '_' ||
sum(c.field3),
sum(c.field2) foo
from table1 a,
table2 b,
table3 c
where a.field1 || '_' ||
b.field2 || '_' ||
foo not in (select d.field1 || '_' ||
e.field2 || '_' ||
sum(f.field3)
from table4 d,
table5 e,
table6 f
where conditional_info_to_join_the_tables
group by d.field1, e.field2)
and conditional_info_to_join_the_tables
group by a.field1, b.field2
但是那个 foo 不是一个已识别的变量。