Chinastark/bird_dataset huggingface dataset:
Database: olympics
Note: swimming refers to sport_name = 'Swimming';
Question: Tell the number of swimming related events.
SQL: SELECT count(event.event_name) FROM sport INNER JOIN event ON sport.id = event.sport_id WHERE sport.sport_name = 'Swimming'
Database: olympics
Note: name of his/her region refers to region_name;
Question: For Peter Kohnke, show the name of his/her region.
SQL: SELECT noc_region.region_name FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id INNER JOIN person ON person_region.person_id = person.id WHERE person.full_name = 'Peter Kohnke'
Database: olympics
Note: id of the game refers to games_id;
Question: Which game has Jessica Carolina Aguilera Aguilera participated in? Give the id of the game.
SQL: SELECT games_competitor.games_id FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE person.full_name = 'Jessica Carolina Aguilera Aguilera'
Database: olympics
Note: name of the sport with the most events refers to sport_name where MAX(COUNT(id));
Question: Show the name of the sport with the most events.
SQL: SELECT sport.sport_name FROM sport INNER JOIN event ON sport.id = event.sport_id GROUP BY sport.sport_name ORDER BY count(event.event_name) DESC LIMIT 1
Database: olympics
Note: the tallest athlete refers to id where MAX(height); from Sweden refers to region_name = 'Sweden'; name refers to full_name;
Question: Give the name of the tallest athlete from Sweden.
SQL: SELECT person.full_name FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id INNER JOIN person ON person_region.person_id = person.id WHERE noc_region.region_name = 'Sweden' ORDER BY person.height DESC LIMIT 1
Database: olympics
Note: from Guatemala refers to region_name = 'Guatemala';
Question: How many athletes in the database are from Guatemala?
SQL: SELECT count(person_region.person_id) FROM person_region INNER JOIN noc_region ON person_region.region_id = noc_region.id WHERE noc_region.region_name = 'Guatemala'
Database: olympics
Note: Who refers to full_name; participated in the most Olympic games refers to MAX(COUNT(games_id));
Question: Who has participated in the most Olympic Games in the database?
SQL: SELECT person.full_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id GROUP BY games_competitor.person_id ORDER BY count(games_competitor.person_id) DESC LIMIT 1
Database: olympics
Note: name of the competitor refers to full_name;
Question: Show the name of the competitor id 90991.
SQL: SELECT person.full_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE games_competitor.id = 90991
Database: olympics
Question: How many competitor ids does Martina Kohlov have?
SQL: SELECT count(games_competitor.id) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE person.full_name = 'Martina Kohlov'
Database: olympics
Note: DIVidE(weight), MULTIPLY(height, height) where id = 147420;
Question: Calculate the bmi of the competitor id 147420.
SQL: SELECT cast(person.weight AS REAL) / (person.height * person.height) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE games_competitor.id = 147420
Database: olympics
Note: DIVidE(COUNT(id where gender = 'M'), COUNT(id)) as percentage where region_name = 'Estonia';
Question: What is the percentage of male athletes from Estonia?
SQL: SELECT cast(count(CASE WHEN person.gender = 'M' THEN 1 ELSE NULL END) AS REAL) * 100 / count(person_region.person_id) FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id INNER JOIN person ON person_region.person_id = person.id WHERE noc_region.region_name = 'Estonia'
Database: olympics
Note: Who is the youngest person refers to full_name where MIN(age);
Question: Who is the youngest person who participated in the Olympics?
SQL: SELECT person.full_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id ORDER BY games_competitor.age LIMIT 1
Database: olympics
Note: 24 years old competitors refer to id where age = 24; Men's Basketball refers to event_name = 'Basketball Men''s Basketball';
Question: How many 24 years old competitors competed in Men's Basketball?
SQL: SELECT count(games_competitor.person_id) FROM competitor_event INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN event ON competitor_event.event_id = event.id WHERE event.event_name LIKE 'Basketball Men%s Basketball' AND games_competitor.age = 24
Database: olympics
Note: Art Competitions refer to sport_name = 'Art Competitions'; names of events refers to event_name;
Question: What are the names of the events under Art Competitions?
SQL: SELECT event.event_name FROM sport INNER JOIN event ON sport.id = event.sport_id WHERE sport.sport_name = 'Art Competitions'
Database: olympics
Note: gold medals refer to medal_name = 'Gold';
Question: How many gold medals does Henk Jan Zwolle have?
SQL: SELECT count(person.id) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN competitor_event ON games_competitor.id = competitor_event.competitor_id INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE person.full_name = 'Henk Jan Zwolle' AND medal.medal_name = 'Gold'
Database: olympics
Note: received the most gold medals refers to MAX(COUNT(medal_name = 'Gold'));
Question: What is the name of the event where competitors received the most gold medals?
SQL: SELECT event.event_name FROM competitor_event INNER JOIN event ON competitor_event.event_id = event.id INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE medal.medal_name = 'Gold' GROUP BY event.id ORDER BY count(competitor_event.event_id) DESC LIMIT 1
Database: olympics
Note: from Australia refer region_name = 'Australia';
Question: How many athletes are from Australia?
SQL: SELECT count(person_region.person_id) FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id WHERE noc_region.region_name = 'Australia'
Database: olympics
Note: cities refer to city_name; hosted at least 3 Olympic games refers to COUNT(games_id) >= 3;
Question: Which cities hosted at least 3 Olympic games?
SQL: SELECT city.city_name FROM games_city INNER JOIN city ON games_city.city_id = city.id GROUP BY city.id HAVING count(games_city.games_id) >= 3
Database: olympics
Note: Summer games refer to id where season = 'Summer'; in Stockholm refers to city_name = 'Stockholm';
Question: How many Summer games were held in Stockholm?
SQL: SELECT count(games.id) FROM games_city INNER JOIN city ON games_city.city_id = city.id INNER JOIN games ON games_city.games_id = games.id WHERE city.city_name = 'Stockholm' AND games.season = 'Summer'
Database: olympics
Note: region refers to region_name; most of the athletes refer to MAX(COUNT(person_id));
Question: Which region do most of the athletes are from?
SQL: SELECT noc_region.region_name FROM person_region INNER JOIN noc_region ON person_region.region_id = noc_region.id GROUP BY noc_region.region_name ORDER BY count(person_region.person_id) DESC LIMIT 1
Database: olympics
Note: Where it was held refers to city_name; the first Olympic game refers to id where MIN(games_year);
Question: Where was the first Olympic game held?
SQL: SELECT city.city_name FROM games_city INNER JOIN city ON games_city.city_id = city.id INNER JOIN games ON games_city.games_id = games.id ORDER BY games.games_year LIMIT 1
Database: olympics
Note: the oldest Olympian refers to id where MAX(age); name of the game refers to games_name;
Question: What is the name of the game in which the oldest Olympian has ever participated?
SQL: SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id ORDER BY games_competitor.age LIMIT 1
Database: olympics
Note: 1992 Summer Olympics refer to games_name = '1928 Summer';
Question: How many athletes competed in the 1992 Summer Olympics?
SQL: SELECT count(games_competitor.person_id) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.games_name = '1928 Summer'
Database: olympics
Note: DIVidE(COUNT(event_id where medal_name = 'Gold'), COUNT(event_id)) as percentage where full_name = 'Michael Fred Phelps, II';
Question: How many Olympic events did Michael Phelps II join in total? Find the percentage of the events where he won a gold medal.
SQL: SELECT count(competitor_event.event_id) , cast(count(CASE WHEN medal.id = '1' THEN 1 ELSE NULL END) AS REAL) * 100 / count(medal.id) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN competitor_event ON games_competitor.id = competitor_event.competitor_id INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE person.full_name = 'Michael Fred Phelps, II'
Database: olympics
Note: the most number of competitors refer to MAX(COUNT(person_id)); SUBTRACT(COUNT(person_id where games_name = '1988 Summer'), COUNT(person_id where games_name = '1988 Winter'));
Question: In the Winter and Summer Olympics of 1988, which game has the most number of competitors? Find the difference of the number of competitors between the two games.
SQL: SELECT p1 , ( SELECT max(p2) - min(p2) FROM ( SELECT count(games_competitor.person_id) AS p2 FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.games_name IN ('1988 Winter', '1988 Summer') GROUP BY games.season ) ORDER BY p2 DESC LIMIT 1 ) FROM ( SELECT games.season AS p1, count(games_competitor.person_id) AS p2 FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.games_name IN ('1988 Winter', '1988 Summer') GROUP BY games.season ) ORDER BY p2 DESC LIMIT 1
Database: olympics
Note: age is the most numerous refers to age where MAX(COUNT(person_id));
Question: What age of the competitors is the most numerous?
SQL: SELECT age FROM games_competitor GROUP BY age ORDER BY count(person_id) DESC LIMIT 1
Database: olympics
Note: cities beginning with the letter M refer to city_name LIKE 'M%';
Question: In which cities beginning with the letter M have the Olympic Games been held?
SQL: SELECT city_name FROM city WHERE city_name LIKE 'M%'
Database: olympics
Note: cities refer to city_name; 1976 winter and summer games refer to games_name IN ('1976 Winter', '1976 Summer');
Question: In which cities were the 1976 winter and summer games held?
SQL: SELECT city.city_name FROM games_city INNER JOIN city ON games_city.city_id = city.id INNER JOIN games ON games_city.games_id = games.id WHERE games.games_name IN ('1976 Summer', '1976 Winter')
Database: olympics
Note: What medal refers to medal_name;
Question: What was the medal that Coleen Dufresne got?
SQL: SELECT medal.medal_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN competitor_event ON games_competitor.id = competitor_event.competitor_id INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE person.full_name = 'Coleen Dufresne (-Stewner)'
Database: olympics
Note: name of the competitor refers to full_name; won the most medals refer to MAX(COUNT(medal_id));
Question: What is the name of the competitor who has won the most medals?
SQL: SELECT person.full_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN competitor_event ON games_competitor.id = competitor_event.competitor_id INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE medal.id != 4 GROUP BY person.full_name ORDER BY count(medal.id) DESC LIMIT 1
Database: olympics
Note: Where competitor is from refers to region_name;
Question: Where is competitor Estelle Nze Minko from?
SQL: SELECT noc_region.region_name FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id INNER JOIN person ON person_region.person_id = person.id WHERE person.full_name = 'Estelle Nze Minko'
Database: olympics
Note: name of the sport refers to sport_name;
Question: What is the name of all the sports Chin Eei Hui has competed in?
SQL: SELECT DISTINCT sport.sport_name FROM sport INNER JOIN event ON sport.id = event.sport_id INNER JOIN competitor_event ON event.id = competitor_event.event_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person ON games_competitor.person_id = person.id WHERE person.full_name = 'Chin Eei Hui'
Database: olympics
Note: the oldest person refers to person_id where MAX(age); name refers to full_name;
Question: What is the name of the oldest person who participated in the Olympic Games?
SQL: SELECT person.full_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id ORDER BY games_competitor.age DESC LIMIT 1
Database: olympics
Note: the largest number of women participation refers to MAX(COUNT(gender = 'F')); In which Olympic games refer to games_year;
Question: In which Olympic Games have the largest number of women participation?
SQL: SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id WHERE person.gender = 'F' GROUP BY games.games_name ORDER BY count(games_competitor.person_id) DESC LIMIT 1
Database: olympics
Note: males refer to gender = 'M'; Belgium refers to region_name = 'Belgium';
Question: How many males from Belgium have participated in an Olympic Games?
SQL: SELECT count(person_region.person_id) FROM noc_region INNER JOIN person_region ON noc_region.id = person_region.region_id INNER JOIN person ON person_region.person_id = person.id WHERE noc_region.region_name = 'Belgium' AND person.gender = 'M'
Database: olympics
Note: the Sapporo Olympics refer to games_id where city_name = 'Sapporo';
Question: How many persons participated in the Sapporo Olympics?
SQL: SELECT count(games_competitor.person_id) FROM games_competitor INNER JOIN games_city ON games_competitor.games_id = games_city.games_id INNER JOIN city ON games_city.city_id = city.id WHERE city.city_name = 'Sapporo'
Database: olympics
Note: In which Olympic games refer to games_year;
Question: In which Olympic Games has Morten Aleksander Djupvik participated?
SQL: SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id WHERE person.full_name = 'Morten Aleksander Djupvik'
Database: olympics
Note: 12 meter Mixed Sailing competitions refer to event_name = 'Sailing Mixed 12 metres';
Question: How many persons in total have participated in 12 meter Mixed Sailing competitions?
SQL: SELECT count(competitor_event.competitor_id) FROM competitor_event INNER JOIN event ON competitor_event.event_id = event.id INNER JOIN sport ON event.sport_id = sport.id WHERE event.event_name = 'Sailing Mixed 12 metres'
Database: olympics
Note: Modern Pentathlon refers to sport_name = 'Modern Pentathlon';
Question: How many different events are there of Modern Pentathlon?
SQL: SELECT count(DISTINCT event.event_name) FROM sport INNER JOIN event ON sport.id = event.sport_id WHERE sport.sport_name = 'Modern Pentathlon'
Database: olympics
Note: DIVidE(COUNT(person_id where gender = 'F), COUNT(person_id)) as percentage where event_name = 'Equestrianism Mixed Three-Day event, Individual';
Question: Calculate the percentage of women who have participated in Equestrianism Mixed Three-Day Event, Individual.
SQL: SELECT cast(count(CASE WHEN person.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / count(person.id) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN competitor_event ON games_competitor.id = competitor_event.competitor_id INNER JOIN event ON competitor_event.event_id = event.id WHERE event.event_name = 'Equestrianism Mixed Three-Day Event, Individual'
Database: olympics
Note: DIVidE(SUM(age), COUNT(person_id)) where games_name = '1992 Summer';
Question: Calculate the average age of the persons who participated in the 1992 Summer Games.
SQL: SELECT avg(games_competitor.age) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id WHERE games.games_name = '1992 Summer'
Database: olympics
Note: years refer to games_year; only have summer games refer to games_year where COUNT(games_name) = 1 and season = 'Summer';
Question: List out years that only have summer games.
SQL: SELECT games_year FROM games WHERE season != 'Winter' GROUP BY games_year HAVING count(season) = 1
Database: olympics
Note: games refer to id; during the 90s refers to games_year BETWEEN 1990 AND 1999;
Question: How many Olympics games were held during the 90s?
SQL: SELECT count(games_year) FROM games WHERE games_year BETWEEN '1990' AND '1999'
Database: olympics
Note: athletes refer to person_id; 2014 Winter Olympics refer to games_name = '2014 Winter';
Question: How many athletes participated in the 2014 Winter Olympics?
SQL: SELECT count(games_competitor.person_id) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.games_name = '2014 Winter'
Database: olympics
Note: athletes refer to person_id; region 151 refers to region_id = 151; won a medal refers to medal_id <> 4;
Question: How many athletes from region 151 have won a medal?
SQL: SELECT count(person_region.person_id) FROM competitor_event INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person_region ON games_competitor.person_id = person_region.person_id WHERE person_region.region_id = 151 AND competitor_event.medal_id != 4
Database: olympics
Note: athletes from China refer to person_id where region_name = 'China'; the 2016 Summer Olympics refer to games_name = '2016 Summer';
Question: How many athlete from China participate in the 2016 Summer Olympics?
SQL: SELECT count(person.id) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id INNER JOIN person_region ON person.id = person_region.person_id INNER JOIN noc_region ON person_region.region_id = noc_region.id WHERE games.games_name = '2016 Summer' AND noc_region.region_name = 'China'
Database: olympics
Note: gold medals given to the winners refer to competitor_id where medal_name = 'Gold'; Ice Hockey Men's Ice Hockey refers to event_name = 'Ice Hockey Men''s Ice Hockey';
Question: How many gold medals were given to the winners in the Ice Hockey Men's Ice Hockey event?
SQL: SELECT count(competitor_event.competitor_id) FROM event INNER JOIN competitor_event ON event.id = competitor_event.event_id WHERE event.event_name LIKE 'Ice Hockey Men%s Ice Hockey' AND competitor_event.medal_id = 1
Database: olympics
Note: region refers to region_name; the highest medal number refers to MAX(COUNT(medal_id <> 4));
Question: Which region has the highest medal number?
SQL: SELECT noc_region.region_name FROM medal INNER JOIN competitor_event ON medal.id = competitor_event.medal_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person_region ON games_competitor.person_id = person_region.person_id INNER JOIN noc_region ON person_region.region_id = noc_region.id WHERE medal.id != 4 GROUP BY noc_region.region_name ORDER BY count(competitor_event.competitor_id) DESC LIMIT 1
Database: olympics
Note: gold medalist winners refer to full_name where medal_name = 'Gold'; cycling sport refers to sport_name = 'Cycling';
Question: List out all the gold medalist winners in cycling sport.
SQL: SELECT DISTINCT person.full_name FROM event INNER JOIN competitor_event ON event.id = competitor_event.event_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN sport ON event.sport_id = sport.id INNER JOIN person ON games_competitor.person_id = person.id WHERE sport.sport_name = 'Cycling' AND competitor_event.medal_id = 1
Database: olympics
Note: medals refer to medal_id where medal_id <> 4;
Question: List out all the medals won by Lee Chong Wei.
SQL: SELECT DISTINCT medal.medal_name FROM medal INNER JOIN competitor_event ON medal.id = competitor_event.medal_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person ON games_competitor.person_id = person.id WHERE person.full_name = 'Lee Chong Wei' AND competitor_event.medal_id <> 4
Database: olympics
Note: DIVidE(COUNT(person_id where gender = 'F' and age < 20), COUNT(person_id)) as percentage where games_name = '2002 Winter';
Question: What is the percentage of female athletes below 20s who participated in the 2002 Winter Olympic?
SQL: SELECT cast(count(CASE WHEN person.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / count(games_competitor.person_id) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id WHERE games.games_name = '2002 Winter' AND games_competitor.age < 20
Database: olympics
Note: DIVidE(COUNT(gender = 'M'), COUNT(gender = 'F')) where games_name = '2012 Summer';
Question: What is the ratio male to female athletes in the 2012 Summer Olympic?
SQL: SELECT cast(count(CASE WHEN person.gender = 'M' THEN 1 ELSE NULL END) AS REAL) / count(CASE WHEN person.gender = 'F' THEN 1 ELSE NULL END) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id INNER JOIN person ON games_competitor.person_id = person.id WHERE games.games_name = '2012 Summer'
Database: olympics
Note: the highest number of participants refers to MAX(COUNT(person_id)); the lowest number of participants refers to MIN(COUNT(person_id)); Which summer Olympic refers to games_name where season = 'Summer';
Question: Which summer Olympic have the highest and lowest number of participants?
SQL: SELECT ( SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.season = 'Summer' GROUP BY games.games_year ORDER BY count(games_competitor.person_id) DESC LIMIT 1 ) AS highest , ( SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.season = 'Summer' GROUP BY games.games_year ORDER BY count(games_competitor.person_id) LIMIT 1 ) AS lowest
Database: olympics
Note: Malaysia refers to region_name = 'Malaysia'; athletes won a medal refer to competitor_id where medal_id <> 4;
Question: How many athletes from Malaysia have won a medal?
SQL: SELECT count(games_competitor.person_id) FROM medal INNER JOIN competitor_event ON medal.id = competitor_event.medal_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person_region ON games_competitor.person_id = person_region.person_id INNER JOIN noc_region ON person_region.region_id = noc_region.id WHERE noc_region.region_name = 'Malaysia' AND medal.id != 4
Database: olympics
Note: fall into overweight BMI category refers to DIVidE(weight), MULTIPLY(height, height) < 30; Canoeing refers to a sport name; the 2008 Summer games refer to games_name = '2008 Summer';
Question: How many athletes playing in Canoeing fall into overweight BMI category in the 2008 Summer games?
SQL: SELECT count(person.id) FROM sport INNER JOIN event ON sport.id = event.sport_id INNER JOIN competitor_event ON event.id = competitor_event.event_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person ON games_competitor.person_id = person.id INNER JOIN games ON games_competitor.games_id = games.id WHERE sport.sport_name = 'Canoeing' AND games.games_name = '2008 Summer' AND person.weight * 10000.0 / (person.height * person.height) BETWEEN 25.0 AND 30
Database: olympics
Note: AVG(height) where sport_name = 'Basketball' and event_name = 'Basketball Men''s';
Question: What is the average height of male athletes playing basketball sport?
SQL: SELECT avg(person.height) FROM sport INNER JOIN event ON sport.id = event.sport_id INNER JOIN competitor_event ON event.id = competitor_event.event_id INNER JOIN games_competitor ON competitor_event.competitor_id = games_competitor.id INNER JOIN person ON games_competitor.person_id = person.id WHERE sport.sport_name = 'Basketball' AND person.gender = 'M'