mysql语句当天个人按成绩排名,要查询快,不消耗太多资源的。

ID UID NAME S O TIME
1 1001 p1 12 22 2015-1-21
2 1002 p2 13 32 2015-1-21
3 1001 p1 13 12 2015-1-22
4 1002 p2 11 32 2015-1-22
5 1001 p1 19 12 2015-1-23
6 1002 p2 11 13 2015-1-23
........................................................................................
想要的结果是:P1在今天的排名是几名,按S+O的成绩排名。因为是很多人查询的,所以每次都耗时很久。有简便快捷的语句吗?

select @rownum:=@rownum+1 AS rownum,p.* from
(
select uid,time,sum(s)+sum(o) from person_result where time='写今天的日期'
group by uid,time
) p,(SELECT @rownum:=0) r
order by time

select 你要查询的数据 from 表 where 成绩 by 你需要的排序方式

查询的时候劲量不要避免*

为什么不添加一个字段标示S+O的和

select count(1) from score where time=curdate()
and (s+O)> (select s+o from score where time=curdate() and uid=1001 );