Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to have a Count when using Groupby?

Tags:

database

mysql

I have got a column name country in which there are 3 entries which are shown below. In each countries i have set of people working in it in a different column. I want a count query which can count how people are working in each country in a single query.

country
________
 India
 America
 China
like image 409
user2470026 Avatar asked Aug 01 '13 07:08

user2470026


People also ask

How do I see the number of groups in Groupby pandas?

The most simple method for pandas groupby count is by using the in-built pandas method named size(). It returns a pandas series that possess the total number of row count for each group.

What does count () do in pandas?

Pandas DataFrame count() Method The count() method counts the number of not empty values for each row, or column if you specify the axis parameter as axis='columns' , and returns a Series object with the result for each row (or column).


1 Answers

try this:

SELECT country,COUNT(*)  
FROM table        
GROUP BY country;  
like image 135
Zaheer Ahmed Avatar answered Sep 17 '22 23:09

Zaheer Ahmed