I have two tables for teams for players. What I'm trying to figure out is a general counting table. In other words, I want to have the total number of teams in which there are 2 participants, for all the number of teams that have 3 participants, etc.
Here is the database structure.
(Sidebar Question: I'm new here: is there a better way to publish SQL?)
CREATE TABLE `formsfiles`.`Teams` ( `ID` INT NOT NULL AUTO_INCREMENT , `Name` VARCHAR(45) NULL , PRIMARY KEY (`ID`) ); INSERT INTO `Teams` (`Name`) VALUES ('Sharks'); INSERT INTO `Teams` (`Name`) VALUES ('Jets'); INSERT INTO `Teams` (`Name`) VALUES ('Fish'); INSERT INTO `Teams` (`Name`) VALUES ('Dodgers'); CREATE TABLE `Players` ( `ID` INT NOT NULL AUTO_INCREMENT , `Name` VARCHAR(45) NULL , `Team_ID` INT NULL , PRIMARY KEY (`ID`) ); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Jim', '1'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Tom', '1'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Harry', '2'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Dave', '2'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Tim', '3'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Trey', '4'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Jay', '4'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Steve', '4'); INSERT INTO `Players` (`Name`, `Team_ID`) VALUES ('Chris', '4');
What I want is the number of teams in the group.
I would like to see the following output
Team_Size Count 1 1 2 2 4 1
source share