Page 1 of 1

ranking or incrementing results

Posted: Thu Feb 17, 2005 1:52 pm
by magicrobotmonkey
What I am trying to do here is to rank the results I am getting based on one column, but order them based on another column.

For instance, say I've got a table locations. I want to query it such that I get a rank based on the score, but I want it ordered by the location name. Is this even possible?

I am using MySQL

Posted: Thu Feb 17, 2005 3:58 pm
by feyd
I don't understand...maybe a pseudo-query would help. :?

Posted: Thu Feb 17, 2005 6:41 pm
by magicrobotmonkey
ok lets say I have table locatoins

Code: Select all

LOCATIONS
LocID
LocName
LocScore
Now what I want to do is get a result ordered by LocName. I also want to know the score, but not the actual score, rather, the rank of the score, as if i was ordering by LocScore descending, which number it would be. So if there were three shops scoring 100, 100, and 95, their ranks would be 1, 1, an 2 respectivly. In essence I am trying to order by two different columns. I am afraid this may be unpossible, and I am trying to work out a way to do it by some sorting of the resulting arrays, but the size of them frightens me.