Database: wta_1
# players ( player_id , first_name , last_name , hand , birth_date , country_code )
# matches ( best_of , draw_size , loser_age , loser_entry , loser_hand , loser_ht , loser_id , loser_ioc , loser_name , loser_rank , loser_rank_points , loser_seed , match_num , minutes , round , score , surface , tourney_date , tourney_id , tourney_level , tourney_name , winner_age , winner_entry , winner_hand , winner_ht , winner_id , winner_ioc , winner_name , winner_rank , winner_rank_points , winner_seed , year )
# rankings ( ranking_date , ranking , player_id , ranking_points , tours )
# matches.winner_id = players.player_id
# matches.loser_id = players.player_id
# rankings.player_id = players.player_id

Question: Find the total number of players.
SQL: select count ( * ) from players

Question: How many players are there?
SQL: select count ( * ) from players

Question: Find the total number of matches.
SQL: select count ( * ) from matches

Question: Count the number of matches.
SQL: select count ( * ) from matches

Question: List the first name and birth date of all players from the country with code USA.
SQL: select first_name , birth_date from players where country_code = 'USA'

Question: What are the first names and birth dates of players from the USA?
SQL: select first_name , birth_date from players where country_code = 'USA'

Question: Find the average age of losers and winners of all matches.
SQL: select avg ( loser_age ) , avg ( winner_age ) from matches

Question: What are the average ages of losers and winners across matches?
SQL: select avg ( loser_age ) , avg ( winner_age ) from matches

Question: Find the average rank of winners in all matches.
SQL: select avg ( winner_rank ) from matches

Question: What is the average rank for winners in all matches?
SQL: select avg ( winner_rank ) from matches

Question: Find the highest rank of losers in all matches.
SQL: select min ( loser_rank ) from matches

Question: What is the best rank of losers across all matches?
SQL: select min ( loser_rank ) from matches

Question: find the number of distinct country codes of all players.
SQL: select count ( distinct country_code ) from players

Question: How many distinct countries do players come from?
SQL: select count ( distinct country_code ) from players

Question: Find the number of distinct name of losers.
SQL: select count ( distinct loser_name ) from matches

Question: How many different loser names are there?
SQL: select count ( distinct loser_name ) from matches

Question: Find the name of tourney that has more than 10 matches.
SQL: select tourney_name from matches group by tourney_name having count ( * ) > 10

Question: What are the names of tournaments that have more than 10 matches?
SQL: select tourney_name from matches group by tourney_name having count ( * ) > 10

Question: List the names of all winners who played in both 2013 and 2016.
SQL: select winner_name from matches where year = 2013 intersect select winner_name from matches where year = 2016

Question: What are the names of players who won in both 2013 and 2016?
SQL: select winner_name from matches where year = 2013 intersect select winner_name from matches where year = 2016

Question: List the number of all matches who played in years of 2013 or 2016.
SQL: select count ( * ) from matches where year = 2013 or year = 2016

Question: How many matches were played in 2013 or 2016?
SQL: select count ( * ) from matches where year = 2013 or year = 2016

Question: What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
SQL: select players.country_code , players.first_name from players join matches on players.player_id = matches.winner_id where matches.tourney_name = 'WTA Championships' intersect select players.country_code , players.first_name from players join matches on players.player_id = matches.winner_id where matches.tourney_name = 'Australian Open'

Question: What are the first names and country codes for players who won both the WTA Championships and the Australian Open?
SQL: select players.country_code , players.first_name from players join matches on players.player_id = matches.winner_id where matches.tourney_name = 'WTA Championships' intersect select players.country_code , players.first_name from players join matches on players.player_id = matches.winner_id where matches.tourney_name = 'Australian Open'

Question: Find the first name and country code of the oldest player.
SQL: select first_name , country_code from players order by birth_date asc limit 1

Question: What is the first name and country code of the oldest player?
SQL: select first_name , country_code from players order by birth_date asc limit 1

Question: List the first and last name of all players in the order of birth date.
SQL: select first_name , last_name from players order by birth_date asc

Question: What are the full names of all players, sorted by birth date?
SQL: select first_name , last_name from players order by birth_date asc

Question: List the first and last name of all players who are left / L hand in the order of birth date.
SQL: select first_name , last_name from players where hand = 'L' order by birth_date asc

Question: What are the full names of all left handed players, in order of birth date?
SQL: select first_name , last_name from players where hand = 'L' order by birth_date asc

Question: Find the first name and country code of the player who did the most number of tours.
SQL: select players.country_code , players.first_name from players join rankings on players.player_id = rankings.player_id order by rankings.tours desc limit 1

Question: What is the first name and country code of the player with the most tours?
SQL: select players.country_code , players.first_name from players join rankings on players.player_id = rankings.player_id order by rankings.tours desc limit 1

Question: Find the year that has the most number of matches.
SQL: select year from matches group by year order by count ( * ) desc limit 1

Question: Which year had the most matches?
SQL: select year from matches group by year order by count ( * ) desc limit 1

Question: Find the name and rank points of the winner who won the most times.
SQL: select winner_name , winner_rank_points from matches group by winner_name order by count ( * ) desc limit 1

Question: What is the name of the winner who has won the most matches, and how many rank points does this player have?
SQL: select winner_name , winner_rank_points from matches group by winner_name order by count ( * ) desc limit 1

Question: Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
SQL: select winner_name from matches where tourney_name = 'Australian Open' order by winner_rank_points desc limit 1

Question: What is the name of the winner with the most rank points who participated in the Australian Open tournament?
SQL: select winner_name from matches where tourney_name = 'Australian Open' order by winner_rank_points desc limit 1

Question: find the names of loser and winner who played in the match with greatest number of minutes.
SQL: select winner_name , loser_name from matches order by minutes desc limit 1

Question: What are the names of the winner and loser who played in the longest match?
SQL: select winner_name , loser_name from matches order by minutes desc limit 1

Question: Find the average ranking for each player and their first name.
SQL: select avg ( ranking ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name

Question: What are the first names of all players, and their average rankings?
SQL: select avg ( ranking ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name

Question: Find the total ranking points for each player and their first name.
SQL: select sum ( ranking_points ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name

Question: What are the first names of all players, and their total ranking points?
SQL: select sum ( ranking_points ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name

Question: find the number of players for each country.
SQL: select count ( * ) , country_code from players group by country_code

Question: How many players are from each country?
SQL: select count ( * ) , country_code from players group by country_code

Question: find the code of the country where has the greatest number of players.
SQL: select country_code from players group by country_code order by count ( * ) desc limit 1

Question: What is the code of the country with the most players?
SQL: select country_code from players group by country_code order by count ( * ) desc limit 1

Question: Find the codes of countries that have more than 50 players.
SQL: select country_code from players group by country_code having count ( * ) > 50

Question: What are the codes of countries with more than 50 players?
SQL: select country_code from players group by country_code having count ( * ) > 50

Question: Find the total number of tours for each ranking date.
SQL: select sum ( tours ) , ranking_date from rankings group by ranking_date

Question: How many total tours were there for each ranking date?
SQL: select sum ( tours ) , ranking_date from rankings group by ranking_date

Question: Find the number of matches happened in each year.
SQL: select count ( * ) , year from matches group by year

Question: How many matches were played in each year?
SQL: select count ( * ) , year from matches group by year

Question: Find the name and rank of the 3 youngest winners across all matches.
SQL: select distinct winner_name , winner_rank from matches order by winner_age asc limit 3

Question: What are the names and ranks of the three youngest winners across all matches?
SQL: select distinct winner_name , winner_rank from matches order by winner_age asc limit 3

Question: How many different winners both participated in the WTA Championships and were left handed?
SQL: select count ( distinct winner_name ) from matches where tourney_name = 'WTA Championships' and winner_hand = 'L'

Question: Find the number of left handed winners who participated in the WTA Championships.
SQL: select count ( distinct winner_name ) from matches where tourney_name = 'WTA Championships' and winner_hand = 'L'

Question: Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
SQL: select players.first_name , players.country_code , players.birth_date from players join matches on players.player_id = matches.winner_id order by matches.winner_rank_points desc limit 1

Question: What is the first name, country code, and birth date of the player with the most winner rank points across all matches?
SQL: select players.first_name , players.country_code , players.birth_date from players join matches on players.player_id = matches.winner_id order by matches.winner_rank_points desc limit 1

Question: Find the number of players for each hand type.
SQL: select count ( * ) , hand from players group by hand

Question: How many players are there for each hand type?
SQL: select count ( * ) , hand from players group by hand