Oracle 11g 子查询中缺少表达式
Posted
技术标签:
【中文标题】Oracle 11g 子查询中缺少表达式【英文标题】:Missing Expression in Oracle 11g subquery 【发布时间】:2018-06-16 21:49:40 【问题描述】:我正在尝试在 oracle 11g 中运行此代码并收到此错误消息
// 第 4 行出错 ORA-00936: missing expression // 错误是 'j' @ "来自工作 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】:如果您仔细查看您的代码,请在评论中突出显示的那一点...
c.soldstatus,
FROM JOB j
...你会注意到你有一个尾随逗号。查询投影中的最后一列后跟 FROM 而不是逗号。因为你有一个逗号 Oracle 期望另一个列被命名。因此例外。
【讨论】:
公用表表达式SQ
中的 ...estimate e, WHERE...
存在相同问题。祝你好运。
嗨,谢谢 - 是的,我在发布后不久就看到了多余的逗号并取出了。我非常希望能解决这个问题,但它没有......现在我得到:ORA-00911:sub qry select 的第 2 行上的无效字符:“ WITH sq AS (SELECT j.measurenumber, j. enterdate, "
以上是关于Oracle 11g 子查询中缺少表达式的主要内容,如果未能解决你的问题,请参考以下文章
ORA-00936: Oracle 11g 中的 DELETE 语句和视图缺少表达式