Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by Ryszard (Priest)
on May 04, 2004 at 08:48 UTC ( #350261=note: print w/replies, xml ) Need Help??


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

If the rank of a student is relative to the population you cant determine the rank on the fly without looking at the population.

My idea would be to run a job periodically that would do that for you, compute the value and store it statically in a table.

Alternatively you could write an internal function that did that for you eg: select rank(student) from students.. and the rank function would be something you write yourself. not sure if MySQL supports custom functions in perl, (and i'm too lazy to look it up) but postgres sure does.. (not that i'm suggesting you switch RBDMS's) :-).

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

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 08:55 UTC
    I believe you are right. The rank is highly dependent on the entire population. Since students are taking exams online at indefinite times, their performances vary at a non-predictable manner. To determine a specific rank, I need to take a snapshot from the entire table.

    Previously, I thought of having another table that only holds information such as the rank of the student. The problem with this idea is that everytime a student improves in rank (like from 9th place moving up to 5th place), I need to update the ranks of all entries respectively.

    Thanks for the comments

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350261]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2021-04-14 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?