本文介绍了使用select语句创建的字段上的标识符错误无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么SQL波纹管不起作用?

Why sql bellow don't work?

select
    a.field1, a.field2, a.field3,
    (select count(*)
        from table2 b
        where b.field1 = a.field1
    ) as field4,
    (select count(*)
        from table3 b
        where b.field1 = a.field1
    ) as field5,
    (select count(*)
        from table4 b
        where b.field1 = a.field1
    ) as field6,
from table1 a
order by field4

Oracle说:ORA-00904:"field4":无效的标识符

Oracle says: ORA-00904: "field4": invalid identifier

推荐答案

尝试将其包装

select * from
(
select
    a.field1, a.field2, a.field3,
    (select count(*)
        from table2 b
        where b.field1 = a.field1
    ) as field4,
    (select count(*)
        from table3 b
        where b.field1 = a.field1
    ) as field5,
    (select count(*)
        from table4 b
        where b.field1 = a.field1
    ) as field6,
from table1 a
)
order by field4

这篇关于使用select语句创建的字段上的标识符错误无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 11:43