Oracle 11g子查询中缺少表达式

时间:2018-06-16 21:49:40

标签: oracle oracle11g ora-00936

我试图在oracle 11g&中运行此代码得到这个错误消息

  

//第4行的错误ORA-00936:缺少表达式//错误是   ' J' @" FROM JOB j," //

以下是代码:

WITH sq AS (SELECT j.measurenumber, j.enterdate, trunc(c.passedoffdate) PassedOffDate, 
d.yearid, d.weekid, d.quarterid, c, estimatesqft, e.totalamount EstimateTotal, 
j.storenumber, c.quoteid, c.measurebitfield, c.soldstatus, 
FROM JOB j, JOB_CLOSE c, dash_reportweek d, estimate_measure em,
estimate e,
WHERE   measurenumber = c.measurenumber
                AND j.measurenumber = em.measurenumber
                AND em.estimateid = e.estimateid
                AND j.measurenumber = o.measurenumber(+)
                AND o.measurenumber IS NULL
                AND j.enterdate BETWEEN d.startdate AND d.enddate
                AND d.yearid = 2018 AND c.measurebitfield = 1
                AND d.quarterid = 2)
SELECT sq.MEASURENUMBER,
       SQ.ENTERDATE, 
       SQ.YEARID,
       SQ.WEEKID,
       SQ.QUARTERID,
       SQ.PASSEDOFFDATE,
       SQ.ESTIMATESQFT,
       SQ.ESTIMATETOTAL,
       SQ.STORENUMBER,
       SQ.QUOTEID,
       QUOTEDOLLARAMMOUNT,
       SQFT, 
       SQ.SOLDSTATUS
  FROM SQ,
       (  SELECT sq.measurenumber, SUM (unitprice) sqft
            FROM sq, quoteitementry qi
           WHERE sq.quoteid = qi.quoteid AND qi.quoteelementid = 25007
        GROUP BY sq.measurenumber) v1,
       (  SELECT sq.measurenumber,
                 SUM (qi.quantity * qi.UNITPRICE) QuoteDollarAmmount
            FROM sq, quoteitementry qi
           WHERE sq.quoteid = qi.quoteid AND qi.active = 'T'
        GROUP BY sq.measurenumber) v2
WHERE     sq.measurenumber = v2.measurenumber(+)
       AND sq.measurenumber = v1.measurenumber(+);

1 个答案:

答案 0 :(得分:1)

如果仔细查看代码,请在评论中突出显示...

 c.soldstatus, 
 FROM JOB j

...你会注意到你有一个逗号。查询投影中的最后一列后面是FROM而不是逗号。因为您有一个逗号,所以Oracle期望另一个列被命名。因此例外。