db_id
stringclasses
20 values
question
stringlengths
18
174
db_info
stringclasses
20 values
ground_truth
stringlengths
20
474
course_teach
What is the name of each teacher and what course they teach?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name , course.course from course_arrange join course on course_arrange.course_id = course.course_id join teacher on course_arrange.teacher_id = teacher.teacher_id
course_teach
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name , course.course from course_arrange join course on course_arrange.course_id = course.course_id join teacher on course_arrange.teacher_id = teacher.teacher_id order by teacher.name asc
course_teach
What are the names of the teachers and the courses they teach in ascending alphabetical order by the name of the teacher?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name , course.course from course_arrange join course on course_arrange.course_id = course.course_id join teacher on course_arrange.teacher_id = teacher.teacher_id order by teacher.name asc
course_teach
Show the name of the teacher for the math course.
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name from course_arrange join course on course_arrange.course_id = course.course_id join teacher on course_arrange.teacher_id = teacher.teacher_id where course.course = 'Math'
course_teach
What are the names of the people who teach math courses?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name from course_arrange join course on course_arrange.course_id = course.course_id join teacher on course_arrange.teacher_id = teacher.teacher_id where course.course = 'Math'
course_teach
Show names of teachers and the number of courses they teach.
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name , count ( * ) from course_arrange join teacher on course_arrange.teacher_id = teacher.teacher_id group by teacher.name
course_teach
What are the names of the teachers and how many courses do they teach?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name , count ( * ) from course_arrange join teacher on course_arrange.teacher_id = teacher.teacher_id group by teacher.name
course_teach
Show names of teachers that teach at least two courses.
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name from course_arrange join teacher on course_arrange.teacher_id = teacher.teacher_id group by teacher.name having count ( * ) >= 2
course_teach
What are the names of the teachers who teach at least two courses?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select teacher.name from course_arrange join teacher on course_arrange.teacher_id = teacher.teacher_id group by teacher.name having count ( * ) >= 2
course_teach
List the names of teachers who have not been arranged to teach courses.
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select name from teacher where teacher_id not in ( select teacher_id from course_arrange )
course_teach
What are the names of the teachers whose courses have not been arranged?
# course ( course_id , staring_date , course ) # teacher ( teacher_id , name , age , hometown ) # course_arrange ( course_id , teacher_id , grade ) # course_arrange.teacher_id = teacher.teacher_id # course_arrange.course_id = course.course_id
select name from teacher where teacher_id not in ( select teacher_id from course_arrange )
museum_visit
How many visitors below age 30 are there?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select count ( * ) from visitor where age < 30
museum_visit
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select name from visitor where level_of_membership > 4 order by level_of_membership desc
museum_visit
What is the average age of the visitors whose membership level is not higher than 4?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select avg ( age ) from visitor where level_of_membership <= 4
museum_visit
Find the name and membership level of the visitors whose membership level is higher than 4, and sort by their age from old to young.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select name , level_of_membership from visitor where level_of_membership > 4 order by age desc
museum_visit
Find the id and name of the museum that has the most staff members?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select museum_id , name from museum order by num_of_staff desc limit 1
museum_visit
Find the average number of staff working for the museums that were open before 2009.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select avg ( num_of_staff ) from museum where open_year < 2009
museum_visit
What are the opening year and staff number of the museum named Plaza Museum?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select num_of_staff , open_year from museum where name = 'Plaza Museum'
museum_visit
find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select name from museum where num_of_staff > ( select min ( num_of_staff ) from museum where open_year > 2010 )
museum_visit
find the id, name and age for visitors who visited some museums more than once.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select visitor.id , visitor.name , visitor.age from visitor join visit on visitor.id = visit.visitor_id group by visitor.id having count ( * ) > 1
museum_visit
What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select visit.visitor_id , visitor.name , visitor.level_of_membership from visitor join visit on visitor.id = visit.visitor_id group by visit.visitor_id order by sum ( visit.total_spent ) desc limit 1
museum_visit
What are the id and name of the museum visited most times?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select visit.museum_id , museum.name from museum join visit on museum.museum_id = visit.museum_id group by visit.museum_id order by count ( * ) desc limit 1
museum_visit
What is the name of the museum that had no visitor yet?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select name from museum where museum_id not in ( select museum_id from visit )
museum_visit
Find the name and age of the visitor who bought the most tickets at once.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select visitor.name , visitor.age from visitor join visit on visitor.id = visit.visitor_id order by visit.num_of_ticket desc limit 1
museum_visit
What are the average and maximum number of tickets bought in all visits?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select avg ( num_of_ticket ) , max ( num_of_ticket ) from visit
museum_visit
What is the total ticket expense of the visitors whose membership level is 1?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select sum ( visit.total_spent ) from visitor join visit on visitor.id = visit.visitor_id where visitor.level_of_membership = 1
museum_visit
What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select visitor.name from visitor join visit on visitor.id = visit.visitor_id join museum on museum.museum_id = visit.museum_id where museum.open_year < 2009 intersect select visitor.name from visitor join visit on visitor.id = visit.visitor_id join museum on museum.museum_id = visit.museum_id where museum.open_year > 2011
museum_visit
Find the number of visitors who did not visit any museum opened after 2010.
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select count ( * ) from visitor where id not in ( select visit.visitor_id from museum join visit on museum.museum_id = visit.museum_id where museum.open_year > 2010 )
museum_visit
How many museums were opened after 2013 or before 2008?
# museum ( museum_id , name , num_of_staff , open_year ) # visitor ( id , name , level_of_membership , age ) # visit ( museum_id , visitor_id , num_of_ticket , total_spent ) # visit.visitor_id = visitor.id # visit.museum_id = museum.museum_id
select count ( * ) from museum where open_year > 2013 or open_year < 2008
wta_1
Find the total number of players.
# 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
select count ( * ) from players
wta_1
How many players are there?
# 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
select count ( * ) from players
wta_1
Find the total number of matches.
# 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
select count ( * ) from matches
wta_1
Count the number of matches.
# 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
select count ( * ) from matches
wta_1
List the first name and birth date of all players from the country with code USA.
# 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
select first_name , birth_date from players where country_code = 'USA'
wta_1
What are the first names and birth dates of players from the USA?
# 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
select first_name , birth_date from players where country_code = 'USA'
wta_1
Find the average age of losers and winners of all matches.
# 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
select avg ( loser_age ) , avg ( winner_age ) from matches
wta_1
What are the average ages of losers and winners across matches?
# 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
select avg ( loser_age ) , avg ( winner_age ) from matches
wta_1
Find the average rank of winners in all matches.
# 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
select avg ( winner_rank ) from matches
wta_1
What is the average rank for winners in all matches?
# 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
select avg ( winner_rank ) from matches
wta_1
Find the highest rank of losers in all matches.
# 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
select min ( loser_rank ) from matches
wta_1
What is the best rank of losers across all matches?
# 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
select min ( loser_rank ) from matches
wta_1
find the number of distinct country codes of all players.
# 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
select count ( distinct country_code ) from players
wta_1
How many distinct countries do players come from?
# 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
select count ( distinct country_code ) from players
wta_1
Find the number of distinct name of losers.
# 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
select count ( distinct loser_name ) from matches
wta_1
How many different loser names are there?
# 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
select count ( distinct loser_name ) from matches
wta_1
Find the name of tourney that has more than 10 matches.
# 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
select tourney_name from matches group by tourney_name having count ( * ) > 10
wta_1
What are the names of tournaments that have more than 10 matches?
# 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
select tourney_name from matches group by tourney_name having count ( * ) > 10
wta_1
List the names of all winners who played in both 2013 and 2016.
# 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
select winner_name from matches where year = 2013 intersect select winner_name from matches where year = 2016
wta_1
What are the names of players who won in both 2013 and 2016?
# 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
select winner_name from matches where year = 2013 intersect select winner_name from matches where year = 2016
wta_1
List the number of all matches who played in years of 2013 or 2016.
# 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
select count ( * ) from matches where year = 2013 or year = 2016
wta_1
How many matches were played in 2013 or 2016?
# 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
select count ( * ) from matches where year = 2013 or year = 2016
wta_1
What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
# 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
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'
wta_1
What are the first names and country codes for players who won both the WTA Championships and the Australian Open?
# 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
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'
wta_1
Find the first name and country code of the oldest player.
# 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
select first_name , country_code from players order by birth_date asc limit 1
wta_1
What is the first name and country code of the oldest player?
# 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
select first_name , country_code from players order by birth_date asc limit 1
wta_1
List the first and last name of all players in the order of birth date.
# 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
select first_name , last_name from players order by birth_date asc
wta_1
What are the full names of all players, sorted by birth date?
# 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
select first_name , last_name from players order by birth_date asc
wta_1
List the first and last name of all players who are left / L hand in the order of birth date.
# 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
select first_name , last_name from players where hand = 'L' order by birth_date asc
wta_1
What are the full names of all left handed players, in order of birth date?
# 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
select first_name , last_name from players where hand = 'L' order by birth_date asc
wta_1
Find the first name and country code of the player who did the most number of tours.
# 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
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
wta_1
What is the first name and country code of the player with the most tours?
# 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
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
wta_1
Find the year that has the most number of matches.
# 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
select year from matches group by year order by count ( * ) desc limit 1
wta_1
Which year had the most matches?
# 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
select year from matches group by year order by count ( * ) desc limit 1
wta_1
Find the name and rank points of the winner who won the most times.
# 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
select winner_name , winner_rank_points from matches group by winner_name order by count ( * ) desc limit 1
wta_1
What is the name of the winner who has won the most matches, and how many rank points does this player have?
# 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
select winner_name , winner_rank_points from matches group by winner_name order by count ( * ) desc limit 1
wta_1
Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
# 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
select winner_name from matches where tourney_name = 'Australian Open' order by winner_rank_points desc limit 1
wta_1
What is the name of the winner with the most rank points who participated in the Australian Open tournament?
# 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
select winner_name from matches where tourney_name = 'Australian Open' order by winner_rank_points desc limit 1
wta_1
find the names of loser and winner who played in the match with greatest number of minutes.
# 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
select winner_name , loser_name from matches order by minutes desc limit 1
wta_1
What are the names of the winner and loser who played in the longest match?
# 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
select winner_name , loser_name from matches order by minutes desc limit 1
wta_1
Find the average ranking for each player and their first name.
# 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
select avg ( ranking ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name
wta_1
What are the first names of all players, and their average rankings?
# 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
select avg ( ranking ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name
wta_1
Find the total ranking points for each player and their first name.
# 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
select sum ( ranking_points ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name
wta_1
What are the first names of all players, and their total ranking points?
# 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
select sum ( ranking_points ) , players.first_name from players join rankings on players.player_id = rankings.player_id group by players.first_name
wta_1
find the number of players for each country.
# 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
select count ( * ) , country_code from players group by country_code
wta_1
How many players are from each country?
# 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
select count ( * ) , country_code from players group by country_code
wta_1
find the code of the country where has the greatest number of players.
# 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
select country_code from players group by country_code order by count ( * ) desc limit 1
wta_1
What is the code of the country with the most players?
# 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
select country_code from players group by country_code order by count ( * ) desc limit 1
wta_1
Find the codes of countries that have more than 50 players.
# 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
select country_code from players group by country_code having count ( * ) > 50
wta_1
What are the codes of countries with more than 50 players?
# 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
select country_code from players group by country_code having count ( * ) > 50
wta_1
Find the total number of tours for each ranking date.
# 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
select sum ( tours ) , ranking_date from rankings group by ranking_date
wta_1
How many total tours were there for each ranking date?
# 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
select sum ( tours ) , ranking_date from rankings group by ranking_date
wta_1
Find the number of matches happened in each year.
# 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
select count ( * ) , year from matches group by year
wta_1
How many matches were played in each year?
# 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
select count ( * ) , year from matches group by year
wta_1
Find the name and rank of the 3 youngest winners across all matches.
# 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
select distinct winner_name , winner_rank from matches order by winner_age asc limit 3
wta_1
What are the names and ranks of the three youngest winners across all matches?
# 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
select distinct winner_name , winner_rank from matches order by winner_age asc limit 3
wta_1
How many different winners both participated in the WTA Championships and were left handed?
# 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
select count ( distinct winner_name ) from matches where tourney_name = 'WTA Championships' and winner_hand = 'L'
wta_1
Find the number of left handed winners who participated in the WTA Championships.
# 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
select count ( distinct winner_name ) from matches where tourney_name = 'WTA Championships' and winner_hand = 'L'
wta_1
Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
# 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
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
wta_1
What is the first name, country code, and birth date of the player with the most winner rank points across all matches?
# 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
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
wta_1
Find the number of players for each hand type.
# 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
select count ( * ) , hand from players group by hand
wta_1
How many players are there for each hand type?
# 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
select count ( * ) , hand from players group by hand
battle_death
How many ships ended up being 'Captured'?
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select count ( * ) from ship where disposition_of_ship = 'Captured'
battle_death
List the name and tonnage ordered by in descending alphaetical order for the names.
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select name , tonnage from ship order by name desc
battle_death
List the name, date and result of each battle.
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select name , date from battle
battle_death
What is maximum and minimum death toll caused each time?
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select max ( killed ) , min ( killed ) from death
battle_death
What is the average number of injuries caused each time?
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select avg ( injured ) from death
battle_death
What are the death and injury situations caused by the ship with tonnage 't'?
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select death.killed , death.injured from death join ship on death.caused_by_ship_id = ship.id where ship.tonnage = 't'
battle_death
What are the name and results of the battles when the bulgarian commander is not 'Boril'
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select name , result from battle where bulgarian_commander != 'Boril'
battle_death
What are the different ids and names of the battles that lost any 'Brig' type shipes?
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select distinct battle.id , battle.name from battle join ship on battle.id = ship.lost_in_battle where ship.ship_type = 'Brig'
battle_death
What are the ids and names of the battles that led to more than 10 people killed in total.
# battle ( id , name , date , bulgarian_commander , latin_commander , result ) # ship ( lost_in_battle , id , name , tonnage , ship_type , location , disposition_of_ship ) # death ( caused_by_ship_id , id , note , killed , injured ) # ship.lost_in_battle = battle.id # death.caused_by_ship_id = ship.id
select battle.id , battle.name from battle join ship on battle.id = ship.lost_in_battle join death on ship.id = death.caused_by_ship_id group by battle.id having sum ( death.killed ) > 10