首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误sql oracle "ORA-00936:表达式缺失“

错误sql oracle "ORA-00936:表达式缺失“
EN

Stack Overflow用户
提问于 2015-10-12 02:29:13
回答 2查看 802关注 0票数 0

我的SQL缺少什么?

代码语言:javascript
复制
select cl.nom_cl
from client cl
where (cl.id_client IN(select e.id_acheteur
    from enchere e 
    group by e.id_acheteur 
    having(  count(distinct e.idobj) = select count(distinct e2.idobj) from enchere e2 )))

ORA-00936:缺席的表达式:省略了子句或表达式的一个必需部分。

EN

回答 2

Stack Overflow用户

发布于 2015-10-12 02:36:32

我已将您的查询重构为:

代码语言:javascript
复制
  select cl.nom_cl
      from client cl
  where cl.id_client IN(select e.id_acheteur
  from enchere e 
  group by e.id_acheteur 
  having(  count(distinct (e.idobj)) IN (select count(distinct (e2.idobj)) from enchere e2) )  ) 

查询的select count(distinct (e2.idobj)) from enchere e2部分可能会检索多条记录,这也是您获得错误的原因。另外,这是count(distinct e.idobj)错了。应该是这样的:count(distinct (e.idobj))

票数 0
EN

Stack Overflow用户

发布于 2015-10-12 02:41:54

真正的问题是:

代码语言:javascript
复制
  select cl.nom_cl
    from client cl
    where (cl.id_client IN(select e.id_acheteur
                from enchere e 
                group by e.id_acheteur 
                having(  count(distinct e.idobj) = (select count(distinct e2.idobj) from enchere e2 ))  ) )
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33072395

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档