简体   繁体   English

ORA-00907: 缺少右括号 - 只有当我添加 where 语句 (

[英]ORA-00907: missing right parenthesis - only comes up when I add a where statement (

I am using a string to access a code that will then access an ORACLE data, I use this code a lot, but for some reason it is not working now.我正在使用一个字符串来访问一个代码,然后该代码将访问一个 ORACLE 数据,我经常使用这个代码,但由于某种原因它现在不起作用。 The code below works fine when I don't include a where statement, but gives the above error when I do.当我不包含 where 语句时,下面的代码可以正常工作,但是当我这样做时会出现上述错误。 I have looked at other examples of this error, but can not find any that match what I am doing.我查看了此错误的其他示例,但找不到任何与我正在做的事情相匹配的示例。 Any help would be appreciated.任何帮助,将不胜感激。 Start year is the number 2010起始年份是数字 2010

 select * from(
    select  
        count(distinct(fileid)) as cyic,
        to_number(substr(cym, 1, 4)) as cym,
    from group.data
    group by fileid, cym
    where to_number(substr(cym, 1, 4)) >= :start_yr
)               

The problem is that the WHERE clause must come before the GROUP BY clause.问题是WHERE子句必须在GROUP BY子句之前。 If you need to check something after the grouping, then you use HAVING after the GROUP BY .如果您需要在分组后检查某些内容,则在GROUP BY之后使用HAVING

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM