0

Try to see which player scored the most goals.

Player_id
Goals.

I tried the following statement:

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

But i get the error:

SQL command not properly ended.

Does anyone see the problem with the query?

Kermit
  • 33,827
  • 13
  • 85
  • 121

1 Answers1

2

Oracle doesn't support the limit clause. Try

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

Kermit
  • 33,827
  • 13
  • 85
  • 121