I know how the group by works, bimmer.
Your query is an example of group by with hidden fields , I was refering to this part of the manual, perhaps not very clearly:
Do not use this feature if the columns you omit from the GROUP BY part are not unique in the group! You get unpredictable results.
Now if your query without the division is working and the correct col2 value is always returned then I completely misunderstand it anyway :bemused:
As to ordering by the calculated column, I just ran this
SELECT test, max(uid)/aid as s FROM assign group by test order by s desc
in phpadmin and it worked for me without a hitch. So I've got no idea what the problem is.