0

视图如下所示:

Create or Replace view MyView( Col1, Col2, Col3) as 
select count(OuterQ.Name), OuterQ.Year, Outer.Date 
      (select InnerQ.Name, InnerQ.Year, X.Date, 
         From X
            , ( select p.Id, p.Name, t.year from p,t where p.id = t.id) InnerQ 
        where X.field = 'YYY' 
          and X.value = t.value) OuterQ 
group by OuterQ.Date, OuterQ.Year 

例如,当我需要视图中的一个特定列值时,select Col1 from MyView;我收到错误"904 invalid identifier"

但是当我运行时select * from MyView,查询运行良好。

4

1 回答 1

0

您有语法错误:

-- first off , remove ( Col1, Col2, Col3) 
Create or Replace view MyView( Col1, Col2, Col3) as

select count(OuterQ.Name), OuterQ.Year, Outer.Date

-- you should have FROM clause here or   
(select InnerQ.Name, InnerQ.Year, X.Date,

From X, (select p.Id, p.Name, t.year from p,t where p.id = t.id) InnerQ

where X.field = 'YYY' and X.value = t.value) OuterQ

 -- FROM Clause here of outer query    
group by OuterQ.Date, OuterQ.Year 
于 2012-12-18T21:34:00.240 回答