简体   繁体   中英

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. The code below works fine when I don't include a where statement, but gives the above error when I do. 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

 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. If you need to check something after the grouping, then you use HAVING after the GROUP BY .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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