Sampling with grouping and sum?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
11 views
Got a sketch request:
SELECT * FROM `stat` GROUP BY `geo` ORDER BY `good` DESC

It works correctly, I can not understand how you can group fields and understand at the same time to calculate the sum in this group.
That is, there are countries (geo) they have the conversion (good == 0 || 1) I need to output data like this example:
EN(`geo`) - 100(total number of `good` geo 'EN')
US - 50
GB - 30
by | 11 views

1 Answer

0 like 0 dislike
SELECT `geo`, sum(`good`) as `sum_good` FROM `stat` GROUP BY `geo` ORDER BY `sum_good` DESC


But this is not accurate)
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
3 answers
0 like 0 dislike
1 answer
asked May 20, 2019 by barrty
110,608 questions
257,186 answers
0 comments
35,593 users