input
stringlengths
193
2.69k
output
stringlengths
24
744
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: Who is the oldest among all the casts and crews? [/INST]
SELECT name FROM Person ORDER BY birthdate ASC LIMIT 1;
[INST] Here is a database schema: Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: What are the episodes Oscar Cervantes is credited with? [/INST]
SELECT episode_id FROM Credit WHERE person = 'Oscar Cervantes' AND credited = 'true';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: What are the roles of the cast and crew from countries other than the USA? [/INST]
SELECT T2.role FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T1.birth_country != 'USA';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many 1 star ratings are there in the worst rated episode of the season? [/INST]
SELECT COUNT(*) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = 1 ORDER BY T1.rating LIMIT 1;
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: Which character did the "Outstanding Voice-Over Performance" winner voice? [/INST]
SELECT DISTINCT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.award = 'Outstanding Voice-Over Performance' AND T1.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: What is the summary of the episode in which Emily Blunt is featured in? [/INST]
SELECT T1.summary FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Emily Blunt';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: Who did "The Tiny Canadian" play as in the show? [/INST]
SELECT T2.role FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T1.nickname = 'The Tiny Canadian';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Among the episodes with an award nominee or winner, which has the highest percent of 5 star votes? [/INST]
SELECT T1.episode_id FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = 5 ORDER BY T2.percent DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: What is the credited cast for the episode "In the Name of the Grandfather"? [/INST]
SELECT DISTINCT T2.person FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'In the Name of the Grandfather' AND T2.category = 'Cast' AND T2.credited = 'true';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: List all of the award winners' birth dates. [/INST]
SELECT T1.birthdate FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.result = 'Winner';
[INST] Here is a database schema: Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Who is the writer for the episode with the most 10 star votes? [/INST]
SELECT T1.person FROM Credit AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T1.role = 'Writer' AND T2.stars = 10 GROUP BY T1.person ORDER BY COUNT(*) DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: What award did the episode that aired on 11/30/2008 win? [/INST]
SELECT T1.award FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.result = 'Winner' AND T2.air_date = '2008-11-30';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: List all of the information about the music department's casts and crews. [/INST]
SELECT DISTINCT person, name, birthdate, birth_name, birth_place , birth_region, birth_country, height_meters, nickname FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.category = 'Music Department';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: What are the keywords for episode 426 of the series? [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.number_in_series = 426;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What are the titles of the episodes that have received more 7-star votes than the season average? [/INST]
SELECT DISTINCT T1.episode_id FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = 7 AND T2.votes > 0.7 * ( SELECT CAST(COUNT(votes) AS REAL) / COUNT(CASE WHEN stars = 7 THEN 1 ELSE 0 END) FROM Vote );
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: What percentage of votes are from the nominated episodes? [/INST]
SELECT CAST(SUM(CASE WHEN T1.result = 'Nominee' THEN T2.votes ELSE 0 END) AS REAL) * 100 / SUM(T2.votes) FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: List down person's name who has nickname. [/INST]
SELECT name FROM Person WHERE nickname IS NOT NULL;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: Which country has the tallest person in the crew? [/INST]
SELECT birth_country FROM Person ORDER BY height_meters DESC LIMIT 1;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: What is the average height of people from USA? [/INST]
SELECT AVG(height_meters) FROM Person WHERE birth_country = 'USA';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of people who were born after 1970 and from California. [/INST]
SELECT CAST(SUM(CASE WHEN birth_region = 'California' AND SUBSTR(birthdate, 1, 4) > '1970' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(birthdate) FROM Person;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: How many people were not born in Connecticut, USA? [/INST]
SELECT COUNT(name) FROM Person WHERE birth_region != 'Connecticut' AND birth_country != 'USA';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Please write me a SQL statement that answers the following question: List down the title of episode S20-E1, S20-E2 & S20-E3. [/INST]
SELECT title FROM Episode WHERE episode_id IN ('S20-E1', 'S20-E2', 'S20-E3');
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Please write me a SQL statement that answers the following question: Write down the website address which stores the episode image of episode 5. [/INST]
SELECT episode_image FROM Episode WHERE episode = 5;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Please write me a SQL statement that answers the following question: State the number of votes for episode with rating of 7 and above. [/INST]
SELECT votes FROM Episode WHERE rating > 7;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: How many title's crew members are working from Casting Department? [/INST]
SELECT COUNT(*) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.category = 'Casting Department';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: How many additional timers were born in USA? [/INST]
SELECT COUNT(*) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.role = 'additional timer' AND T1.birth_country = 'USA';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: How many people who were born after 1970 are animation executive producer? [/INST]
SELECT COUNT(*) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE STRFTIME(T1.birthdate) > '1970' AND T2.role = 'animation executive producer';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: Write down the summary of episode whereby it has crew members that are not included in the credit list. [/INST]
SELECT T1.summary FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.credited = 'false';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: List down the rating of episodes that were produced by Jason Bikowski. [/INST]
SELECT T1.rating FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Jason Bikowski';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: What is the average heights of crew members from Animation Department? [/INST]
SELECT AVG(T1.height_meters) FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.name = T2.person WHERE T2.category = 'Animation Department';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: What is the character that won the award in Primetime Emmy 2009? [/INST]
SELECT DISTINCT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.award_category = 'Primetime Emmy' AND T1.year = 2009 AND T1.result = 'Winner';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: What are the characters that were nominated for Primetime Emmy Award from 2009 to 2010 but did not win? [/INST]
SELECT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.award_category = 'Primetime Emmy' AND T1.year BETWEEN 2009 AND 2010 AND T1.result != 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the total votes of episodes that Adam Kuhlman had involved. [/INST]
SELECT SUM(T1.votes) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Adam Kuhlman';
[INST] Here is a database schema: Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: List down the keyword and crew member's name for episode id S20-E1. [/INST]
SELECT T1.keyword, T2.person FROM Keyword AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode_id = 'S20-E1';
[INST] Here is a database schema: Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the keyword for episodes with stars score of 10 at 30% and above? [/INST]
SELECT T1.keyword FROM Keyword AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 AND T2.percent > 29;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the percentage of star score 5 that was collected by title "Sex, Pies and Idiot Scrapes"? [/INST]
SELECT CAST(SUM(CASE WHEN T2.stars = 5 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'Sex, Pies and Idiot Scrapes';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: Please check is "limbo dancing" the keyword for title "Dangerous Curves"? [/INST]
SELECT CASE WHEN T2.Keyword = 'limbo dancing' THEN 'Yes' ELSE 'No' END AS result FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Which title is the winner of Best International TV Series in 2017? [/INST]
SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award = 'Best International TV Series' AND SUBSTR(T1.year, 1, 4) = '2017';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: Write down all the keywords for winner of "WGA Award (TV)" award. [/INST]
SELECT T2.keyword FROM Award AS T1 INNER JOIN Keyword AS T2 ON T2.episode_id = T1.episode_id WHERE T1.award_category = 'WGA Award (TV)';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: State the birth place of co-executive producer for nominee of "Outstanding Animated Program (For Programming Less Than One Hour)" award. [/INST]
SELECT T1.birth_place FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.award = 'Outstanding Animated Program (For Programming Less Than One Hour)' AND T2.role = 'co-executive producer';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Sum up the votes from star 1 to 5 for all of the contestants in Blimp Award. [/INST]
SELECT T2.stars, SUM(T2.stars) FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.award_category = 'Blimp Award' AND T2.stars BETWEEN 1 AND 5 GROUP BY T2.stars;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the total rating of winners in OFTA Television Award and WGA Award (TV). [/INST]
SELECT SUM(T2.rating) FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award_category IN ('Jupiter Award ', 'WGA Award (TV)');
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Out of the rating of 6.8 scored by title "No Loan Again, Naturally", how many percent of it consists of scores 5 to 10? [/INST]
SELECT SUM(T2.percent) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'No Loan Again, Naturally' AND T1.rating = 6.8 AND T2.stars BETWEEN 5 AND 10;
[INST] Here is a database schema: Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: How many episodes have the star score greater than 8? [/INST]
SELECT COUNT(DISTINCT episode_id) FROM Vote WHERE stars > 8;
[INST] Here is a database schema: Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Which episode has the highest number of vote of the star score? [/INST]
SELECT episode_id FROM Vote ORDER BY votes DESC LIMIT 1;
[INST] Here is a database schema: Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: How many episodes have the keyword "2d animation"? [/INST]
SELECT COUNT(episode_id) FROM Keyword WHERE keyword = '2d animation';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Name the organization which hold the award id 328. [/INST]
SELECT organization FROM Award WHERE award_id = 328;
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: How many awards had been held in 2009? [/INST]
SELECT COUNT(award_id) FROM Award WHERE SUBSTR(year, 1, 4) = '2009';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: How many awards classified as "Primetime Emmy" category? [/INST]
SELECT COUNT(award_id) FROM Award WHERE award_category = 'Primetime Emmy';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: List out the birth name of crews who are co-executive producer and higher than 1.60 meters. [/INST]
SELECT T1.birth_name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.role = 'co-executive producer' AND T1.height_meters > 1.60;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of the nominees who were born in USA. [/INST]
SELECT CAST(SUM(CASE WHEN T1.birth_country = 'USA' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.result = 'Nominee';
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Calculate the percentage of the winners who are higher than 1.75 meters. [/INST]
SELECT CAST(SUM(CASE WHEN T1.height_meters > 1.75 THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List out the title of episodes which have star score of 2. [/INST]
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars = 2;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List out the star scores of episode which has title of "How the Test Was Won". [/INST]
SELECT T2.stars FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.title = 'How the Test Was Won';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Among the episodes which have star score greater than 5, how many episodes have air date in 2008? [/INST]
SELECT COUNT(DISTINCT T2.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE strftime('%Y', T1.air_date) = '2008' AND T2.stars > 5;
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: List out the names of the awarded character in the awards held in 2009. [/INST]
SELECT T2.character FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T1.year = 2009;
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: Which are the years that character Mr. Burns won an award? [/INST]
SELECT DISTINCT T1.year FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Mr. Burns';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: What is the awarded category that the awarded character Lenny won? [/INST]
SELECT DISTINCT T1.award_category FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Lenny';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Character_Award : award_id [ INTEGER ] Character_Award.award_id = Award.award_id character [ TEXT ] Please write me a SQL statement that answers the following question: What is the name of actor who took the role Smithers? [/INST]
SELECT DISTINCT T1.person FROM Award AS T1 INNER JOIN Character_Award AS T2 ON T1.award_id = T2.award_id WHERE T2.character = 'Smithers';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: What are the keywords of the episode which has title as Dangerous Curves? [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Dangerous Curves';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Keyword : episode_id [ TEXT ] Keyword.episode_id = Episode.episode_id keyword [ TEXT ] Please write me a SQL statement that answers the following question: What are the keywords of the episodes which have the air date in 2008? [/INST]
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Among the episodes which have star score less than 8, how many episodes were aired in 2009? [/INST]
SELECT COUNT(DISTINCT T2.episode_id) FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE strftime('%Y', T1.air_date) = '2009' AND T2.stars < 8;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: State the birth name of crews who are director and have birth country in South Korea. [/INST]
SELECT T1.birth_name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.name = T2.person WHERE T2.role = 'director' AND T1.birth_country = 'South Korea';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: How many awards did simpson 20 won in 2009? [/INST]
SELECT COUNT(award_id) FROM Award WHERE SUBSTR(year, 1, 4) = '2009' AND result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Please write me a SQL statement that answers the following question: What is the total number of episode with a rating below 7? [/INST]
SELECT COUNT(episode_id) FROM Episode WHERE rating < 7;
[INST] Here is a database schema: Person : name [ TEXT ] primary_key birthdate [ TEXT ] birth_name [ TEXT ] birth_place [ TEXT ] birth_region [ TEXT ] birth_country [ TEXT ] height_meters [ REAL ] nickname [ TEXT ] Please write me a SQL statement that answers the following question: List down the names of person born in California, USA. [/INST]
SELECT name FROM Person WHERE birth_region = 'California' AND birth_country = 'USA';
[INST] Here is a database schema: Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: In between the episode 5 and10 of season 2, how many of them are credited for casting? [/INST]
SELECT COUNT(credited) FROM Credit WHERE episode_id IN ( 'S20-E5', 'S20-E6', 'S20-E7', 'S20-E8', 'S20-E9', 'S20-E10' ) AND credited = 'true' AND role = 'casting';
[INST] Here is a database schema: Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the episode ID that received 2 stars and 9 votes? [/INST]
SELECT episode_id FROM Vote WHERE stars = 2 AND votes = 9;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: Give the title of the episode won in Primetime Emmy Awards 2009. [/INST]
SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.organization = 'Primetime Emmy Awards' AND T1.year = 2009 AND T1.result = 'Winner';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List down the episode ID of episodes aired in 2008 with 5 stars and below. [/INST]
SELECT DISTINCT T1.episode_id FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008' AND T2.stars < 5;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: Among the episode with highest votes, what is the category credited to Carlton Batten? [/INST]
SELECT T2.category FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.person = 'Carlton Batten' AND T2.credited = 'true' ORDER BY T1.votes DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: Among the episodes aired in 2008 with votes ranges from 920 to 950, list their percent. [/INST]
SELECT T2.percent FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE SUBSTR(T1.air_date, 1, 4) = '2008' AND T1.votes BETWEEN 950 AND 960;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: List the episode ID and title of episode where casting was credited to Bonita Pietila. [/INST]
SELECT T1.episode_id, T1.title FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.credited = 'true' AND T2.person = 'Bonita Pietila' AND T2.role = 'casting';
[INST] Here is a database schema: Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: In episode nominated in Annie Awards, how many of the episodes have a percent greater than 6? [/INST]
SELECT COUNT(*) FROM Award AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T1.organization = 'Annie Awards' AND T1.result = 'Nominee' AND T2.percent > 6;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: What is the title of episode nominated for WGA Award (TV) with votes greater than 1000? [/INST]
SELECT DISTINCT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T2.votes > 1000 AND T1.award_category = 'WGA Award (TV)' AND T1.result = 'Nominee';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: Among the people in Animation Department, who are credited for additional time in the episode titled by "How the Test Was Won"? [/INST]
SELECT T2.person FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'How the Test Was Won' AND T2.role = 'additional timer' AND T2.credited = 'true' AND T2.category = 'Animation Department';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List the stars of episodes aired in November 2008. [/INST]
SELECT T2.stars FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE SUBSTR(T1.air_date, 1, 7) = '2008-11';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: What is the title of episode with 5 stars and nominated for Prism Award which is aired on April 19, 2009? [/INST]
SELECT T3.title FROM Award AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T3.air_date = '2009-04-19' AND T1.award_category = 'Prism Award' AND T2.stars = 5 AND T1.result = 'Nominee';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: In episode with the highest votes, list the category of awards it is nominated for. [/INST]
SELECT T1.award_category FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.result = 'Nominee' ORDER BY T2.votes DESC LIMIT 1;
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Credit : episode_id [ TEXT ] Credit.episode_id = Episode.episode_id category [ TEXT ] person [ TEXT ] Credit.person = Person.name role [ TEXT ] credited [ TEXT ] Please write me a SQL statement that answers the following question: In episodes aired in 2009, how many of them are credited to Sam Im for additional timer? [/INST]
SELECT COUNT(*) FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id WHERE T2.credited = 'true' AND T2.person = 'Sam Im' AND SUBSTR(T1.air_date, 1, 4) = '2009' AND T2.role = 'additional timer';
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Vote : episode_id [ TEXT ] Vote.episode_id = Episode.episode_id stars [ INTEGER ] votes [ INTEGER ] percent [ REAL ] Please write me a SQL statement that answers the following question: List the title of the episode with stars greater than the 70% of average stars of all episodes. [/INST]
SELECT DISTINCT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T2.episode_id = T1.episode_id WHERE T2.stars > 0.7 * ( SELECT AVG(stars) FROM Vote );
[INST] Here is a database schema: Episode : episode_id [ TEXT ] primary_key season [ INTEGER ] episode [ INTEGER ] number_in_series [ INTEGER ] title [ TEXT ] summary [ TEXT ] air_date [ TEXT ] episode_image [ TEXT ] rating [ REAL ] votes [ INTEGER ] Award : award_id [ INTEGER ] primary_key organization [ TEXT ] year [ INTEGER ] award_category [ TEXT ] award [ TEXT ] person [ TEXT ] Award.person = Person.name role [ TEXT ] episode_id [ TEXT ] Award.episode_id = Episode.episode_id season [ TEXT ] song [ TEXT ] result [ TEXT ] Please write me a SQL statement that answers the following question: In year 2009, what is the percentage of the episode titled by "Gone Maggie Gone" being nominated? [/INST]
SELECT CAST((SUM(CASE WHEN T1.result = 'Nominee' THEN 1 ELSE 0 END) - SUM(CASE WHEN T1.result = 'Winner' THEN 1 ELSE 0 END)) AS REAL) * 100 / COUNT(T1.result) FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T2.title = 'Gone Maggie Gone' AND T1.year = 2009;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: For the students who have been absent from school for the longest time, how many months have they been absent? [/INST]
SELECT MAX(month) FROM longest_absense_from_school;
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: How many students belong to the navy department? [/INST]
SELECT COUNT(name) FROM enlist WHERE organ = 'navy';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many female students are disabled? [/INST]
SELECT COUNT(name) FROM disabled WHERE name NOT IN ( SELECT name FROM male );
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Please list all the female students that have filed for bankruptcy. [/INST]
SELECT name FROM filed_for_bankrupcy WHERE name NOT IN ( SELECT name FROM male );
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: Name all students enlisted in the foreign legion. [/INST]
SELECT name FROM enlist WHERE organ = 'foreign_legion';
[INST] Here is a database schema: no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: Does student348 have a due payment? [/INST]
SELECT bool FROM no_payment_due WHERE name = 'student348';
[INST] Here is a database schema: enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: Which school is student829 enrolled in? [/INST]
SELECT school FROM enrolled WHERE name = 'student829';
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many months has student217 been absent? [/INST]
SELECT month FROM longest_absense_from_school WHERE name = 'student217';
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] Please write me a SQL statement that answers the following question: Which organization did student285 enlist? [/INST]
SELECT organ FROM enlist WHERE name = 'student285';
[INST] Here is a database schema: male : name [ TEXT ] primary_key male.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name Please write me a SQL statement that answers the following question: How many male students have no due payments? [/INST]
SELECT COUNT(T1.name) FROM no_payment_due AS T1 INNER JOIN male AS T2 ON T1.name = T2.name WHERE T1.bool = 'neg';
[INST] Here is a database schema: person : name [ TEXT ] primary_key Please write me a SQL statement that answers the following question: What is the total number of students in the school? [/INST]
SELECT COUNT(name) FROM person;
[INST] Here is a database schema: longest_absense_from_school : name [ TEXT ] primary_key longest_absense_from_school.name = person.name month [ INTEGER ] Please write me a SQL statement that answers the following question: How many students were absence for 4 month? [/INST]
SELECT COUNT(name) FROM longest_absense_from_school WHERE month = 4;
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: What is the number of unemployed and bankrupt students? [/INST]
SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name;
[INST] Here is a database schema: filed_for_bankrupcy : name [ TEXT ] primary_key filed_for_bankrupcy.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: How many unemployed and bankrupt students that have payment dues? [/INST]
SELECT COUNT(T1.name) FROM unemployed AS T1 INNER JOIN filed_for_bankrupcy AS T2 ON T1.name = T2.name INNER JOIN no_payment_due AS T3 ON T2.name = T3.name WHERE T3.bool = 'pos';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: Please check if student 124 is disabled male. [/INST]
SELECT IIF(T2.name IS NULL, 'female', 'male') FROM male AS T1 LEFT JOIN disabled AS T2 ON T1.name = T2.name WHERE T1.name = 'student124';
[INST] Here is a database schema: disabled : name [ TEXT ] primary_key disabled.name = person.name male : name [ TEXT ] primary_key male.name = person.name no_payment_due : name [ TEXT ] primary_key no_payment_due.name = person.name bool [ TEXT ] no_payment_due.bool = bool.name unemployed : name [ TEXT ] primary_key unemployed.name = person.name Please write me a SQL statement that answers the following question: What is the employment, disability, gender and school debt status for student180 and student117? [/INST]
SELECT ( SELECT COUNT(name) FROM disabled WHERE name IN ('student180', 'student117') ), ( SELECT COUNT(name) FROM unemployed WHERE name IN ('student180', 'student117') ), ( SELECT COUNT(name) FROM male WHERE name IN ('student180', 'student117') ), ( SELECT COUNT(name) FROM no_payment_due WHERE name IN ('student180', 'student117'));
[INST] Here is a database schema: enlist : name [ TEXT ] enlist.name = person.name organ [ TEXT ] male : name [ TEXT ] primary_key male.name = person.name Please write me a SQL statement that answers the following question: How many female students joined a marines and air force organization? [/INST]
SELECT COUNT(name) FROM enlist WHERE organ IN ('marines', 'air_force') AND name NOT IN ( SELECT name FROM male );
[INST] Here is a database schema: person : name [ TEXT ] primary_key male : name [ TEXT ] primary_key male.name = person.name enrolled : name [ TEXT ] enrolled.name = person.name school [ TEXT ] month [ INTEGER ] Please write me a SQL statement that answers the following question: How many female students are not joining any of the organization? [/INST]
SELECT COUNT(name) FROM person WHERE name NOT IN ( SELECT name FROM male ) AND name NOT IN ( SELECT name FROM enrolled );