select t.Letter, t.Value from MyTable t inner join ( select Letter, sum(Value) as ValueSum from MyTable group by Letter ) ts on t.Letter = ts.Letter order by ts.ValueSum desc, t.Letter, t.Value desc
References :
sorting - MySQL show all grouped results and sort - Stack Overflow
沒有留言:
張貼留言