2011-10-11 20 views
1

なぜSQLベローが機能しないのですか?select文でフィールドに無効な識別子エラーが発生しました

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":無効な識別子

答えて

1

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 
それを包むしよう
関連する問題