MySQL中的特定行的总和

时间:2017-01-22 02:23:00

标签: mysql sum row

我有一张这样的表:

id | player | points
----------------------
1  | A      | 2500
2  | B      | 3800
3  | C      | 1500

我想总结(例如)球员A和C的分数。我该怎么做?

2 个答案:

答案 0 :(得分:2)

您考虑过$( document.body ).on( 'click', '.append', function( event ) { $("#append").append("<li><a href=\"#\">Item 1</a></li>"); return false; }); 吗?

where

答案 1 :(得分:0)

也许你想要将A和C加在一起,并将其余部分分开,如下所示:

select
    case when player in ('A','C') then 'A or C'
    else player end player,
    sum(points)
from t
group by
    case when player in ('A','C') then 'A or C'
    else player end;