Results 1 to 2 of 2

Thread: Ranking query help

  1. #1
    Join Date
    May 2011

    Ranking query help

    I'm stuck on a site I'm building, I need to make a ranking page that shows results from contests and sorts them by points and gives them a ranking 1 to however may people competed. I have the basics done, I can get the info in the DB and display it on the page but as for the sql query I need to sort the results I'm stumped. It would end up like this:

    Rank Rider Total Points Comp1 Comp2
    1 John 1000 500 500
    2 Fred 800 400 400

    So it would add all the comp columns give a total and then rank based on the highest points
    Here is an example of what I need to do.


    Thank you for any help you can provide...I've googled my self to death looking for tuts on the subject.

  2. #2
    Join Date
    Dec 2002
    St. Louis, MO, USA
    I don't think you can sort by an alias (the sum of Comp1 and Comp2), so you'd most likely have to create a temp table, insert the data into there (including the calculation) and select from that, sorting by the column created for the sum, descending.
    o . Q
    ___ "You live and you learn; or you don't live long." - Lazarus Long


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center