ORA-00907:缺少右括号

时间:2011-11-03 02:02:23

标签: sql oracle ora-00907

我收到错误“ORA-00907:错过右括号” 但我已经检查了所有的括号都在那里,所以我很难过。

我的查询是

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 

我绝不是Oracle专家,但我必须使用它,因为它必须是托管环境。

1 个答案:

答案 0 :(得分:0)

Oracle中无法识别LIMIT命令。并且应该使用 ROWNUM 而不是限制

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