I'm in a tricky situation, I need to order the rows in one table by the highest position in three of the columns.
For example, here is a basic table;
ID Stat1 Stat2 Stat3
--------------------------
1 400 100 200
2 200 200 100
3 100 400 400
4 300 300 300
Idealy, each row would be ordered by its average position in each column, sorted by the lowest ascending. This is what would ideally be returned:
ID Average
------------
3 2
4 2
2 2.3333333333333
1 2.6666666666667
The first ID gets the lowest position, because for the first, second and third stats it ranks 1 4 and 3, which is an average of 2.6666666666667.