If efficiency is important, then add a column avgscore
and assign it the value of score/numsub
. Then, create an index on the column.
You can use an insert/update trigger to do the average calculation automatically when a row is added or modified.
Once your tables gets large, the sort is going to take a noticeable amount of time.