If I have 3 columns, X, Y, Z, that are each a number, how can I get each row returned greatest to least, and then the rows return greatest to least?
So if I had:
X Y Z
8 7 9
1 2 3
4 6 5
how could I get:
9 8 7
6 5 4
3 2 1
Off of the top of my head, that should work. I’m not going to make promises on performance. If this were Microsoft SQL, I’d be tempted to make a second table which stored the values per row in order, and have a Trigger set up to keep the second table up to date.
Now, that’s pretty obviously only going to work if you have 3 columns. 4 columns is more of a headache, and that’s really where you need to start thinking up a new way to store the info, such as a table like this:
… and so forth.
Once you’ve got the data in this format, doing some sort of:
suddenly becomes super-easy.