Home > Back-end >  ORA-00907: missing right parenthesis - only comes up when I add a where statement (
ORA-00907: missing right parenthesis - only comes up when I add a where statement (

Time:11-18

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
)               

CodePudding user response:

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.

  • Related