日期:2014-05-16 浏览次数:20478 次
id uid scroe
-------------
1 1 1.5
2 1 1.8
3 2 -5.5
4 1 0.8
5 2 8.2
6 1 -2
7 4 3
8 2 2.3
--------------
用户 分数 汇总分
-----------------------
1 1.5 2.1
1 1.8 2.1
1 0.8 2.1
1 -2 2.1
2 -5.5 5
2 8.2 5
2 2.3 5
3 0 0
4 3 3
5 0 0
select t.*,round(s.scroe,1) as scroe , round(if(s.total is null,0,s.total),1) as summary from
(select 1 as uid
union
select 2 as uid
union
select 3 as uid
union
select 4 as uid
union
select 5 as uid) t left join
(select uid,scroe,(select sum(scroe) from a where uid=aa.uid group by uid) as total from a as aa) s
on s.uid = t.uid