output
stringlengths
18
577
instruction
stringlengths
16
224
input
stringclasses
160 values
SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID
What is the name of each teacher and what course they teach?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name
What are the names of the teachers and the courses they teach in ascending alphabetical order by the name of the teacher?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math"
Show the name of the teacher for the math course.
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T3.Name FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID WHERE T2.Course = "Math"
What are the names of the people who teach math courses?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T2.Name , COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name
Show names of teachers and the number of courses they teach.
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T2.Name , COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name
What are the names of the teachers and how many courses do they teach?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2
Show names of teachers that teach at least two courses.
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT T2.Name FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name HAVING COUNT(*) >= 2
What are the names of the teachers who teach at least two courses?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT Name FROM teacher WHERE Teacher_id NOT IN (SELECT Teacher_id FROM course_arrange)
List the names of teachers who have not been arranged to teach courses.
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT Name FROM teacher WHERE Teacher_id NOT IN (SELECT Teacher_id FROM course_arrange)
What are the names of the teachers whose courses have not been arranged?
"Schema (values (type))": course : Course_ID (number) , Staring_Date (text) , Course (text) | teacher : Teacher_ID (number) , Name (text) , Age (text) , Hometown (text) | course_arrange : Course_ID (number) , Teacher_ID (number) , Grade (number) "Primary Keys": course : Course_ID | teacher : Teacher_ID | course_arrange : Course_ID "Foreign Keys": course_arrange : Teacher_ID equals teacher : Teacher_ID | course_arrange : Course_ID equals course : Course_ID
SELECT count(*) FROM visitor WHERE age < 30
How many visitors below age 30 are there?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT avg(age) FROM visitor WHERE Level_of_membership <= 4
What is the average age of the visitors whose membership level is not higher than 4?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT name , Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC
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.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT museum_id , name FROM museum ORDER BY num_of_staff DESC LIMIT 1
Find the id and name of the museum that has the most staff members?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT avg(num_of_staff) FROM museum WHERE open_year < 2009
Find the average number of staff working for the museums that were open before 2009.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT Num_of_Staff , Open_Year FROM museum WHERE name = 'Plaza Museum'
What are the opening year and staff number of the museum named Plaza Museum?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT name FROM museum WHERE num_of_staff > (SELECT min(num_of_staff) FROM museum WHERE open_year > 2010)
find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT t1.id , t1.name , t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t1.id HAVING count(*) > 1
find the id, name and age for visitors who visited some museums more than once.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT t2.visitor_id , t1.name , t1.Level_of_membership FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id GROUP BY t2.visitor_id ORDER BY sum(t2.Total_spent) DESC LIMIT 1
What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT t2.Museum_ID , t1.name FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID GROUP BY t2.Museum_ID ORDER BY count(*) DESC LIMIT 1
What are the id and name of the museum visited most times?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT name FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
What is the name of the museum that had no visitor yet?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT t1.name , t1.age FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id ORDER BY t2.num_of_ticket DESC LIMIT 1
Find the name and age of the visitor who bought the most tickets at once.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT avg(num_of_ticket) , max(num_of_ticket) FROM visit
What are the average and maximum number of tickets bought in all visits?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT sum(t2.Total_spent) FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id WHERE t1.Level_of_membership = 1
What is the total ticket expense of the visitors whose membership level is 1?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year < 2009 INTERSECT SELECT t1.name FROM visitor AS t1 JOIN visit AS t2 ON t1.id = t2.visitor_id JOIN museum AS t3 ON t3.Museum_ID = t2.Museum_ID WHERE t3.open_year > 2011
What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT count(*) FROM visitor WHERE id NOT IN (SELECT t2.visitor_id FROM museum AS t1 JOIN visit AS t2 ON t1.Museum_ID = t2.Museum_ID WHERE t1.open_year > 2010)
Find the number of visitors who did not visit any museum opened after 2010.
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT count(*) FROM museum WHERE open_year > 2013 OR open_year < 2008
How many museums were opened after 2013 or before 2008?
"Schema (values (type))": museum : Museum_ID (number) , Name (text) , Num_of_Staff (number) , Open_Year (text) | visitor : ID (number) , Name (text) , Level_of_membership (number) , Age (number) | visit : Museum_ID (number) , visitor_ID (text) , Num_of_Ticket (number) , Total_spent (number) "Primary Keys": museum : Museum_ID | visitor : ID | visit : Museum_ID "Foreign Keys": visit : visitor_ID equals visitor : ID | visit : Museum_ID equals museum : Museum_ID
SELECT count(*) FROM players
Find the total number of players.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM players
How many players are there?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM matches
Find the total number of matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM matches
Count the number of matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , birth_date FROM players WHERE country_code = 'USA'
List the first name and birth date of all players from the country with code USA.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , birth_date FROM players WHERE country_code = 'USA'
What are the first names and birth dates of players from the USA?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(loser_age) , avg(winner_age) FROM matches
Find the average age of losers and winners of all matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(loser_age) , avg(winner_age) FROM matches
What are the average ages of losers and winners across matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(winner_rank) FROM matches
Find the average rank of winners in all matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(winner_rank) FROM matches
What is the average rank for winners in all matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT min(loser_rank) FROM matches
Find the highest rank of losers in all matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT min(loser_rank) FROM matches
What is the best rank of losers across all matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT country_code) FROM players
find the number of distinct country codes of all players.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT country_code) FROM players
How many distinct countries do players come from?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT loser_name) FROM matches
Find the number of distinct name of losers.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT loser_name) FROM matches
How many different loser names are there?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING count(*) > 10
Find the name of tourney that has more than 10 matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING count(*) > 10
What are the names of tournaments that have more than 10 matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
List the names of all winners who played in both 2013 and 2016.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
What are the names of players who won in both 2013 and 2016?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
List the number of all matches who played in years of 2013 or 2016.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
How many matches were played in 2013 or 2016?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open'
What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'WTA Championships' INTERSECT SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id WHERE T2.tourney_name = 'Australian Open'
What are the first names and country codes for players who won both the WTA Championships and the Australian Open?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
Find the first name and country code of the oldest player.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
What is the first name and country code of the oldest player?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , last_name FROM players ORDER BY birth_date
List the first and last name of all players in the order of birth date.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , last_name FROM players ORDER BY birth_date
What are the full names of all players, sorted by birth date?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
List the first and last name of all players who are left / L hand in the order of birth date.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
What are the full names of all left handed players, in order of birth date?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC LIMIT 1
Find the first name and country code of the player who did the most number of tours.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.country_code , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id ORDER BY T2.tours DESC LIMIT 1
What is the first name and country code of the player with the most tours?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT YEAR FROM matches GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
Find the year that has the most number of matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT YEAR FROM matches GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
Which year had the most matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name , winner_rank_points FROM matches GROUP BY winner_name ORDER BY count(*) DESC LIMIT 1
Find the name and rank points of the winner who won the most times.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name , winner_rank_points FROM matches GROUP BY winner_name ORDER BY count(*) DESC LIMIT 1
What is the name of the winner who has won the most matches, and how many rank points does this player have?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1
Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1
What is the name of the winner with the most rank points who participated in the Australian Open tournament?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name , loser_name FROM matches ORDER BY minutes DESC LIMIT 1
find the names of loser and winner who played in the match with greatest number of minutes.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT winner_name , loser_name FROM matches ORDER BY minutes DESC LIMIT 1
What are the names of the winner and loser who played in the longest match?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(ranking) , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
Find the average ranking for each player and their first name.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT avg(ranking) , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
What are the first names of all players, and their average rankings?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT sum(ranking_points) , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
Find the total ranking points for each player and their first name.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT sum(ranking_points) , T1.first_name FROM players AS T1 JOIN rankings AS T2 ON T1.player_id = T2.player_id GROUP BY T1.first_name
What are the first names of all players, and their total ranking points?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , country_code FROM players GROUP BY country_code
find the number of players for each country.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , country_code FROM players GROUP BY country_code
How many players are from each country?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT country_code FROM players GROUP BY country_code ORDER BY count(*) DESC LIMIT 1
find the code of the country where has the greatest number of players.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT country_code FROM players GROUP BY country_code ORDER BY count(*) DESC LIMIT 1
What is the code of the country with the most players?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT country_code FROM players GROUP BY country_code HAVING count(*) > 50
Find the codes of countries that have more than 50 players.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT country_code FROM players GROUP BY country_code HAVING count(*) > 50
What are the codes of countries with more than 50 players?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT sum(tours) , ranking_date FROM rankings GROUP BY ranking_date
Find the total number of tours for each ranking date.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT sum(tours) , ranking_date FROM rankings GROUP BY ranking_date
How many total tours were there for each ranking date?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , YEAR FROM matches GROUP BY YEAR
Find the number of matches happened in each year.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , YEAR FROM matches GROUP BY YEAR
How many matches were played in each year?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT DISTINCT winner_name , winner_rank FROM matches ORDER BY winner_age LIMIT 3
Find the name and rank of the 3 youngest winners across all matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT DISTINCT winner_name , winner_rank FROM matches ORDER BY winner_age LIMIT 3
What are the names and ranks of the three youngest winners across all matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'
How many different winners both participated in the WTA Championships and were left handed?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'
Find the number of left handed winners who participated in the WTA Championships.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.first_name , T1.country_code , T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC LIMIT 1
Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT T1.first_name , T1.country_code , T1.birth_date FROM players AS T1 JOIN matches AS T2 ON T1.player_id = T2.winner_id ORDER BY T2.winner_rank_points DESC LIMIT 1
What is the first name, country code, and birth date of the player with the most winner rank points across all matches?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , hand FROM players GROUP BY hand
Find the number of players for each hand type.
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) , hand FROM players GROUP BY hand
How many players are there for each hand type?
"Schema (values (type))": players : player_id (number) , first_name (text) , last_name (text) , hand (text) , birth_date (time) , country_code (text) | matches : best_of (number) , draw_size (number) , loser_age (number) , loser_entry (text) , loser_hand (text) , loser_ht (number) , loser_id (number) , loser_ioc (text) , loser_name (text) , loser_rank (number) , loser_rank_points (number) , loser_seed (number) , match_num (number) , minutes (number) , round (text) , score (text) , surface (text) , tourney_date (time) , tourney_id (text) , tourney_level (text) , tourney_name (text) , winner_age (number) , winner_entry (text) , winner_hand (text) , winner_ht (number) , winner_id (number) , winner_ioc (text) , winner_name (text) , winner_rank (number) , winner_rank_points (number) , winner_seed (number) , year (number) | rankings : ranking_date (time) , ranking (number) , player_id (number) , ranking_points (number) , tours (number) "Primary Keys": players : player_id "Foreign Keys": matches : winner_id equals players : player_id | matches : loser_id equals players : player_id | rankings : player_id equals players : player_id
SELECT count(*) FROM ship WHERE disposition_of_ship = 'Captured'
How many ships ended up being 'Captured'?
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT name , tonnage FROM ship ORDER BY name DESC
List the name and tonnage ordered by in descending alphaetical order for the names.
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT name , date FROM battle
List the name, date and result of each battle.
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT max(killed) , min(killed) FROM death
What is maximum and minimum death toll caused each time?
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT avg(injured) FROM death
What is the average number of injuries caused each time?
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT T1.killed , T1.injured FROM death AS T1 JOIN ship AS t2 ON T1.caused_by_ship_id = T2.id WHERE T2.tonnage = 't'
What are the death and injury situations caused by the ship with tonnage 't'?
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT name , RESULT FROM battle WHERE bulgarian_commander != 'Boril'
What are the name and results of the battles when the bulgarian commander is not 'Boril'
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT DISTINCT T1.id , T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle WHERE T2.ship_type = 'Brig'
What are the different ids and names of the battles that lost any 'Brig' type shipes?
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id
SELECT T1.id , T1.name FROM battle AS T1 JOIN ship AS T2 ON T1.id = T2.lost_in_battle JOIN death AS T3 ON T2.id = T3.caused_by_ship_id GROUP BY T1.id HAVING sum(T3.killed) > 10
What are the ids and names of the battles that led to more than 10 people killed in total.
"Schema (values (type))": battle : id (number) , name (text) , date (text) , bulgarian_commander (text) , latin_commander (text) , result (text) | ship : lost_in_battle (number) , id (number) , name (text) , tonnage (text) , ship_type (text) , location (text) , disposition_of_ship (text) | death : caused_by_ship_id (number) , id (number) , note (text) , killed (number) , injured (number) "Primary Keys": battle : id | ship : id | death : id "Foreign Keys": ship : lost_in_battle equals battle : id | death : caused_by_ship_id equals ship : id