-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,242,037
  • 58
  • 646
  • 786

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
  • 4,709
  • 4
  • 28
  • 53
0
Select <ID>, count(<ID>) from <TABLE> group by <ID>

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

Kaa
  • 193
  • 3
  • 17
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
  • 63
  • 8