How to find count of repeated country names and also display different country names using single sql query?
I have table Source_country_Table
INDIA
SPAIN
JAPAN
INDIA
US
UK
US
SPAIN
JAPAN
INDIA
How to find count of repeated country names and also display different country names using single sql query?
I have table Source_country_Table
INDIA
SPAIN
JAPAN
INDIA
US
UK
US
SPAIN
JAPAN
INDIA
You can use below query to get the count of multiple country names
SELECT COLUMN_NAME, COUNT(*) FROM Source_country_Table
GROUP BY COLUMN_NAME HAVING COUNT(*) > 1;
Make clear of the second requirement to help you out
Select <ID>, count(<ID>) from <TABLE> group by <ID>
Probably this should help you. Just group by serched column and count it.
To show repeated country names with count:
SELECT Country_Name, COUNT(Country_Name) as Counts FROM
[Source_country_Table] GROUP BY Country_Name HAVING COUNT(Country_Name) > 1
To show all the country names with count:
SELECT Country_Name, COUNT(Country_Name) FROM [Source_country_Table] GROUP BY Country_Name