Chinastark/bird_dataset huggingface dataset:
Database: olympics
Note: Barcelona refers to city_name = 'Barcelona';
Question: How many athletes took part in the Olympic games held in Barcelona?
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 = 'Barcelona'
Database: olympics
Note: events refer to event_name; football refers to sport_name = 'Football';
Question: How many different football events are there?
SQL: SELECT count(event.event_name) FROM sport INNER JOIN event ON sport.id = event.sport_id WHERE sport.sport_name = 'Football'
Database: olympics
Note: cities refer to city_name;
Question: What were the cities in which John Aalberg competed?
SQL: SELECT city.city_name FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id INNER JOIN games_city ON games_competitor.games_id = games_city.games_id INNER JOIN city ON games_city.city_id = city.id WHERE person.full_name = 'John Aalberg'
Database: olympics
Note: Barcelona refers to city_name = 'Barcelona';
Question: In Barcelona, how many Olympic games were held?
SQL: SELECT count(games_city.games_id) FROM games_city INNER JOIN city ON games_city.city_id = city.id WHERE city.city_name = 'Barcelona'
Database: olympics
Note: competitors over the age of 30 refer to person_id where age > 30; the 1992 Winter Olympics refers to games_name = '1992 Winter';
Question: How many competitors over the age of 30 participated in the 1992 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 = '1992 Winter' AND games_competitor.age > 30
Database: olympics
Note: Barcelona refers to city_name = 'Barcelona'; the most competitors refer to MAX(COUNT(games_name)); name of game refers to games_name;
Question: What is the name of the Olympic game with the most competitors held in Barcelona?
SQL: SELECT games.games_name FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id 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 = 'Barcelona' GROUP BY games.id ORDER BY count(games_competitor.person_id) DESC LIMIT 1
Database: olympics
Note: name refers to full_name; Argentina refers to region_name = 'Argentina';
Question: List the name of competitors from Argentina.
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 = 'Argentina'
Database: olympics
Note: AVG(age) where games_name = '2012 Summer' and region_name = 'Argentina';
Question: What is the average age of Argentina's athletes who participated in the Summer Olympics in 2012?
SQL: SELECT avg(games_competitor.age) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_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 games.games_name = '2012 Summer' AND noc_region.region_name = 'Argentina'
Database: olympics
Note: DIVidE(COUNT(competitor_id where medal_name = 'Bronze'), COUNT(competitor_id)) as percentage where event_name = 'Basketball Men''s Basketball';
Question: Calculate the percentage of bronze medals won by men's basketball players.
SQL: SELECT cast(count(CASE WHEN medal.medal_name = 'Bronze' THEN 1 ELSE NULL END) AS REAL) * 100 / 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 INNER JOIN medal ON competitor_event.medal_id = medal.id WHERE event.event_name LIKE 'Basketball Men%s Basketball'
Database: olympics
Note: name of games refers to games_name;
Question: List the name of the games that Georgios Abaris 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 = 'Georgios Abaris'
Database: olympics
Note: name refers to full_name; Greece refers to region_name = 'Greece';
Question: Provide the name of competitors from Greece.
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 = 'Greece'
Database: olympics
Note: AVG(age) where games_name = '1924 Winter';
Question: Calculate the average age of the competitors who participated in the 1924 Winter.
SQL: SELECT avg(games_competitor.age) FROM games INNER JOIN games_competitor ON games.id = games_competitor.games_id WHERE games.games_name = '1924 Winter'
Database: olympics
Note: noc code refers to noc; competitors weighted 77 kg refer to person_id where weight = 77;
Question: What is the NOC code of the region of the competitors weighted 77 kg?
SQL: SELECT noc_region.noc 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.weight = 77
Database: olympics
Note: Paris refers to city_name = 'Paris'; names of games refers to games_name;
Question: List the names of the games held in Paris.
SQL: SELECT games.games_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 city.city_name = 'Paris'
Database: olympics
Note: the competitors' names refer to full_name; the 2000 Summer refers to games_name = '2000 Summer';
Question: Provide the competitors' names who joined the 2000 Summer.
SQL: SELECT person.full_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 games.games_name = '2000 Summer'
Database: olympics
Note: in which city refers to city_name; the oldest refers to MAX(age);
Question: In which city was the game held where the oldest competitor participated?
SQL: SELECT city.city_name FROM games_competitor INNER JOIN games ON games_competitor.games_id = games.id INNER JOIN games_city ON games_competitor.games_id = games_city.games_id INNER JOIN city ON games_city.city_id = city.id ORDER BY games_competitor.age DESC LIMIT 1
Database: olympics
Note: name refers to full_name; the youngest refers to MIN(age);
Question: What is the name of the youngest competitor?
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: Tokyo refers to city_name = 'Tokyo';
Question: List down the games ID of games held in Tokyo.
SQL: SELECT games_city.games_id FROM games_city INNER JOIN city ON games_city.city_id = city.id WHERE city.city_name = 'Tokyo'
Database: olympics
Note: noc code refers to noc; the heaviest refers to MAX(weight);
Question: Give the NOC code and region name of the heaviest competitor.
SQL: SELECT noc_region.noc, 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 ORDER BY person.weight DESC LIMIT 1
Database: olympics
Note: year refers to games_year;
Question: In what year and season did Sohail Abbas compete?
SQL: SELECT games.games_year, games.season 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 = 'Sohail Abbas'
Database: olympics
Note: AVG(weight) where medal_name = 'Silver';
Question: What is the average weight of the competitors who won a silver medal?
SQL: SELECT avg(person.weight) 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.medal_name = 'Silver'
Database: olympics
Note: in which city refers to city_name; the 2004 Summer refers to games_name = '2004 Summer';
Question: In which city the 2004 Summer was 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 = '2004 Summer'
Database: olympics
Note: competitor who weighted 73 kg and 180 cm tall refers to person_id where height = 180 and weight = 73;
Question: What is the season of the game where a competitor who weighted 73 kg and 180 cm tall, participated?
SQL: SELECT DISTINCT games.season 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.height = 180 AND person.weight = 73
Database: olympics
Note: names of competitors refer to full_name; gold medal refers to medal_name = 'Gold';
Question: Provide the names of competitors who received a gold medal.
SQL: SELECT DISTINCT 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.medal_name = 'Gold'
Database: olympics
Note: AVG(height) where age BETWEEN 22 AND 28;
Question: Compute the average height of competitors whose age ranges from 22 to 28.
SQL: SELECT avg(person.height) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE games_competitor.age BETWEEN 22 AND 28
Database: olympics
Note: female competitors refer to person_id where gender = 'F'; from Iran refers to region_name = 'Iran';
Question: How many female competitors were from Iran?
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 = 'Iran' AND person.gender = 'F'
Database: olympics
Note: the tallest refers to MAX(height);
Question: Provide the age of the tallest competitor.
SQL: SELECT games_competitor.age FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id ORDER BY person.height DESC LIMIT 1
Database: olympics
Note: SUBTRACT(COUNT(weight > 70), COUNT(weight < 70)) where age < 24;
Question: Among the competitors with age ranges 24 and below, calculate the difference between the number of competitors who weighed greater than 70 kg and competitors who weighted less than 70 kg.
SQL: SELECT count(CASE WHEN person.weight > 70 THEN 1 ELSE NULL END) - count(CASE WHEN person.weight < 70 THEN 1 ELSE NULL END) FROM person INNER JOIN games_competitor ON person.id = games_competitor.person_id WHERE games_competitor.age < 24
Database: olympics
Note: DIVidE(COUNT(age = 28), COUNT(id)) as percentage where games_name = '2014 Winter';
Question: In the 2014 Winter game, what is the percentage of competitors who age 28 years old?
SQL: SELECT cast(count(CASE WHEN games_competitor.age = 28 THEN 1 END) AS REAL) * 100 / 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: males refer to gender = 'M'; height greater than 87% of the average height refers to height > MULTIPLY(AVG(height), 0.87);
Question: Among the males, list the region name of people with height greater than 87% of the average height of all people listed.
SQL: SELECT DISTINCT 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.gender = 'M' AND person.height * 100 > ( SELECT avg(height) FROM person WHERE gender = 'M' ) * 87
Database: address
Note: "ARECIBO" is the county; total number of households refer to sum(households);
Question: What is the total number of households in Arecibo county?
SQL: SELECT sum(zip_data.households) FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO'
Database: address
Note: "ARECIBO" is the county; highest average house value refers to Max(avg_house_value);
Question: Which residential area in Arecibo county has the highest average house value? Please give its zip_code.
SQL: SELECT zip_data.zip_code FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO' ORDER BY zip_data.avg_house_value DESC LIMIT 1
Database: address
Note: "ARECIBO" is the county; number of males refers to Sum(male_population);
Question: Please list the numbers of males in all the residential areas in Arecibo county.
SQL: SELECT sum(zip_data.male_population) FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO'
Database: address
Note: "Delaware" is a county; implement daylight savings refers to daylight_saving = 'Yes';
Question: Among all the residential areas in Delaware, how many of them implement daylight saving?
SQL: SELECT count(zip_data.zip_code) FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'DELAWARE' AND zip_data.daylight_savings = 'Yes'
Database: address
Note: "ARECIBO" is the county; highest white population refers to Max(white_population);
Question: Among all the residential areas in Arecibo county, what is the zip_code of the one with the highest white population?
SQL: SELECT zip_data.zip_code FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO' ORDER BY zip_data.white_population DESC LIMIT 1
Database: address
Note: highest average income per household refers to Max(avg_income_per_household);
Question: In which county is the residential area with the highest average income per household located?
SQL: SELECT country.county FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO' GROUP BY country.county ORDER BY zip_data.avg_income_per_household DESC LIMIT 1
Database: address
Note: implements daylight savings refers to daylight_savings = 'Yes';
Question: Please list the names of all the counties with at least one residential area that implements daylight saving.
SQL: SELECT DISTINCT country.county FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE zip_data.daylight_savings = 'Yes'
Database: address
Note: over 30 employees refers to employee > 30; 'HUNTINGDON' is the county;
Question: Please list the zip_codes of all the residential areas in Huntingdon county with over 30 employees.
SQL: SELECT DISTINCT zip_data.zip_code FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'HUNTINGDON' AND zip_data.employees > 30
Database: address
Note: "URB San Joaquin" is the bad_alias;
Question: Please list the Asian populations of all the residential areas with the bad alias "URB San Joaquin".
SQL: SELECT sum(zip_data.asian_population) FROM zip_data INNER JOIN avoid ON zip_data.zip_code = avoid.zip_code WHERE avoid.bad_alias = 'URB San Joaquin'
Database: address
Note: "Internal Revenue Service" is the bad_alias; in Eastern time zone refers to time_zone = 'Eastern';
Question: Among the residential areas with the bad alias "Internal Revenue Service", how many of them are in the Eastern time zone?
SQL: SELECT count(zip_data.zip_code) FROM zip_data INNER JOIN avoid ON zip_data.zip_code = avoid.zip_code WHERE avoid.bad_alias = 'Internal Revenue Service' AND zip_data.time_zone = 'Eastern'
Database: address
Note: highest average house value refers to Max(avg_house_value);
Question: What is the bad alias of the residential area with the highest average house value?
SQL: SELECT avoid.bad_alias FROM zip_data INNER JOIN avoid ON zip_data.zip_code = avoid.zip_code WHERE zip_data.avg_house_value = ( SELECT max(avg_house_value) FROM zip_data ) LIMIT 1
Database: address
Note: median female age of over 32 refers to median_female_age > 32;
Question: Please list the bad alias of all the residential areas with a median female age of over 32.
SQL: SELECT DISTINCT avoid.bad_alias FROM zip_data INNER JOIN avoid ON zip_data.zip_code = avoid.zip_code WHERE zip_data.female_median_age > 32
Database: address
Note: "ARECIBO" is the county; highest gender ration refers to Max(Divide (male_population, female_population));
Question: What is the highest gender ratio of the residential areas in Arecibo county?
SQL: SELECT cast(zip_data.male_population AS REAL) / zip_data.female_population FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO' AND zip_data.female_population <> 0 ORDER BY 1 DESC LIMIT 1
Database: address
Note: "ARECIBO" is the county; average median female age = Divide (Sum(median_female_age), Count(country));
Question: What is the average median female age of all the residential areas in the Arecibo county?
SQL: SELECT sum(zip_data.female_median_age) / count(zip_data.zip_code) FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'ARECIBO'
Database: address
Question: What is the area code of the city with the female median age over 32 years old?
SQL: SELECT area_code.area_code FROM area_code INNER JOIN zip_data ON area_code.zip_code = zip_data.zip_code WHERE zip_data.female_median_age > 32 GROUP BY area_code.area_code
Database: address
Note: "Hartford" is the city;
Question: What is the alias of the city called Hartford?
SQL: SELECT DISTINCT ALIAS.alias FROM zip_data INNER JOIN ALIAS ON zip_data.zip_code = ALIAS.zip_code WHERE zip_data.city = 'Hartford'
Database: address
Note: "Alabama" is the name;
Question: How many counties are there in Alabama?
SQL: SELECT count(country.county) FROM state INNER JOIN country ON state.abbreviation = country.state WHERE state.name = 'Alabama'
Database: address
Note: "New York" refers to state = 'NY' and name = 'New York'; 'Post Office' is the type;
Question: How many post offices are there in New York?
SQL: SELECT count(DISTINCT zip_data.zip_code) FROM state INNER JOIN zip_data ON state.abbreviation = zip_data.state WHERE state.abbreviation = 'NY' AND zip_data.type = 'Post Office'
Database: address
Note: precise location refers to latitude, longitude;
Question: What are the precise locations of the cities with an area code of 787?
SQL: SELECT zip_data.latitude, zip_data.longitude FROM area_code INNER JOIN zip_data ON area_code.zip_code = zip_data.zip_code WHERE area_code.area_code = '787' GROUP BY zip_data.latitude, zip_data.longitude
Database: address
Note: in California refers to name = 'California' and state = 'CA'; 'Community Post Office' is the type;
Question: In California, how many delivery receptacles are there in the community post office that has the highest number of delivery receptacles?
SQL: SELECT count(*) FROM state INNER JOIN zip_data ON state.abbreviation = zip_data.state WHERE state.abbreviation = 'CA' AND zip_data.type LIKE '%Community Post Office%' AND state.name = 'California' AND zip_data.state = 'CA'
Database: address
Note: highest number of females refers to Max(female_population);
Question: In which county can you find the city with the highest number of females?
SQL: SELECT country.county FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code GROUP BY country.county ORDER BY zip_data.female_population DESC LIMIT 1
Database: address
Note: postal point is not affiliated with any organization refers to division is null;
Question: What are the names of the states whose postal point is not affiliated with any organization?
SQL: SELECT DISTINCT state.name FROM zip_data INNER JOIN state ON zip_data.state = state.abbreviation WHERE zip_data.division IS NULL
Database: address
Note: "Allentown-Bethlehem-Easton, PA-NJ" is the cbsa_name; most populated city refers to Max(population_2020); difference = Subtract (population_2020, population_2011);
Question: What is the difference in the most populated city of Allentown-Bethlehem-Easton, PA-NJ in 2020 against its population in 2010?
SQL: SELECT zip_data.population_2020 - zip_data.population_2010 AS result_data FROM zip_data INNER JOIN cbsa ON zip_data.cbsa = cbsa.cbsa WHERE cbsa.cbsa_name = 'Allentown-Bethlehem-Easton, PA-NJ' ORDER BY zip_data.population_2020 DESC LIMIT 1
Database: address
Note: "NEW CASTLE" is the county; 'Delaware' is the name of state;
Question: List all the zip codes in the county of New Castle in Delaware.
SQL: SELECT DISTINCT country.zip_code FROM state INNER JOIN country ON state.abbreviation = country.state WHERE country.county = 'NEW CASTLE' AND state.name = 'Delaware'
Database: address
Note: state with highest monthly benefits payment for retired workers refers to Max(monthly_benefits_retired_workers);
Question: How many representatives are there in the state with the highest monthly benefit payments for retired workers?
SQL: SELECT count(congress.cognress_rep_id) FROM zip_data INNER JOIN state ON zip_data.state = state.abbreviation INNER JOIN congress ON state.abbreviation = congress.abbreviation ORDER BY zip_data.monthly_benefits_retired_workers DESC LIMIT 1
Database: address
Note: zero employee refers to employees = 0;
Question: In the state where Lisa Murkowski is the representative, how many cities have zero employees?
SQL: SELECT count(zip_data.city) FROM congress INNER JOIN state ON congress.abbreviation = state.abbreviation INNER JOIN zip_data ON state.abbreviation = zip_data.state WHERE congress.first_name = 'Murkowski' AND congress.last_name = 'Lisa' AND zip_data.employees = 0
Database: address
Note: city with highest asian population refers to Max(Sum(asian_population)); full name refers to first_name, last_name;
Question: What are the top 3 states with the highest Asian population? List the full names of all the representatives in the said states.
SQL: SELECT t.state, congress.first_name, congress.last_name FROM zip_data AS t INNER JOIN congress ON t.state = congress.abbreviation GROUP BY t.state ORDER BY sum(t.asian_population) DESC LIMIT 3
Database: address
Note: "OUTAGAMIE" is the county;
Question: Which state is Outagamie County in? Give the full name of the state.
SQL: SELECT DISTINCT state.name FROM country INNER JOIN state ON country.state = state.abbreviation WHERE country.county = 'OUTAGAMIE'
Database: address
Question: What party does the area with the zip code 91701 belong to?
SQL: SELECT congress.party FROM congress INNER JOIN state ON congress.abbreviation = state.abbreviation INNER JOIN zip_data ON state.abbreviation = zip_data.state WHERE zip_data.zip_code = 91701 GROUP BY congress.party
Database: address
Note: "NEW HAVEN" is the county; male refers to male_population;
Question: How many males are there in New Haven County's residential areas?
SQL: SELECT sum(zip_data.male_population) FROM zip_data INNER JOIN country ON zip_data.zip_code = country.zip_code WHERE country.county = 'NEW HAVEN'
Database: address
Note: coordinates refers to latitude, longitude; latitude = '18.090875; longitude = '-66.867756';
Question: Show the alias for the county at coordinate (18.090875, -66.867756).
SQL: SELECT ALIAS.alias FROM zip_data INNER JOIN ALIAS ON zip_data.zip_code = ALIAS.zip_code WHERE zip_data.latitude = 18.090875 AND zip_data.longitude = -66.867756
Database: address
Note: city with most elders refers to Max(over_65);
Question: For the city with the most elders, what's its area code?
SQL: SELECT area_code.area_code FROM zip_data INNER JOIN area_code ON zip_data.zip_code = area_code.zip_code GROUP BY area_code.area_code ORDER BY zip_data.over_65 DESC LIMIT 1
Database: address
Question: For the county represented by Thompson Bennie G, how many bad aliases does it have?
SQL: SELECT count(DISTINCT avoid.bad_alias) FROM zip_congress INNER JOIN avoid ON zip_congress.zip_code = avoid.zip_code INNER JOIN congress ON zip_congress.district = congress.cognress_rep_id WHERE congress.first_name = 'Thompson' AND congress.last_name = 'Bennie G'