get the SUM of each Person by the PersonID

北城以北 提交于 2019-12-02 03:57:30

You need a GROUP BY and an aggregate function like count or sum

SELECT SCORE_PERSON_ID, sum(SCORE_VOTE) as score
FROM table 
GROUP BY `SCORE_PERSON_ID`
SELECT SUM(SCORE_VOTE)
FROM SCORES
GROUP BY SCORE_PERSON_ID

how about

select sum(SCORE_VOTE) as score  from TABLE group by SCORE_PERSON_ID 

this is sum them up for each person

select sum(SCORE_VOTE)  as score  from TABLE where SCORE_PERSON_ID = 1

I think either this is what you're asking for:

SELECT SUM(SCORE_VOTE)
  FROM <your_table_name>
 WHERE SCORE_PERSON_ID = <some value>

or this:

SELECT SUM(SCORE_VOTE)
  FROM <your_table_name>
 GROUP BY SCORE_PERSON_ID

Hope that helps. Good luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!