Need help using RANK in Excel (or MySql) for mulitple people, points scored
I have a data set:
Player Year Points
John 2010 60
Jane 2010 83
Stan 2010 42
Brian 2010 51
Phil 2010 65
John 2009 1
Jane 2009 44
Stan 2009 89
Brian 2009 4
Phil 2009 82
John 2008 93
Jane 2008 12
Stan 开发者_开发技巧 2008 31
Brian 2008 41
Phil 2008 63
John 2007 47
Jane 2007 73
Stan 2007 72
Brian 2007 17
Phil 2007 81
I am looking to get the points and years ranked by PERSON, not overall. In other words:
Player Year Points Personal Rank
John 2010 60 2
Jane 2010 83 1
Stan 2010 42 3
Brian 2010 51 1
Phil 2010 65 3
John 2009 1 4
Jane 2009 44 3
Stan 2009 89 1
Brian 2009 4 4
Phil 2009 82 1
John 2008 93 1
Jane 2008 12 4
Stan 2008 31 4
Brian 2008 41 2
Phil 2008 63 4
John 2007 47 3
Jane 2007 73 2
Stan 2007 72 2
Brian 2007 17 3
Phil 2007 81 2
Is this possible to do in Excel?
I also have this data in MySql if anyone knows (or can point me in the right direction) a SELECT for it.
Thanks in advance.
set @player = '',@num=0;
select id,player,year,points,rank from
(select *,
@num := if(@player = player, @num + 1, 1) as rank,
@player := player as p
from results order by player,points desc) as t
order by id
In mysql you could also use something like this:
SET @rank=0;
SELECT @rank:=@rank+1 AS rank, person, year, points FROM yourtable ORDER BY id person;
精彩评论