无法让查询工作

时间:2013-04-26 19:35:32

标签: sql oracle

尝试看看哪个球员获得了最多的进球。

Player_id
Goals.

我尝试了以下声明:

select player_id, sum(goals) as total
from matchstat
group by player_id
order by total desc limit 1;

但我得到错误:

  

SQL命令未正确结束。

有没有人看到查询的问题?

1 个答案:

答案 0 :(得分:2)

Oracle不支持限制条款。尝试

SELECT * 
FROM   (SELECT "player_id", 
               SUM("goals") AS total 
        FROM   matchstat 
        GROUP  BY "player_id" 
        ORDER  BY total DESC) a 
WHERE  ROWNUM <= 1 

See a demo