-1

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
Gordon Linoff
  • 1,122,135
  • 50
  • 484
  • 624

3 Answers3

1


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

Jim Macaulay
  • 3,992
  • 3
  • 16
  • 33
0
Select <ID>, count(<ID>) from <TABLE> group by <ID>

Probably this should help you. Just group by serched column and count it.

Kaa
  • 165
  • 2
  • 14
0

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
ROY
  • 33
  • 8