MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 19th, 2002, 03:17 PM
DimSum DimSum is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: california
Posts: 5 DimSum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old August 19th, 2002, 04:00 PM
NoXcuz's Avatar
NoXcuz NoXcuz is offline
Wiking
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Sep 2000
Location: Sweden
Posts: 3,608 NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level)NoXcuz User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 7 h 49 m 27 sec
Reputation Power: 21
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

Reply With Quote
  #3  
Old August 20th, 2002, 10:32 PM
SpongeWorthyII SpongeWorthyII is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 28 SpongeWorthyII User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > finding someone's "rank" in a database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT