input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] historical : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] primary_key bioguide_previous_id [ TEXT ] birthday_bio [ TEXT ] cspan_id [ TEXT ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_alternate_id [ TEXT ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ TEXT ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ TEXT ] votesmart_id [ TEXT ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: What is the ratio between famous current legislators and famous historical legislators? [/INST]
SELECT CAST(COUNT(CASE WHEN wikipedia_id IS NOT NULL THEN bioguide_id ELSE 0 END) AS REAL) * 100 / ( SELECT COUNT(CASE WHEN wikipedia_id IS NOT NULL THEN bioguide_id ELSE 0 END) FROM historical ) FROM current;
[INST] Here is a database schema: historical : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] primary_key bioguide_previous_id [ TEXT ] birthday_bio [ TEXT ] cspan_id [ TEXT ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_alternate_id [ TEXT ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ TEXT ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ TEXT ] votesmart_id [ TEXT ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: How many Catholic legislators do not have an account on ballotpedia.org? [/INST]
SELECT COUNT(bioguide_id) FROM historical WHERE religion_bio = 'Catholic' AND ballotpedia_id IS NULL;
[INST] Here is a database schema: historical : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] primary_key bioguide_previous_id [ TEXT ] birthday_bio [ TEXT ] cspan_id [ TEXT ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_alternate_id [ TEXT ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ TEXT ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ TEXT ] votesmart_id [ TEXT ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: What are the full names of the non-google female entity legislators that have not been registered in Federal Election Commission data? [/INST]
SELECT first_name, last_name FROM historical WHERE gender_bio = 'F' AND google_entity_id_id IS NULL AND fec_id IS NULL;
[INST] Here is a database schema: historical : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] primary_key bioguide_previous_id [ TEXT ] birthday_bio [ TEXT ] cspan_id [ TEXT ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_alternate_id [ TEXT ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ TEXT ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ TEXT ] votesmart_id [ TEXT ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: What is the full name of the oldest legislator? [/INST]
SELECT first_name, last_name FROM historical ORDER BY birthday_bio LIMIT 1;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: Among all the current legislators born after the year 1960, how many of them are not google entities? [/INST]
SELECT COUNT(*) FROM current WHERE strftime('%Y', birthday_bio) > '1960' AND google_entity_id_id IS NULL;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: Please list the official full names of all the current legislators who have served in the U.S. House. [/INST]
SELECT official_full_name FROM current WHERE house_history_id IS NOT NULL;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: How many current legislators have both accounts on both VoteView.com and maplight.org? [/INST]
SELECT COUNT(*) FROM current WHERE icpsr_id IS NOT NULL AND maplight_id IS NOT NULL;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: Among all the current female legislators, how many of them have attended in Senate roll call votes? [/INST]
SELECT COUNT(lis_id) FROM current WHERE gender_bio = 'F' AND lis_id IS NOT NULL;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: What is the religion of current legislator Sherrod Brown? [/INST]
SELECT religion_bio FROM current WHERE official_full_name = 'Sherrod Brown';
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: What is the religion with the most occurrrence of the current legislators? [/INST]
SELECT religion_bio FROM current GROUP BY religion_bio ORDER BY COUNT(religion_bio) DESC LIMIT 1;
[INST] Here is a database schema: current : ballotpedia_id [ TEXT ] bioguide_id [ TEXT ] birthday_bio [ DATE ] cspan_id [ REAL ] fec_id [ TEXT ] first_name [ TEXT ] gender_bio [ TEXT ] google_entity_id_id [ TEXT ] govtrack_id [ INTEGER ] house_history_id [ REAL ] icpsr_id [ REAL ] last_name [ TEXT ] lis_id [ TEXT ] maplight_id [ REAL ] middle_name [ TEXT ] nickname_name [ TEXT ] official_full_name [ TEXT ] opensecrets_id [ TEXT ] religion_bio [ TEXT ] suffix_name [ TEXT ] thomas_id [ INTEGER ] votesmart_id [ REAL ] wikidata_id [ TEXT ] wikipedia_id [ TEXT ] Please write me a SQL statement that answers the following question: How many of the legislators are female? [/INST]
SELECT COUNT(gender_bio) FROM current WHERE gender_bio = 'F';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Please list the names of all the Olympic games that John Aalberg has taken part in. [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'John Aalberg';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What was the name of the Olympic game that John Aalberg took part in when he was 31? [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'John Aalberg' AND T2.age = 31;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: When John Aalberg took part in the 1994 Winter Olympic Game, how old was he? [/INST]
SELECT T2.age FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'John Aalberg' AND T1.games_name = '1994 Winter';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many Olympic competitors are from Finland? [/INST]
SELECT COUNT(T1.person_id) FROM person_region AS T1 INNER JOIN noc_region AS T2 ON T1.region_id = T2.id WHERE T2.region_name = 'Finland';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Please list the names of all the Olympic competitors from Finland. [/INST]
SELECT T3.full_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Finland';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: The Olympic competitor John Aalberg is from which region? [/INST]
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'John Aalberg';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: What is the NOC code of the region where the tallest male Olympic competitor is from? [/INST]
SELECT T1.noc FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.gender = 'M' ORDER BY T3.height DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Among all the Olympic competitors from Finland, how many of them are female? [/INST]
SELECT COUNT(T3.id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Finland' AND T3.gender = 'F';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: In which city was the 1992 Summer Olympic Games held? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name = '1992 Summer';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: Please list the names of the Olympic games that were held in London. [/INST]
SELECT T3.games_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'London';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: In which year did London hold its earliest Olympic game? [/INST]
SELECT T3.games_year FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'London' ORDER BY T3.games_year LIMIT 1;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: For how many times has London held the Olympic games? [/INST]
SELECT COUNT(T1.games_id) FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T2.city_name = 'London';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: What is the average height of the male Olympic competitors from Finland? [/INST]
SELECT AVG(T3.height) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Finland' AND T3.gender = 'M';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Among the competitors of the 1994 Winter Olympic Game, what is the percentage of those from Finland? [/INST]
SELECT CAST(COUNT(CASE WHEN T5.region_name = 'Finland' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T3.id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id INNER JOIN person_region AS T4 ON T3.id = T4.person_id INNER JOIN noc_region AS T5 ON T4.region_id = T5.id WHERE T1.games_name = '1994 Winter';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: Which sport does the event "Shooting Women's Trap" belong to? [/INST]
SELECT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T2.event_name LIKE 'Shooting Women%s Trap';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: Which city was the host of 1936 Winter Olympic Games? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name = '1936 Winter';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: How many Olympic Games has London hosted? [/INST]
SELECT COUNT(T3.id) FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'London';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: Tell the number of swimming related events. [/INST]
SELECT COUNT(T2.event_name) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Swimming';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: For Peter Kohnke, show the name of his/her region. [/INST]
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Peter Kohnke';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Which game has Jessica Carolina Aguilera Aguilera participated in? Give the id of the game. [/INST]
SELECT T2.games_id FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Jessica Carolina Aguilera Aguilera';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: Show the name of the sport with the most events. [/INST]
SELECT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id GROUP BY T1.sport_name ORDER BY COUNT(T2.event_name) DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Give the name of the tallest athlete from Sweden. [/INST]
SELECT T3.full_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Sweden' ORDER BY T3.height DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many athletes in the database are from Guatemala? [/INST]
SELECT COUNT(T1.person_id) FROM person_region AS T1 INNER JOIN noc_region AS T2 ON T1.region_id = T2.id WHERE T2.region_name = 'Guatemala';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Who has participated in the most Olympic Games in the database? [/INST]
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id GROUP BY T2.person_id ORDER BY COUNT(T2.person_id) DESC LIMIT 1;
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Show the name of the competitor id 90991. [/INST]
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.id = 90991;
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: How many competitor ids does Martina Kohlov have? [/INST]
SELECT COUNT(T2.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Martina Kohlov';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the bmi of the competitor id 147420. [/INST]
SELECT CAST(T1.weight AS REAL) / (T1.height * T1.height) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T2.id = 147420;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: What is the percentage of male athletes from Estonia? [/INST]
SELECT CAST(COUNT(CASE WHEN T3.gender = 'M' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Estonia';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Who is the youngest person who participated in the Olympics? [/INST]
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T2.age LIMIT 1;
[INST] Here is a database schema: games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many 24 years old competitors competed in Men's Basketball? [/INST]
SELECT COUNT(T2.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id INNER JOIN event AS T3 ON T1.event_id = T3.id WHERE T3.event_name LIKE 'Basketball Men%s Basketball' AND T2.age = 24;
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: What are the names of the events under Art Competitions? [/INST]
SELECT T2.event_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Art Competitions';
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many gold medals does Henk Jan Zwolle have? [/INST]
SELECT COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T1.full_name = 'Henk Jan Zwolle' AND T4.medal_name = 'Gold';
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: What is the name of the event where competitors received the most gold medals? [/INST]
SELECT T2.event_name FROM competitor_event AS T1 INNER JOIN event AS T2 ON T1.event_id = T2.id INNER JOIN medal AS T3 ON T1.medal_id = T3.id WHERE T3.medal_name = 'Gold' GROUP BY T2.id ORDER BY COUNT(T1.event_id) DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many athletes are from Australia? [/INST]
SELECT COUNT(T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id WHERE T1.region_name = 'Australia';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: Which cities hosted at least 3 Olympic games? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id GROUP BY T2.id HAVING COUNT(T1.games_id) >= 3;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: How many Summer games were held in Stockholm? [/INST]
SELECT COUNT(T3.id) FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T2.city_name = 'Stockholm' AND T3.season = 'Summer';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Which region do most of the athletes are from? [/INST]
SELECT T2.region_name FROM person_region AS T1 INNER JOIN noc_region AS T2 ON T1.region_id = T2.id GROUP BY T2.region_name ORDER BY COUNT(T1.person_id) DESC LIMIT 1;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: Where was the first Olympic game held? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id ORDER BY T3.games_year LIMIT 1;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the game in which the oldest Olympian has ever participated? [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id ORDER BY T2.age LIMIT 1;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: How many athletes competed in the 1992 Summer Olympics? [/INST]
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '1928 Summer';
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many Olympic events did Michael Phelps II join in total? Find the percentage of the events where he won a gold medal. [/INST]
SELECT COUNT(T3.event_id) , CAST(COUNT(CASE WHEN T4.id = '1' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T4.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T1.full_name = 'Michael Fred Phelps, II';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following 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. [/INST]
SELECT P1 , ( SELECT MAX(P2) - MIN(P2) FROM ( SELECT COUNT(T2.person_id) AS P2 FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name IN ('1988 Winter', '1988 Summer') GROUP BY T1.season ) ORDER BY P2 DESC LIMIT 1 ) FROM ( SELECT T1.season AS P1, COUNT(T2.person_id) AS P2 FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name IN ('1988 Winter', '1988 Summer') GROUP BY T1.season ) ORDER BY P2 DESC LIMIT 1;
[INST] Here is a database schema: games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What age of the competitors is the most numerous? [/INST]
SELECT age FROM games_competitor GROUP BY age ORDER BY COUNT(person_id) DESC LIMIT 1;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] Please write me a SQL statement that answers the following question: In which cities beginning with the letter M have the Olympic Games been held? [/INST]
SELECT city_name FROM city WHERE city_name LIKE 'M%';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: In which cities were the 1976 winter and summer games held? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name IN ('1976 Summer', '1976 Winter');
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: What was the medal that Coleen Dufresne got? [/INST]
SELECT T4.medal_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T1.full_name = 'Coleen Dufresne (-Stewner)';
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: What is the name of the competitor who has won the most medals? [/INST]
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN medal AS T4 ON T3.medal_id = T4.id WHERE T4.id != 4 GROUP BY T1.full_name ORDER BY COUNT(T4.id) DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Where is competitor Estelle Nze Minko from? [/INST]
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Estelle Nze Minko';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: What is the name of all the sports Chin Eei Hui has competed in? [/INST]
SELECT DISTINCT T1.sport_name FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id INNER JOIN competitor_event AS T3 ON T2.id = T3.event_id INNER JOIN games_competitor AS T4 ON T3.competitor_id = T4.id INNER JOIN person AS T5 ON T4.person_id = T5.id WHERE T5.full_name = 'Chin Eei Hui';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What is the name of the oldest person who participated in the Olympic Games? [/INST]
SELECT T1.full_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id ORDER BY T2.age DESC LIMIT 1;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: In which Olympic Games have the largest number of women participation? [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.gender = 'F' GROUP BY T1.games_name ORDER BY COUNT(T2.person_id) DESC LIMIT 1;
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many males from Belgium have participated in an Olympic Games? [/INST]
SELECT COUNT(T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Belgium' AND T3.gender = 'M';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: How many persons participated in the Sapporo Olympics? [/INST]
SELECT COUNT(T1.person_id) FROM games_competitor AS T1 INNER JOIN games_city AS T2 ON T1.games_id = T2.games_id INNER JOIN city AS T3 ON T2.city_id = T3.id WHERE T3.city_name = 'Sapporo';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: In which Olympic Games has Morten Aleksander Djupvik participated? [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Morten Aleksander Djupvik';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many persons in total have participated in 12 meter Mixed Sailing competitions? [/INST]
SELECT COUNT(T1.competitor_id) FROM competitor_event AS T1 INNER JOIN event AS T2 ON T1.event_id = T2.id INNER JOIN sport AS T3 ON T2.sport_id = T3.id WHERE T2.event_name = 'Sailing Mixed 12 metres';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: How many different events are there of Modern Pentathlon? [/INST]
SELECT COUNT(DISTINCT T2.event_name) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id WHERE T1.sport_name = 'Modern Pentathlon';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: Calculate the percentage of women who have participated in Equestrianism Mixed Three-Day Event, Individual. [/INST]
SELECT CAST(COUNT(CASE WHEN T1.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN event AS T4 ON T3.event_id = T4.id WHERE T4.event_name = 'Equestrianism Mixed Three-Day Event, Individual';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Calculate the average age of the persons who participated in the 1992 Summer Games. [/INST]
SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.games_name = '1992 Summer';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] Please write me a SQL statement that answers the following question: List out years that only have summer games. [/INST]
SELECT games_year FROM games WHERE season != 'Winter' GROUP BY games_year HAVING COUNT(season) = 1;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] Please write me a SQL statement that answers the following question: How many Olympics games were held during the 90s? [/INST]
SELECT COUNT(games_year) FROM games WHERE games_year BETWEEN '1990' AND '1999';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: How many athletes participated in the 2014 Winter Olympics? [/INST]
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2014 Winter';
[INST] Here is a database schema: games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many athletes from region 151 have won a medal? [/INST]
SELECT COUNT(T3.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id INNER JOIN person_region AS T3 ON T2.person_id = T3.person_id WHERE T3.region_id = 151 AND T1.medal_id != 4;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many athlete from China participate in the 2016 Summer Olympics? [/INST]
SELECT COUNT(T3.id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id INNER JOIN person_region AS T4 ON T3.id = T4.person_id INNER JOIN noc_region AS T5 ON T4.region_id = T5.id WHERE T1.games_name = '2016 Summer' AND T5.region_name = 'China';
[INST] Here is a database schema: event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many gold medals were given to the winners in the Ice Hockey Men's Ice Hockey event? [/INST]
SELECT COUNT(T2.competitor_id) FROM event AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.event_id WHERE T1.event_name LIKE 'Ice Hockey Men%s Ice Hockey' AND T2.medal_id = 1;
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: Which region has the highest medal number? [/INST]
SELECT T5.region_name FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN person_region AS T4 ON T3.person_id = T4.person_id INNER JOIN noc_region AS T5 ON T4.region_id = T5.id WHERE T1.id != 4 GROUP BY T5.region_name ORDER BY COUNT(T2.competitor_id) DESC LIMIT 1;
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: List out all the gold medalist winners in cycling sport. [/INST]
SELECT DISTINCT T5.full_name FROM event AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.event_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN sport AS T4 ON T1.sport_id = T4.id INNER JOIN person AS T5 ON T3.person_id = T5.id WHERE T4.sport_name = 'Cycling' AND T2.medal_id = 1;
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: List out all the medals won by Lee Chong Wei. [/INST]
SELECT DISTINCT T1.medal_name FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN person AS T4 ON T3.person_id = T4.id WHERE T4.full_name = 'Lee Chong Wei' AND T2.medal_id <> 4;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What is the percentage of female athletes below 20s who participated in the 2002 Winter Olympic? [/INST]
SELECT CAST(COUNT(CASE WHEN T3.gender = 'F' THEN 1 ELSE NULL END) AS REAL) * 100 / COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.games_name = '2002 Winter' AND T2.age < 20;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What is the ratio male to female athletes in the 2012 Summer Olympic? [/INST]
SELECT CAST(COUNT(CASE WHEN T3.gender = 'M' THEN 1 ELSE NULL END) AS REAL) / COUNT(CASE WHEN T3.gender = 'F' THEN 1 ELSE NULL END) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.games_name = '2012 Summer';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Which summer Olympic have the highest and lowest number of participants? [/INST]
SELECT ( SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.season = 'Summer' GROUP BY T1.games_year ORDER BY COUNT(T2.person_id) DESC LIMIT 1 ) AS HIGHEST , ( SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.season = 'Summer' GROUP BY T1.games_year ORDER BY COUNT(T2.person_id) LIMIT 1 ) AS LOWEST;
[INST] Here is a database schema: medal : id [ INTEGER ] primary_key medal_name [ TEXT ] noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many athletes from Malaysia have won a medal? [/INST]
SELECT COUNT(T3.person_id) FROM medal AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.medal_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN person_region AS T4 ON T3.person_id = T4.person_id INNER JOIN noc_region AS T5 ON T4.region_id = T5.id WHERE T5.region_name = 'Malaysia' AND T1.id != 4;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many athletes playing in Canoeing fall into overweight BMI category in the 2008 Summer games? [/INST]
SELECT COUNT(T5.id) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id INNER JOIN competitor_event AS T3 ON T2.id = T3.event_id INNER JOIN games_competitor AS T4 ON T3.competitor_id = T4.id INNER JOIN person AS T5 ON T4.person_id = T5.id INNER JOIN games AS T6 ON T4.games_id = T6.id WHERE T1.sport_name = 'Canoeing' AND T6.games_name = '2008 Summer' AND T5.weight * 10000.0 / (T5.height * T5.height) BETWEEN 25.0 AND 30;
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] sport : id [ INTEGER ] primary_key sport_name [ TEXT ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: What is the average height of male athletes playing basketball sport? [/INST]
SELECT AVG(T5.height) FROM sport AS T1 INNER JOIN event AS T2 ON T1.id = T2.sport_id INNER JOIN competitor_event AS T3 ON T2.id = T3.event_id INNER JOIN games_competitor AS T4 ON T3.competitor_id = T4.id INNER JOIN person AS T5 ON T4.person_id = T5.id WHERE T1.sport_name = 'Basketball' AND T5.gender = 'M';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many female athletes are from the Philippines? [/INST]
SELECT COUNT(T2.person_id) FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T1.region_name = 'Philippines' AND T3.gender = 'F';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: Which region is Yao Ming from? [/INST]
SELECT T1.region_name FROM noc_region AS T1 INNER JOIN person_region AS T2 ON T1.id = T2.region_id INNER JOIN person AS T3 ON T2.person_id = T3.id WHERE T3.full_name = 'Yao Ming';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: At what age did Michael Fred Phelps, II join the Olympics? [/INST]
SELECT T2.age FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id WHERE T1.full_name = 'Michael Fred Phelps, II' ORDER BY T2.age LIMIT 1;
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: How many athletes are there in the region where Clara Hughes is from? [/INST]
SELECT COUNT(person_id) FROM person_region WHERE region_id = ( SELECT T1.region_id FROM person_region AS T1 INNER JOIN person AS T2 ON T1.person_id = T2.id WHERE T2.full_name = 'Clara Hughes' );
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many Men's 200 Metres Freestyle events did Ian James Thorpe compete in? [/INST]
SELECT COUNT(T1.id) FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN competitor_event AS T3 ON T2.id = T3.competitor_id INNER JOIN event AS T4 ON T3.event_id = T4.id WHERE T1.full_name = 'Ian James Thorpe' AND T4.event_name LIKE 'Swimming Men%s 200 metres Freestyle';
[INST] Here is a database schema: person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many times was Larysa Semenivna Latynina (Diriy-) declared as champion in Gymnastics Women's Individual All-Around? [/INST]
SELECT COUNT(T1.id) FROM event AS T1 INNER JOIN competitor_event AS T2 ON T1.id = T2.event_id INNER JOIN games_competitor AS T3 ON T2.competitor_id = T3.id INNER JOIN person AS T4 ON T3.person_id = T4.id WHERE T4.full_name = 'Larysa Semenivna Latynina (Diriy-)' AND T1.event_name LIKE 'Gymnastics Women%s Individual All-Around' AND T2.medal_id = 1;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id person : id [ INTEGER ] primary_key full_name [ TEXT ] gender [ TEXT ] height [ INTEGER ] weight [ INTEGER ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: What are the names of the cities where Carl Lewis Borack competed? [/INST]
SELECT T4.city_name FROM person AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.person_id INNER JOIN games_city AS T3 ON T2.games_id = T3.games_id INNER JOIN city AS T4 ON T3.city_id = T4.id WHERE T1.full_name = 'Carl Lewis Borack';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: How many Olympic games were held in London? [/INST]
SELECT COUNT(T1.games_id) FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id WHERE T2.city_name = 'London';
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id Please write me a SQL statement that answers the following question: Which city was the 1992 Summer Olympic held? [/INST]
SELECT T2.city_name FROM games_city AS T1 INNER JOIN city AS T2 ON T1.city_id = T2.id INNER JOIN games AS T3 ON T1.games_id = T3.id WHERE T3.games_name = '1992 Summer';
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: How many athletes over the age of 59 competed in the 2016 Summer Olympics? [/INST]
SELECT COUNT(T2.person_id) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id WHERE T1.games_name = '2016 Summer' AND T2.age > 59;
[INST] Here is a database schema: city : id [ INTEGER ] primary_key city_name [ TEXT ] games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] games_city : games_id [ INTEGER ] games_city.games_id = games.id city_id [ INTEGER ] games_city.city_id = city.id games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] Please write me a SQL statement that answers the following question: Among the Olympic games held in Los Angeles, what is the name of the Olympic game that has the most number of competitors? [/INST]
SELECT T1.games_name FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN games_city AS T3 ON T2.games_id = T3.games_id INNER JOIN city AS T4 ON T3.city_id = T4.id WHERE T4.city_name = 'Los Angeles' GROUP BY T1.id ORDER BY COUNT(T2.person_id) DESC LIMIT 1;
[INST] Here is a database schema: games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] competitor_event : event_id [ INTEGER ] competitor_event.event_id = event.id competitor_id [ INTEGER ] competitor_event.competitor_id = games_competitor.id medal_id [ INTEGER ] competitor_event.medal_id = medal.id Please write me a SQL statement that answers the following question: How many 10-year old athletes participated in the Gymnastics Men's Parallel Bars, Teams event? [/INST]
SELECT COUNT(T2.person_id) FROM competitor_event AS T1 INNER JOIN games_competitor AS T2 ON T1.competitor_id = T2.id INNER JOIN event AS T3 ON T1.event_id = T3.id WHERE T3.event_name LIKE 'Gymnastics Men%s Parallel Bars, Teams' AND T2.age = 10;
[INST] Here is a database schema: games : id [ INTEGER ] primary_key games_year [ INTEGER ] games_name [ TEXT ] season [ TEXT ] noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] games_competitor : id [ INTEGER ] primary_key games_id [ INTEGER ] games_competitor.games_id = games.id person_id [ INTEGER ] games_competitor.person_id = person.id age [ INTEGER ] person_region : person_id [ INTEGER ] person_region.person_id = person.id region_id [ INTEGER ] person_region.region_id = noc_region.id Please write me a SQL statement that answers the following question: What is the average age of the athletes from the United States of America who competed in the 2016 Summer Olympics? [/INST]
SELECT AVG(T2.age) FROM games AS T1 INNER JOIN games_competitor AS T2 ON T1.id = T2.games_id INNER JOIN person_region AS T3 ON T2.person_id = T3.person_id INNER JOIN noc_region AS T4 ON T3.region_id = T4.id WHERE T1.games_name = '2016 Summer' AND T4.region_name = 'USA';
[INST] Here is a database schema: noc_region : id [ INTEGER ] primary_key noc [ TEXT ] region_name [ TEXT ] Please write me a SQL statement that answers the following question: Which region does the NOC code "COL" stand for? [/INST]
SELECT region_name FROM noc_region WHERE noc = 'COL';
[INST] Here is a database schema: sport : id [ INTEGER ] primary_key sport_name [ TEXT ] Please write me a SQL statement that answers the following question: State the name of sport id 19. [/INST]
SELECT sport_name FROM sport WHERE id = 19;
[INST] Here is a database schema: event : id [ INTEGER ] primary_key sport_id [ INTEGER ] event.sport_id = sport.id event_name [ TEXT ] Please write me a SQL statement that answers the following question: Give the id of the event "Shooting Mixed Skeet". [/INST]
SELECT id FROM event WHERE event_name = 'Shooting Mixed Skeet';