I am trying to count/add multiple rows with a same column value.
As an example:
aid | uid | name | region | timestamp
17 | 43 | Max Payne | Western Europe | 1507677429
101 | 91 | Jeffrey Birchwood | North America | 1509586239
45 | 109 | Richard Branson | North America | 1509536026
167 | 133 | Soenke Tapaz | North America | 1510603831
23 | 431 | Sophie Turner | Western Europe | 1508166970
187 | 431 | Sophie Turner | Western Europe | 1511190350
19 | 431 | Sophie Turner | Western Europe | 1507887993
169 | 431 | Sophie Turner | Western Europe | 1510612773
161 | 431 | Sophie Turner | Western Europe | 1510574362
207 | 431 | Sophie Turner | Western Europe | 1511788946
145 | 431 | Sophie Turner | Western Europe | 1510138206
189 | 431 | Sophie Turner | Western Europe | 1511196429
8 | 445 | Faisal Riaz | North America | 1507583110
33 | 445 | Faisal Riaz | North America | 1509480510
12 | 445 | Faisal Riaz | North America | 1507659660
217 | 445 | Faisal Riaz | North America | 1511914655
7 | 445 | Faisal Riaz | North America | 1507560542
25 | 449 | Venkat Puri | North America | 1508509764
121 | 449 | Venkat Puri | North America | 1509704227
119 | 449 | Venkat Puri | North America | 1509704171
117 | 449 | Venkat Puri | North America | 1509703793
5 | 463 | Scott Jay | North America | 1507301571
21 | 463 | Scott Jay | North America | 1507910814
27 | 465 | Parker Tates | EEMA | 1509109957
29 | 467 | Vivian Bond | Western Europe | 1509465890
31 | 469 | Jean-Christophe Glachant | Western Europe | 1509474304
35 | 471 | Arnab Goswami | North America | 1509535475
37 | 473 | Matthias Toby | Western Europe | 1509535623
39 | 475 | Shubham Sawdhan | North America | 1509535625
41 | 477 | Martin Hoffmann | Asia | 1509535626
What I am trying to do is to count each occurance region
. Hence my result would be:
Region | Count
Western Europe | 12
North America | 16
Asia | 1
EEMA | 1
Thanks
You would simply use group by
:
select region, count(*)
from t
group by region;
I have no idea what your query has to do with the question.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.