query_id
int64
0
1.03k
database_id
stringclasses
20 values
table_id
sequencelengths
1
4
query
stringlengths
18
174
answer
stringlengths
20
422
difficulty
stringclasses
4 values
400
course_teach
[ "teacher", "course", "course_arrange" ]
What is the name of each teacher and what course they teach?
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
medium
401
course_teach
[ "teacher", "course", "course_arrange" ]
Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.
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
hard
402
course_teach
[ "teacher", "course", "course_arrange" ]
What are the names of the teachers and the courses they teach in ascending alphabetical order by the name of the teacher?
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
hard
403
course_teach
[ "teacher", "course", "course_arrange" ]
Show the name of the teacher for the math course.
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"
hard
404
course_teach
[ "teacher", "course", "course_arrange" ]
What are the names of the people who teach math courses?
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"
hard
405
course_teach
[ "teacher", "course_arrange" ]
Show names of teachers and the number of courses they teach.
SELECT T2.Name , COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name
medium
406
course_teach
[ "teacher", "course_arrange" ]
What are the names of the teachers and how many courses do they teach?
SELECT T2.Name , COUNT(*) FROM course_arrange AS T1 JOIN teacher AS T2 ON T1.Teacher_ID = T2.Teacher_ID GROUP BY T2.Name
medium
407
course_teach
[ "teacher", "course_arrange" ]
Show names of teachers that teach at least two courses.
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
medium
408
course_teach
[ "teacher", "course_arrange" ]
What are the names of the teachers who teach at least two courses?
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
medium
409
course_teach
[ "teacher", "course_arrange" ]
List the names of teachers who have not been arranged to teach courses.
SELECT Name FROM teacher WHERE Teacher_id NOT IN (SELECT Teacher_id FROM course_arrange)
hard
410
course_teach
[ "teacher", "course_arrange" ]
What are the names of the teachers whose courses have not been arranged?
SELECT Name FROM teacher WHERE Teacher_id NOT IN (SELECT Teacher_id FROM course_arrange)
hard
411
museum_visit
[ "visitor" ]
How many visitors below age 30 are there?
SELECT count(*) FROM visitor WHERE age < 30
easy
412
museum_visit
[ "visitor" ]
Find the names of the visitors whose membership level is higher than 4, and order the results by the level from high to low.
SELECT name FROM visitor WHERE Level_of_membership > 4 ORDER BY Level_of_membership DESC
medium
413
museum_visit
[ "visitor" ]
What is the average age of the visitors whose membership level is not higher than 4?
SELECT avg(age) FROM visitor WHERE Level_of_membership <= 4
easy
414
museum_visit
[ "visitor" ]
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.
SELECT name , Level_of_membership FROM visitor WHERE Level_of_membership > 4 ORDER BY age DESC
medium
415
museum_visit
[ "museum" ]
Find the id and name of the museum that has the most staff members?
SELECT museum_id , name FROM museum ORDER BY num_of_staff DESC LIMIT 1
medium
416
museum_visit
[ "museum" ]
Find the average number of staff working for the museums that were open before 2009.
SELECT avg(num_of_staff) FROM museum WHERE open_year < 2009
easy
417
museum_visit
[ "museum" ]
What are the opening year and staff number of the museum named Plaza Museum?
SELECT Num_of_Staff , Open_Year FROM museum WHERE name = 'Plaza Museum'
medium
418
museum_visit
[ "museum" ]
find the names of museums which have more staff than the minimum staff number of all museums opened after 2010.
SELECT name FROM museum WHERE num_of_staff > (SELECT min(num_of_staff) FROM museum WHERE open_year > 2010)
hard
419
museum_visit
[ "visit", "visitor" ]
find the id, name and age for visitors who visited some museums more than once.
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
medium
420
museum_visit
[ "visit", "visitor" ]
What are the id, name and membership level of visitors who have spent the largest amount of money in total in all museum tickets?
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
extra
421
museum_visit
[ "visit", "museum" ]
What are the id and name of the museum visited most times?
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
extra
422
museum_visit
[ "visit", "museum" ]
What is the name of the museum that had no visitor yet?
SELECT name FROM museum WHERE Museum_ID NOT IN (SELECT museum_id FROM visit)
hard
423
museum_visit
[ "visit", "visitor" ]
Find the name and age of the visitor who bought the most tickets at once.
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
hard
424
museum_visit
[ "visit" ]
What are the average and maximum number of tickets bought in all visits?
SELECT avg(num_of_ticket) , max(num_of_ticket) FROM visit
medium
425
museum_visit
[ "visit", "visitor" ]
What is the total ticket expense of the visitors whose membership level is 1?
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
medium
426
museum_visit
[ "visit", "visitor", "museum" ]
What is the name of the visitor who visited both a museum opened before 2009 and a museum opened after 2011?
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
extra
427
museum_visit
[ "visit", "visitor", "museum" ]
Find the number of visitors who did not visit any museum opened after 2010.
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)
extra
428
museum_visit
[ "museum" ]
How many museums were opened after 2013 or before 2008?
SELECT count(*) FROM museum WHERE open_year > 2013 OR open_year < 2008
medium
429
wta_1
[ "players" ]
Find the total number of players.
SELECT count(*) FROM players
easy
430
wta_1
[ "players" ]
How many players are there?
SELECT count(*) FROM players
easy
431
wta_1
[ "matches" ]
Find the total number of matches.
SELECT count(*) FROM matches
easy
432
wta_1
[ "matches" ]
Count the number of matches.
SELECT count(*) FROM matches
easy
433
wta_1
[ "players" ]
List the first name and birth date of all players from the country with code USA.
SELECT first_name , birth_date FROM players WHERE country_code = 'USA'
medium
434
wta_1
[ "players" ]
What are the first names and birth dates of players from the USA?
SELECT first_name , birth_date FROM players WHERE country_code = 'USA'
medium
435
wta_1
[ "matches" ]
Find the average age of losers and winners of all matches.
SELECT avg(loser_age) , avg(winner_age) FROM matches
medium
436
wta_1
[ "matches" ]
What are the average ages of losers and winners across matches?
SELECT avg(loser_age) , avg(winner_age) FROM matches
medium
437
wta_1
[ "matches" ]
Find the average rank of winners in all matches.
SELECT avg(winner_rank) FROM matches
easy
438
wta_1
[ "matches" ]
What is the average rank for winners in all matches?
SELECT avg(winner_rank) FROM matches
easy
439
wta_1
[ "matches" ]
Find the highest rank of losers in all matches.
SELECT min(loser_rank) FROM matches
easy
440
wta_1
[ "matches" ]
What is the best rank of losers across all matches?
SELECT min(loser_rank) FROM matches
easy
441
wta_1
[ "players" ]
find the number of distinct country codes of all players.
SELECT count(DISTINCT country_code) FROM players
easy
442
wta_1
[ "players" ]
How many distinct countries do players come from?
SELECT count(DISTINCT country_code) FROM players
easy
443
wta_1
[ "matches" ]
Find the number of distinct name of losers.
SELECT count(DISTINCT loser_name) FROM matches
easy
444
wta_1
[ "matches" ]
How many different loser names are there?
SELECT count(DISTINCT loser_name) FROM matches
easy
445
wta_1
[ "matches" ]
Find the name of tourney that has more than 10 matches.
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING count(*) > 10
easy
446
wta_1
[ "matches" ]
What are the names of tournaments that have more than 10 matches?
SELECT tourney_name FROM matches GROUP BY tourney_name HAVING count(*) > 10
easy
447
wta_1
[ "matches" ]
List the names of all winners who played in both 2013 and 2016.
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
hard
448
wta_1
[ "matches" ]
What are the names of players who won in both 2013 and 2016?
SELECT winner_name FROM matches WHERE YEAR = 2013 INTERSECT SELECT winner_name FROM matches WHERE YEAR = 2016
hard
449
wta_1
[ "matches" ]
List the number of all matches who played in years of 2013 or 2016.
SELECT count(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
medium
450
wta_1
[ "matches" ]
How many matches were played in 2013 or 2016?
SELECT count(*) FROM matches WHERE YEAR = 2013 OR YEAR = 2016
medium
451
wta_1
[ "players", "matches" ]
What are the country code and first name of the players who won in both tourney WTA Championships and Australian Open?
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'
extra
452
wta_1
[ "players", "matches" ]
What are the first names and country codes for players who won both the WTA Championships and the Australian Open?
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'
extra
453
wta_1
[ "players" ]
Find the first name and country code of the oldest player.
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
medium
454
wta_1
[ "players" ]
What is the first name and country code of the oldest player?
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
medium
455
wta_1
[ "players" ]
List the first and last name of all players in the order of birth date.
SELECT first_name , last_name FROM players ORDER BY birth_date
medium
456
wta_1
[ "players" ]
What are the full names of all players, sorted by birth date?
SELECT first_name , last_name FROM players ORDER BY birth_date
medium
457
wta_1
[ "players" ]
List the first and last name of all players who are left / L hand in the order of birth date.
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
medium
458
wta_1
[ "players" ]
What are the full names of all left handed players, in order of birth date?
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
medium
459
wta_1
[ "rankings", "players" ]
Find the first name and country code of the player who did the most number of tours.
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
hard
460
wta_1
[ "rankings", "players" ]
What is the first name and country code of the player with the most tours?
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
hard
461
wta_1
[ "matches" ]
Find the year that has the most number of matches.
SELECT YEAR FROM matches GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
hard
462
wta_1
[ "matches" ]
Which year had the most matches?
SELECT YEAR FROM matches GROUP BY YEAR ORDER BY count(*) DESC LIMIT 1
hard
463
wta_1
[ "matches" ]
Find the name and rank points of the winner who won the most times.
SELECT winner_name , winner_rank_points FROM matches GROUP BY winner_name ORDER BY count(*) DESC LIMIT 1
hard
464
wta_1
[ "matches" ]
What is the name of the winner who has won the most matches, and how many rank points does this player have?
SELECT winner_name , winner_rank_points FROM matches GROUP BY winner_name ORDER BY count(*) DESC LIMIT 1
hard
465
wta_1
[ "matches" ]
Find the name of the winner who has the highest rank points and participated in the Australian Open tourney.
SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1
hard
466
wta_1
[ "matches" ]
What is the name of the winner with the most rank points who participated in the Australian Open tournament?
SELECT winner_name FROM matches WHERE tourney_name = 'Australian Open' ORDER BY winner_rank_points DESC LIMIT 1
hard
467
wta_1
[ "matches" ]
find the names of loser and winner who played in the match with greatest number of minutes.
SELECT winner_name , loser_name FROM matches ORDER BY minutes DESC LIMIT 1
medium
468
wta_1
[ "matches" ]
What are the names of the winner and loser who played in the longest match?
SELECT winner_name , loser_name FROM matches ORDER BY minutes DESC LIMIT 1
medium
469
wta_1
[ "rankings", "players" ]
Find the average ranking for each player and their first name.
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
medium
470
wta_1
[ "rankings", "players" ]
What are the first names of all players, and their average rankings?
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
medium
471
wta_1
[ "rankings", "players" ]
Find the total ranking points for each player and their first name.
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
medium
472
wta_1
[ "rankings", "players" ]
What are the first names of all players, and their total ranking points?
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
medium
473
wta_1
[ "players" ]
find the number of players for each country.
SELECT count(*) , country_code FROM players GROUP BY country_code
medium
474
wta_1
[ "players" ]
How many players are from each country?
SELECT count(*) , country_code FROM players GROUP BY country_code
medium
475
wta_1
[ "players" ]
find the code of the country where has the greatest number of players.
SELECT country_code FROM players GROUP BY country_code ORDER BY count(*) DESC LIMIT 1
hard
476
wta_1
[ "players" ]
What is the code of the country with the most players?
SELECT country_code FROM players GROUP BY country_code ORDER BY count(*) DESC LIMIT 1
hard
477
wta_1
[ "players" ]
Find the codes of countries that have more than 50 players.
SELECT country_code FROM players GROUP BY country_code HAVING count(*) > 50
easy
478
wta_1
[ "players" ]
What are the codes of countries with more than 50 players?
SELECT country_code FROM players GROUP BY country_code HAVING count(*) > 50
easy
479
wta_1
[ "rankings" ]
Find the total number of tours for each ranking date.
SELECT sum(tours) , ranking_date FROM rankings GROUP BY ranking_date
medium
480
wta_1
[ "rankings" ]
How many total tours were there for each ranking date?
SELECT sum(tours) , ranking_date FROM rankings GROUP BY ranking_date
medium
481
wta_1
[ "matches" ]
Find the number of matches happened in each year.
SELECT count(*) , YEAR FROM matches GROUP BY YEAR
medium
482
wta_1
[ "matches" ]
How many matches were played in each year?
SELECT count(*) , YEAR FROM matches GROUP BY YEAR
medium
483
wta_1
[ "matches" ]
Find the name and rank of the 3 youngest winners across all matches.
SELECT DISTINCT winner_name , winner_rank FROM matches ORDER BY winner_age LIMIT 3
medium
484
wta_1
[ "matches" ]
What are the names and ranks of the three youngest winners across all matches?
SELECT DISTINCT winner_name , winner_rank FROM matches ORDER BY winner_age LIMIT 3
medium
485
wta_1
[ "matches" ]
How many different winners both participated in the WTA Championships and were left handed?
SELECT count(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'
medium
486
wta_1
[ "matches" ]
Find the number of left handed winners who participated in the WTA Championships.
SELECT count(DISTINCT winner_name) FROM matches WHERE tourney_name = 'WTA Championships' AND winner_hand = 'L'
medium
487
wta_1
[ "players", "matches" ]
Find the first name, country code and birth date of the winner who has the highest rank points in all matches.
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
hard
488
wta_1
[ "players", "matches" ]
What is the first name, country code, and birth date of the player with the most winner rank points across all matches?
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
hard
489
wta_1
[ "players" ]
Find the number of players for each hand type.
SELECT count(*) , hand FROM players GROUP BY hand
medium
490
wta_1
[ "players" ]
How many players are there for each hand type?
SELECT count(*) , hand FROM players GROUP BY hand
medium
491
battle_death
[ "ship" ]
How many ships ended up being 'Captured'?
SELECT count(*) FROM ship WHERE disposition_of_ship = 'Captured'
easy
492
battle_death
[ "ship" ]
List the name and tonnage ordered by in descending alphaetical order for the names.
SELECT name , tonnage FROM ship ORDER BY name DESC
medium
493
battle_death
[ "battle" ]
List the name, date and result of each battle.
SELECT name , date FROM battle
medium
494
battle_death
[ "death" ]
What is maximum and minimum death toll caused each time?
SELECT max(killed) , min(killed) FROM death
medium
495
battle_death
[ "death" ]
What is the average number of injuries caused each time?
SELECT avg(injured) FROM death
easy
496
battle_death
[ "ship", "death" ]
What are the death and injury situations caused by the ship with tonnage 't'?
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'
medium
497
battle_death
[ "battle" ]
What are the name and results of the battles when the bulgarian commander is not 'Boril'
SELECT name , RESULT FROM battle WHERE bulgarian_commander != 'Boril'
medium
498
battle_death
[ "battle", "ship" ]
What are the different ids and names of the battles that lost any 'Brig' type shipes?
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'
medium
499
battle_death
[ "death", "battle", "ship" ]
What are the ids and names of the battles that led to more than 10 people killed in total.
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
hard