vearns Posted January 8, 2009 Share Posted January 8, 2009 Hello, i need help for ranking order. currently i used this SQL statement to generate a descending result : SELECT name, COUNT( customerid ) AS orderCount FROM contest GROUP BY name ORDER BY orderCount DESC Let say the descending result is : John 5 Tom 4 Mark 3 Jane 2 Vivian 1 i want to output : Mark is on the 3rd out of 5th. how to do it in MySQL and PHP ? Quote Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/ Share on other sites More sharing options...
vearns Posted January 8, 2009 Author Share Posted January 8, 2009 let say the descending result is : John 64735 Tom 5774 Mark 3533 Jane 211 Vivian 12 how to make mysql know that Mark is the 3rd highest and Tom is the second highest ? is there any other way to solve this ? Quote Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732402 Share on other sites More sharing options...
abdfahim Posted January 8, 2009 Share Posted January 8, 2009 You mean you need to return the result of the 3rd highest scorer? then SELECT name, COUNT( customerid ) AS orderCount FROM contest GROUP BY name ORDER BY orderCount DESC LIMIT 2,2 Quote Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732447 Share on other sites More sharing options...
fenway Posted January 8, 2009 Share Posted January 8, 2009 Since you're outputting all the results anyway, use a php counter. Quote Link to comment https://forums.phpfreaks.com/topic/139995-need-help-for-ranking-order/#findComment-732511 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.