ORA-00907: missing right parenthesis

2.7k Views Asked by At

I'm getting the error " ORA-00907: missing right parenthesis" but I've checked and all the parenthesis are there, so I'm stumped.

My query is

SELECT 
  SUM(score) as score, 
  facebook_id, 
  firstname, 
  lastname, 
  dense_rank(score) 
WITHIN GROUP ( ORDER BY score ) as rank_db  
FROM 
  (
    SELECT DISTINCT *
    FROM 
      (
        SELECT *  
        FROM fanta_score 
        ORDER BY score desc
      ) as f 
    GROUP BY 
      facebook_id, game_id
  ) as g 
GROUP BY facebook_id
ORDER BY score DESC, created_at
LIMIT 50 

I'm by no means an Oracle expert, but I have to use it due the hosting environment its has to be in.

1

There are 1 best solutions below

9
On

LIMIT command isn't recognized in Oracle. And should use ROWNUM instead of Limit.

SELECT 
  SUM(score) as score, 
  facebook_id, 
  firstname, 
  lastname, 
  dense_rank(score) 
WITHIN GROUP ( ORDER BY score ) as rank_db  
FROM 
  (
    SELECT DISTINCT *
    FROM 
      (
        SELECT *  
        FROM fanta_score 
        ORDER BY score desc
      ) as f 
    GROUP BY 
      facebook_id, game_id
  ) as g
WHERE ROWNUM = 50 
GROUP BY facebook_id
ORDER BY score DESC, created_at