I have a table called visitors which contains IP and country columns.
Now I want to query the table such that I get unique countries from the table and display the count of rows of that country.
Table:
IP Country
1.1.1.1. xyz
1.2.3.4 xyz
2.2.3.6 abc
3.61.3.69 axy
Now I want the result as :
Country No_Visitors
xyz 2
abc 1
axy 1
I know how to do it by using 2 queries, get the unique country first and then again query the table for the country name. But how can I do it with single query.
use AGGREGATE FUNCTION
COUNT()to get the total number of instances for each country.SQLFiddle Demo