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.
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.