I am trying to write a query that would fetch the number of player in a sports team for every country in the table:
I have a table with the following fields
country | sports_team | player_name
What I want to display is a reulst similar to this
country | sports_team | number_of_players
i.e. I would like to loop through all the countries, and for every change in sports_team, I would like to record the nummber of players that are in the team.
Sample table:
country | sports_team | player_name
c1 | teamA | name1
c1 | teamA | name2
c1 | teamB | name3
c2 | teamC | name4
c2 | teamC | name5
Sample results
country | sports_team | number_of_players
c1 | teamA | 2
c1 | teamB | 1
c2 | teamC | 2
I am new to writing sql queries and I have no idea how to procede, any help will be appreciated!