Deepak Deepak - 1 month ago 9
SQL Question

Query to find players who represented multiple countries

Sample Table

I would like to run a query from the given table shown in the screenshot to find out either playerids or playernames who have represented multiple countries.For example playerid=1001 have represented more than one country which is 'IND' and 'USA'.
There are some duplicates rows in this table, but please ignore them.

Thanks for your help in advance.

Answer

I think you mean this:

SELECT PlayerID, PlayerName
FROM yourTable
GROUP BY PlayerID, PlayerName
HAVING COUNT(DISTINCT Country) > 1;
Comments