SELECT place, cnt, sum_ FROM ( SELECT place, count(*) as cnt, sum(weight) as sum_ FROM a GROUP BY place ) a ORDER BY place;
Here is what the above code is Doing:
1. The first subquery is grouping the data by place and calculating the count and sum of weight.
2. The second subquery is ordering the data by place.
The result is:
place cnt sum_
A 2 3
B 1 1
C 1 2