【问题标题】:Missing right parenthesis in Oracle queryOracle 查询中缺少右括号
【发布时间】:2013-06-12 16:19:01
【问题描述】:

对于 S9 商店,我正在尝试查找为其发布最多评论数的用户的朋友。

我有以下疑问:

select friend_id 
  from friends 
 where user_id = ( select author_id 
                     from posted_reviews_tab   
                    where rownum <= 1 
                      and reviewid in ( select w.reviews.reviewid 
                                          from wall_tab w  
                                         where w.shopid = 'S9' ) 
                    group by author_id 
                    order by count(author_id) desc );

我收到以下错误:

SQL 错误:ORA-00907:缺少右括号 00907. 00000 - “缺少右括号”

【问题讨论】:

  • 我在您的查询中添加了空格,它使(对我而言)更容易阅读,并且更容易向您显示可能存在问题的地方。带有 rownum 谓词的 GROUP BY、ORDER BY 几乎肯定不会返回您认为的内容。
  • 可以分享一下表结构吗?这将有助于更快地构建查询。

标签: sql oracle


【解决方案1】:

选择中有错字:

select friend_id 
  from friends 
 where user_id = ( select author_id 
                     from posted_reviews_tab   
                    where rownum <= 1 
                                        --w.reviews.reviewid is wrong
                      and reviewid in ( select w.reviews.reviewid 
                                          from wall_tab w  
                                         where w.shopid = 'S9' ) 
                    group by author_id 
                    order by count(author_id) desc );

如果这不是拼写错误,您必须输入 join 才能到达“.reviews”,因为该语法是不可能的。

【讨论】:

  • 好的..所以我需要使用连接..我对此很陌生!
猜你喜欢
  • 1970-01-01
  • 2021-11-10
  • 2019-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多