in reply to Re: Re: What's an Efficient Way to Retrieve a Rank from a MySQL Table?
in thread What's an Efficient Way to Retrieve a Rank from a MySQL Table?

Ranking student 'd' as second is very unrealistic. It would mean that if student 'a' (who is better than 'd') increases his score to 70.000001, student 'd' drops a rank. That would be counterintuitive. Or, if you are a sports fan, if these scores would be sports scores, 'd' would not get a silver medal.

Having said that, look into the 'group by' clause. What you want is determine the rank of the group the student falls in.

Abigail

  • Comment on Re: What's an Efficient Way to Retrieve a Rank from a MySQL Table?

Replies are listed 'Best First'.
Re: Re: What's an Efficient Way to Retrieve a Rank from a MySQL Table?
by soon_j (Scribe) on May 04, 2004 at 12:08 UTC

    You have a point. But in my application, it is necessary. I have to rank students in terms of the number of questions a student answered, ... in terms of the total duration of his exam, ... in terms of his average speed (in sec/question)

    Which means that if student "a" is 0.01 sec faster than the rest, then by all means I have to rank him higher that the rest. BTW, only two decimal places are being reported under some columns. Had it been several decimal places like the you pointed ... 70.000001.. I would definitely consider your suggestion.

    Thanks. By far, your suggestions are the most optimal.

      My point is that whether student "a" is 0.01 sec faster than student "b" or "c" should not effect student "d"'s ranking. Why would your ranking depend on the number of ties between the people who are better than you? "Daddy, daddy, I was second of my class! All other 29 students beat me!"

      Oh well, it's your application, not mine. ;-)

      Abigail

        I guess you are right. I recalled when I was in college when our organization won 1st place in a lantern-making contest... a good finish... but definetely not a glorious win because our lantern was the only entry.

        One thing that I could probably do, for example if I list the top 10 performing students in terms of the number of correct answers is:

        1. Student A - 230 ques
        2. Student B - 185 ques
        3. 3 Tied at 175 ques
        4. Student X - 175 ques
        ... And so forth

        I don't know if that would be better... I'll try to see later once I have the real data to crunch