发布后的解决方案
此过程列出给定game_id的分数.如果省略参数,所有游戏将被总结:
create or replace procedure player_scores(i_game_id number default null) as
begin
for o in (select person_id, name, sum(score) score
from games where game_id = nvl(i_game_id, game_id)
group by person_id, name)
loop
dbms_output.put_line(o.person_id||' '||o.name||' '||o.score);
end loop;
end player_scores;
以前的方案:
你不需要那个程序,只需要简单的查询:
select person_id, name, sum(score)
from your_table
where game_id in (1, 2)
group by person_id, name