Reputation: 13051
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?
Upvotes: 0
Views: 781
Reputation: 15579
select avg(average),name from tableName group by name order by avg(average) desc
Upvotes: 0
Reputation: 56162
Use:
select name, sum(v) as average
from table
group by name
order by sum(v) desc
Upvotes: 0
Reputation: 10644
You don't need average, you need SUM
SELECT name, SUM(v) AS sum FROM table GROUP BY name ORDER BY SUM(v) DESC
Upvotes: 4