|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
finding someone's "rank" in a database
Hi all,
Lets say that I have a table of people with their Name and Salary. How would I query a person and find out his/her rank in terms of their salary?? for example, ----------------------------- |Name | Salary | ----------------------------- | John | $20,000 | | Alex | $5,000 | | Norm | $15,000 | ----------------------------- So if I query for "Alex", MySQL would return "3" since Alex is ranked 3rd in terms of his salary. Can this be done in MySQL?? I'm assuming that I'll first have to order the table by salary, but then what do I do after that??? thanks, -Phil |
|
#2
|
||||
|
||||
|
See this and the links within it -> http://forums.devshed.com/showthrea...&threadid=38524
Though it's probably better/easier to do it in a scripting language. //NoXcuz
__________________
UN*X is sexy! who | grep -i blonde | date; cd ~; unzip; touch; strip; finger; mount; gasp; yes; uptime; umount; sleep |
|
#3
|
|||
|
|||
|
How are you retrieving the data? If you're using PERL, I can show you exactly what to do... without having to change your table format.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > finding someone's "rank" in a database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|