sql可以使用group by分组,如select sum(score),pid from table group by pid
select sum(score) from table where pid=子集