Database: baseball_1

Question: what is the full name and id of the college with the largest number of baseball players?
SQL: SELECT T1.name_full ,  T1.college_id FROM college AS T1 JOIN player_college AS T2 ON T1.college_id  =  T2.college_id GROUP BY T1.college_id ORDER BY count(*) DESC LIMIT 1;

Question: What is average salary of the players in the team named 'Boston Red Stockings' ?
SQL: SELECT avg(T1.salary) FROM salary AS T1 JOIN team AS T2 ON T1.team_id  =  T2.team_id_br WHERE T2.name  = 'Boston Red Stockings'

Question: What are first and last names of players participating in all star game in 1998?
SQL: SELECT name_first ,  name_last FROM player AS T1 JOIN all_star AS T2 ON T1.player_id  =  T2.player_id WHERE YEAR  =  1998

Question: What are the first name, last name and id of the player with the most all star game experiences? Also list the count.
SQL: SELECT T1.name_first , T1.name_last ,  T1.player_id ,   count(*) FROM player AS T1 JOIN all_star AS T2 ON T1.player_id  =  T2.player_id GROUP BY T1.player_id ORDER BY count(*) DESC LIMIT 1;

Question: In 2014, what are the id and rank of the team that has the largest average number of attendance?
SQL: SELECT T2.team_id ,  T2.rank FROM home_game AS T1 JOIN team AS T2 ON T1.team_id  =  T2.team_id WHERE T1.year  =  2014 GROUP BY T1.team_id ORDER BY avg(T1.attendance) DESC LIMIT 1;

Question: What are the manager's first name, last name and id who won the most manager award?
SQL: SELECT T1.name_first ,  T1.name_last ,  T2.player_id FROM player AS T1 JOIN manager_award AS T2 ON T1.player_id  =  T2.player_id GROUP BY T2.player_id ORDER BY count(*) DESC LIMIT 1;

Question: Which 3 players won the most player awards? List their full name and id.
SQL: SELECT T1.name_first ,  T1.name_last ,  T1.player_id FROM player AS T1 JOIN player_award AS T2 ON T1.player_id  =  T2.player_id GROUP BY T1.player_id ORDER BY count(*) DESC LIMIT 3;

Question: List three countries which are the origins of the least players.
SQL: SELECT birth_country FROM player GROUP BY birth_country ORDER BY count(*) ASC LIMIT 3;

Question: How many players born in USA are right-handed batters? That is, have the batter value 'R'.
SQL: SELECT count(*) FROM player WHERE birth_country = 'USA' AND bats  =  'R';

Question: What is the average height of the players from the college named 'Yale University'?
SQL: SELECT avg(T1.height) FROM player AS T1 JOIN player_college AS T2 ON T1.player_id  =  T2.player_id JOIN college AS T3 ON T3.college_id  = T2.college_id WHERE T3.name_full  =  'Yale University';

Question: What is the highest salary among each team? List the team name, id and maximum salary.
SQL: SELECT T1.name ,  T1.team_id ,  max(T2.salary) FROM team AS T1 JOIN salary AS T2 ON T1.team_id  =  T2.team_id GROUP BY T1.team_id;

Question: What are the name and id of the team offering the lowest average salary?
SQL: SELECT T1.name ,  T1.team_id FROM team AS T1 JOIN salary AS T2 ON T1.team_id = T2.team_id GROUP BY T1.team_id ORDER BY avg(T2.salary) ASC LIMIT 1;