i’ve a table like:

i have to make sql query to get the average of v and order the average to have the #n best name in function of v in time. Users so have to select #n of best that want to have before do this query.
In order to have:

Can someone help me?
You don’t need average, you need SUM