Chinastark/bird_dataset huggingface dataset:
Database: law_episode
Note: the winner refers to result = 'Winner'; the Television refers to award = 'Television'; Silver Gavel award refers to award_category = 'Silver Gavel award'; the American Bar Association Silver Gavel awards for Media and the Arts refers to organization = 'American Bar Association Silver Gavel awards for Media and the Arts';
Question: Give me the years and episode IDs in which Constantine Makris was the winner of the Television Silver Gavel Award at the American Bar Association Silver Gavel Awards for Media and the Arts for two consecutive years.
SQL: SELECT t3.years, t3.episode_id FROM ( SELECT DISTINCT award.year AS years, award.episode_id, row_number() OVER (PARTITION BY award.episode_id ORDER BY award.year) AS rm FROM person INNER JOIN award ON person.person_id = award.person_id WHERE award.award = 'Television' AND award.award_category = 'Silver Gavel Award' AND person.name = 'Constantine Makris' AND award.result = 'Winner' AND award.organization = 'American Bar Association Silver Gavel Awards for Media and the Arts' ) AS t3 GROUP BY t3.episode_id HAVING count(t3.years - t3.rm) >= 2
Database: law_episode
Note: who refers to name; writer refers to role = 'writer'; won refers to result = 'Winner'; the Television refers to award = 'Television'; Silver Gavel award refers to award_category = 'Silver Gavel award'; the American Bar Association Silver Gavel awards for Media and the Arts refers to organization = 'American Bar Association Silver Gavel awards for Media and the Arts';
Question: Who was the Law and Order series writer who also won the Television Silver Gavel Award at the American Bar Association Silver Gavel Awards for Media and the Arts for two consecutive years?
SQL: SELECT t3.name FROM ( SELECT DISTINCT award.year AS years, person.name, row_number() OVER (PARTITION BY person.name ORDER BY award.year) AS rm FROM person INNER JOIN award ON person.person_id = award.person_id WHERE award.award = 'Television' AND award.award_category = 'Silver Gavel Award' AND award.series = 'Law and Order' AND award.result = 'Winner' AND award.organization = 'American Bar Association Silver Gavel Awards for Media and the Arts' ) AS t3 GROUP BY t3.name HAVING count(t3.years - t3.rm) >= 2
Database: law_episode
Note: nominated refers to result = 'nominee'; the Law and Order series refers to series = 'Law and Order'; the Primetime Emmy awards refers to organization = 'Primetime Emmy awards'; in 1999 refers to year = 1999;
Question: How many times was episode 20 of the Law and Order series nominated for the Primetime Emmy Awards in 1999?
SQL: SELECT count(award.award_id) FROM episode INNER JOIN award ON episode.episode_id = award.episode_id WHERE award.year = 1999 AND award.result = 'Nominee' AND episode.episode = 20 AND award.organization = 'Primetime Emmy Awards' AND episode.series = 'Law and Order'
Database: law_episode
Note: win refers to result = 'Winner'; the "Outstanding Guest Actress in a Drama series" award refers to award = 'Outstanding Guest Actress in a Drama series'; the 1999 refers to year = 1999; Primetime Emmy awards refers to organization = 'Primetime Emmy awards';
Question: On what episode did Julia Roberts win the "Outstanding Guest Actress in a Drama Series" award during the 1999 Primetime Emmy Awards? Tell me her role.
SQL: SELECT episode.episode_id, award.role FROM person INNER JOIN award ON person.person_id = award.person_id INNER JOIN episode ON award.episode_id = episode.episode_id WHERE award.year = 1999 AND award.award = 'Outstanding Guest Actress in a Drama Series' AND award.organization = 'Primetime Emmy Awards' AND person.name = 'Julia Roberts' AND award.result = 'Nominee'
Database: law_episode
Note: produced refers to role = 'producer';
Question: List the titles and air dates of episodes that were produced by Billy Fox.
SQL: SELECT episode.title, episode.air_date FROM episode INNER JOIN credit ON episode.episode_id = credit.episode_id INNER JOIN person ON person.person_id = credit.person_id WHERE credit.category = 'Produced by' AND credit.role = 'producer' AND person.name = 'Billy Fox'
Database: law_episode
Note: American refers to birth_country = 'USA'; cast refers to category = 'Cast'; uncredited refers to credited = '';
Question: Among the American casts, how many were uncredited on episode ID tt0629228?
SQL: SELECT count(credit.person_id) FROM credit INNER JOIN person ON person.person_id = credit.person_id WHERE credit.episode_id = 'tt0629228' AND credit.category = 'Cast' AND credit.credited = 'false' AND person.birth_country = 'USA'
Database: law_episode
Question: What was the role of Jason Kuschner in episode 9?
SQL: SELECT credit.role FROM credit INNER JOIN person ON person.person_id = credit.person_id INNER JOIN episode ON credit.episode_id = episode.episode_id WHERE episode.episode = 9 AND person.name = 'Jason Kuschner'
Database: law_episode
Note: who refers to name; the role of the "president of NBC West Coast" refers to role = 'president of NBC West Coast'; the first episode refers to episode = 1;
Question: Who played the role of the "president of NBC West Coast" in the first episode?
SQL: SELECT person.name FROM credit INNER JOIN person ON person.person_id = credit.person_id INNER JOIN episode ON credit.episode_id = episode.episode_id WHERE episode.episode = 1 AND credit.role = 'president of NBC West Coast'
Database: law_episode
Note: weighted stars = divide(sum(stars, percent), 100);
Question: List down the titles of the top 3 episodes, from highest to lowest, in terms of their weighted stars.
SQL: SELECT episode.title FROM vote INNER JOIN episode ON episode.episode_id = vote.episode_id WHERE vote.stars BETWEEN 1 AND 10 GROUP BY episode.title ORDER BY cast(sum(vote.stars * vote.percent) AS REAL) / 100 DESC LIMIT 3
Database: law_episode
Note: American refers to birth_country = 'USA'; cast refers to category = 'Cast'; ratio = divide(count(person_id where birth_country = 'USA'), total(category)) where category = 'Cast';
Question: What is the ratio of American casts on episode 2 of the series? Please include their roles.
SQL: SELECT cast(sum(CASE WHEN credit.category = 'Cast' THEN 1 ELSE 0 END) AS REAL) * 100 / count(credit.category), award.role FROM award INNER JOIN credit ON award.episode_id = credit.episode_id INNER JOIN episode ON credit.episode_id = episode.episode_id INNER JOIN person ON credit.person_id = person.person_id WHERE episode.episode = 2 AND person.birth_country = 'USA'
Database: law_episode
Note: from Canada refers to birth_country = Canada; nominated refers to award is NOT NULL;
Question: How many people from Canada are nominated for an award?
SQL: SELECT count(person.person_id) FROM person INNER JOIN award ON person.person_id = award.person_id WHERE person.birth_country = 'Canada'
Database: law_episode
Question: How many episodes are credited to Jerry Orbach?
SQL: SELECT count(person.person_id) FROM credit INNER JOIN person ON person.person_id = credit.person_id WHERE person.name = 'Jerry Orbach'
Database: law_episode
Note: credit name refers to name;
Question: List out all the credit names for episode 9.
SQL: SELECT person.name FROM episode INNER JOIN credit ON episode.episode_id = credit.episode_id INNER JOIN person ON person.person_id = credit.person_id WHERE episode.episode = 9
Database: law_episode
Note: award title refers to title; nominated refers to result = 'Winner' or result = 'Nominee';
Question: List out all award titles nominated for episode 20.
SQL: SELECT award.award FROM episode INNER JOIN award ON episode.episode_id = award.episode_id WHERE episode.episode = 20 AND award.result IN ('Winner', 'Nominee')
Database: law_episode
Note: at least two awards refers to count(role) >1;
Question: Which role have won at least two awards for the entire season and list out the name?
SQL: SELECT person.name FROM person INNER JOIN award ON person.person_id = award.person_id GROUP BY award.role HAVING count(award.award_id) > 1
Database: law_episode
Note: director refers to role = 'director'; received an award refers to result = 'Winner'; episode number refers to episode;
Question: List out director names that received an award along with the episode number.
SQL: SELECT person.name, episode.episode_id FROM episode INNER JOIN award ON episode.episode_id = award.episode_id INNER JOIN person ON award.person_id = person.person_id WHERE award.role = 'director' AND award.result = 'Winner'
Database: law_episode
Note: nominated for an award but not win refers to result = 'Nominee';
Question: Which episodes are nominated for an awards but not win?
SQL: SELECT episode.episode FROM episode INNER JOIN award ON episode.episode_id = award.episode_id WHERE award.result = 'Nominee'
Database: law_episode
Note: average rating = divide(sum(rating), count(episode_id));
Question: What is the average rating for each episode in season 9?
SQL: SELECT sum(rating) / count(episode_id) FROM episode WHERE season = 9
Database: law_episode
Note: the first episode refers to episode = 1; the last episode refers to episode = 24; 10 stars vote refers to stars = 10; the difference = subtract(votes where episode = 1, votes where episode = 24) where stars = 10;
Question: What is the difference of 10 stars votes between the first episode and the last episode?
SQL: SELECT sum(CASE WHEN episode.episode = 24 THEN vote.votes ELSE 0 END) - sum(CASE WHEN episode.episode = 1 THEN vote.votes ELSE 0 END) FROM vote INNER JOIN episode ON episode.episode_id = vote.episode_id WHERE vote.stars = 10
Database: law_episode
Note: the most award won refers to max(episode_id where result = 'Winner');
Question: What is the episode rating with the most award won?
SQL: SELECT episode.rating FROM episode INNER JOIN award ON episode.episode_id = award.episode_id WHERE award.result = 'Winner' GROUP BY episode.episode_id ORDER BY count(award.award_id) DESC LIMIT 1
Database: law_episode
Note: credit displayed refers to credited = 'true'; from episode 1 until 10 refers to episode >= 1 AND episode <= 10;
Question: How many credits have been displayed from episode 1 until 10?
SQL: SELECT count(credit.person_id) FROM credit INNER JOIN episode ON credit.episode_id = episode.episode_id WHERE credit.credited = 'true' AND episode.episode BETWEEN 1 AND 10
Database: law_episode
Note: mafia keyword refers to keyword = 'mafia';
Question: What is the episode that has mafia keyword?
SQL: SELECT episode.episode FROM episode INNER JOIN keyword ON episode.episode_id = keyword.episode_id WHERE keyword.keyword = 'mafia'
Database: law_episode
Note: received award refers to result = 'Winner'; the highest percentage refers to max(percent); average star = divide(sum(stars), count(episode_id));
Question: What is the average star with highest percentage for episodes that have received award?
SQL: SELECT award.person_id FROM vote INNER JOIN award ON vote.episode_id = award.episode_id ORDER BY vote.percent DESC LIMIT 1
Database: law_episode
Note: average ranking = divide(sum(rating), sum(episode_id));
Question: What is the average ranking episodes that are nominated for an award?
SQL: SELECT sum(episode.rating) / count(episode.episode) FROM episode INNER JOIN award ON episode.episode_id = award.episode_id
Database: law_episode
Note: winner refers to result = 'Winner'; Television award refers to award = 'Television'; the "American Bar Association Silver Gavel awards for Media and the Arts" refers to organization = 'American Bar Association Silver Gavel awards for Media and the Arts';
Question: How many winners have been awarded a Television award by the "American Bar Association Silver Gavel Awards for Media and the Arts"?
SQL: SELECT count(award_id) FROM award WHERE RESULT = 'Winner' AND award = 'Television' AND organization = 'American Bar Association Silver Gavel Awards for Media and the Arts'
Database: law_episode
Note: continent refers to birth_country;
Question: Which continent was Michael Preston born on?
SQL: SELECT birth_country FROM person WHERE name = 'Michael Preston'
Database: law_episode
Note: nominee refers to result = 'Nominee'; the role of Katrina Ludlow refers to role = 'Katrina Ludlow';
Question: Who was the nominee playing the role of Katrina Ludlow in the Law & Order series?
SQL: SELECT person.name FROM award INNER JOIN person ON award.person_id = person.person_id WHERE award.result = 'Nominee' AND award.role = 'Katrina Ludlow' AND award.series = 'Law and Order'
Database: law_episode
Note: the role of a teleplay refers to role = 'teleplay'; won refers to result = 'Winner'; "Best Television episode" refers to award = 'Best Television episode';
Question: Who played the role of a teleplay in the episode that won "Best Television Episode"?
SQL: SELECT person.name FROM award INNER JOIN person ON award.person_id = person.person_id WHERE award.result = 'Winner' AND award.award = 'Best Television Episode'
Database: law_episode
Note: date of birth refers to birthdate;
Question: What is the date of birth of the actor who played the role of a "writer"?
SQL: SELECT person.birthdate FROM award INNER JOIN person ON award.person_id = person.person_id WHERE award.role = 'writer'
Database: law_episode
Note: episode refers to title; "Outstanding Costume Design for a series" refers to award = 'Outstanding Costume Design for a series';
Question: Which episode was nominated for the award for "Outstanding Costume Design for a Series"?
SQL: SELECT episode.title FROM award INNER JOIN episode ON award.episode_id = episode.episode_id WHERE award.award = 'Outstanding Costume Design for a Series'
Database: law_episode
Note: episode refers to title; the highest total number of viewer votes refers to max(sum(votes));
Question: Which episode has the highest total number of viewer votes?
SQL: SELECT episode.title FROM episode INNER JOIN vote ON episode.episode_id = vote.episode_id GROUP BY episode.title ORDER BY sum(episode.votes) DESC LIMIT 1
Database: law_episode
Note: who refers to name; portraying "Alex Brown" refers to role = 'Alex Brown'; has been credited refers to credited = 'true';
Question: Who was the actor who was portraying "Alex Brown" and has been credited?
SQL: SELECT person.name FROM person INNER JOIN credit ON person.person_id = credit.person_id WHERE credit.role = 'Alex Brown' AND credit.credited = 'true'
Database: law_episode
Note: place of birth refers to birth_place; actor with the number nm0007064 refers to person_id = 'nm007064'; has not been credited refers to credited = ''; the role of a "Narrator" refers to role = 'narrator';
Question: Where is the place of birth of the actor with the number nm0007064 who has not been credited for playing the role of a "Narrator"?
SQL: SELECT DISTINCT person.birth_place FROM person INNER JOIN credit ON person.person_id = credit.person_id WHERE person.person_id = 'nm0007064' AND credit.role = 'Narrator' AND credit.credited = 'false'
Database: law_episode
Note: the episode "Shield" refers to title = 'Shield';
Question: What are the keywords of the episode "Shield"?
SQL: SELECT keyword.keyword FROM episode INNER JOIN keyword ON episode.episode_id = keyword.episode_id WHERE episode.title = 'Shield'
Database: law_episode
Note: who refers to name; a height of over 1.80m refers to height_meters > 1.80; won an award refers to result = 'Winner';
Question: Who are the actors with a height of over 1.80m in an episode that won an award?
SQL: SELECT person.name FROM award INNER JOIN person ON award.person_id = person.person_id WHERE award.result = 'Winner' AND person.height_meters > 1.80
Database: law_episode
Note: episode refers to title; the two keywords "nun" and "priest" refers to keyword = 'nun' or keyword = 'priest';
Question: Which episode has the two keywords "nun" and "priest"?
SQL: SELECT episode.title FROM episode INNER JOIN keyword ON episode.episode_id = keyword.episode_id WHERE keyword.keyword IN ('nun', 'priest')
Database: law_episode
Note: episode number refers to episode_id; awarded "Best Television episode" refers to award = 'Best Television episode' and result = 'Winner'; the second highest positive viewer comments refers to rating = 8.5;
Question: Which episode number has the second highest positive viewer comments and has been awarded "Best Television Episode"?
SQL: SELECT episode.episode_id FROM award INNER JOIN episode ON award.episode_id = episode.episode_id WHERE award.award = 'Best Television Episode' AND award.result = 'Winner' ORDER BY episode.rating DESC LIMIT 2
Database: law_episode
Note: episode refers to title; most enjoyed by the viewers refers to stars = 10;
Question: Please list any three episodes that were most enjoyed by the viewers.
SQL: SELECT episode.title FROM episode INNER JOIN vote ON episode.episode_id = vote.episode_id WHERE vote.stars = 10 LIMIT 3
Database: synthea
Note: 2008/3/11 refers to date = '2008-03-11'; height refers to description = 'Body Height' from observations;
Question: According to the observation on 2008/3/11, what was the height of Elly Koss?
SQL: SELECT observations.value, observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND observations.date = '2008-03-11' AND observations.description = 'Body Height'
Database: synthea
Note: SUBTRACT((date like '2009%'), (date like '2008%')) where description = 'Body Weight';
Question: By how much did Elly Koss's weight increase from the observation in 2008 to the observation in 2009?
SQL: SELECT sum(CASE WHEN strftime('%Y', observations.date) = '2009' THEN observations.value END) - sum(CASE WHEN strftime('%Y', observations.date) = '2008' THEN observations.value END) AS increase , observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND observations.description = 'Body Height'
Database: synthea
Note: the highest Systolic Blood Pressure refers to MAX(description = 'Systolic Blood Pressure') from observations;
Question: During all the observations of Elly Koss, what was the highest Systolic Blood Pressure observed?
SQL: SELECT observations.value, observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND observations.description = 'Systolic Blood Pressure' ORDER BY observations.value DESC LIMIT 1
Database: synthea
Note: Systolic Blood Pressure refers to description = 'Systolic Blood Pressure';
Question: For how many times had Elly Koss have her Systolic Blood Pressure observed?
SQL: SELECT count(observations.description) FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND observations.description = 'Systolic Blood Pressure'
Database: synthea
Note: the highest Systolic Blood Pressure refers to MAX(description = 'Systolic Blood Pressure') from observations; full name refers to first, last;
Question: The highest Systolic Blood Pressure was observed in which patient? Please give his or her full name.
SQL: SELECT patients.first, patients.last FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE observations.value = ( SELECT max(value) FROM observations WHERE description = 'Systolic Blood Pressure' ) LIMIT 1
Database: synthea
Note: SUM(MULTIPLY(365, SUBTRACT(strftime('%Y', stop), strftime('%Y', start))), MULTIPLY(30, SUBTRACT(strftime('%m', stop), strftime('%m', start))), SUBTRACT(strftime('%d', stop), strftime('%d', start))) where description like 'Acetaminophen%';
Question: For how long was Elly Koss required to take Acetaminophen?
SQL: SELECT strftime('%J', medications.stop) - strftime('%J', medications.start) AS days FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND medications.description LIKE 'Acetaminophen%'
Database: synthea
Note: medication that are prescribed refers to description from medications;
Question: Please list all the medication that are prescribed to Elly Koss.
SQL: SELECT DISTINCT medications.description FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss'
Database: synthea
Note: why need to take Acetaminophen refers to reasondescription  where description like 'Acetaminophen%' from medications;
Question: Why did Elly Koss need to take Acetaminophen?
SQL: SELECT medications.reasondescription FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND medications.description LIKE 'Acetaminophen%'
Database: synthea
Note: medication refers to description from medications; Streptococcal sore throat refers to reasondescription like 'Streptococcal sore throat%';
Question: What medication did Elly Koss take when she had Streptococcal sore throat?
SQL: SELECT medications.description FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND medications.reasondescription = 'Streptococcal sore throat (disorder)'
Database: synthea
Note: full name refers to first, last; prescribed with Acetaminophen refer to description like 'Acetaminophen%' from medications;
Question: Please give the full names of all the patients who had been prescribed with Acetaminophen.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.description LIKE 'Acetaminophen%'
Database: synthea
Note: condition on 2009/1/8 refers to description from conditions where start = '2009-01-08';
Question: What was the condition of Elly Koss on 2009/1/8?
SQL: SELECT conditions.description FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND conditions.start = '2009-01-08'
Database: synthea
Note: SUM(MULTIPLY(365, SUBTRACT(strftime('%Y', stop), strftime('%Y', start))), MULTIPLY(30, SUBTRACT(strftime('%m', stop), strftime('%m', start))), SUBTRACT(strftime('%d', stop), strftime('%d', start))) where description = 'Cystitis';
Question: For how long did Elly Koss's cystitis last?
SQL: SELECT strftime('%J', conditions.stop) - strftime('%J', conditions.start) AS days FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND conditions.description = 'Cystitis'
Database: synthea
Note: DIVidE(SUM(value), COUNT(value)) WHERE description = 'Body Weight';
Question: According to all the observations of Elly Koss, what was her average weight?
SQL: SELECT avg(observations.value), observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND observations.description = 'Body Weight'
Database: synthea
Note: DIVidE(COUNT(marital = 'M'), COUNT(patient)) as percentage where description = 'Cystitis';
Question: Among all the patients who once had cystitis, what was the percentage of them being married?
SQL: SELECT cast(sum(CASE WHEN patients.marital = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / count(DISTINCT patients.patient) FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Cystitis'
Database: synthea
Note: body height status refers to description = 'Body Height' from observations; on 2010/8/2 refers to date = '2010-08-02';
Question: Give the body height status of Mr. Vincent Wyman on 2010/8/2.
SQL: SELECT observations.description, observations.value, observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.prefix = 'Mr.' AND patients.first = 'Vincent' AND patients.last = 'Wyman' AND observations.date = '2010-08-02' AND observations.description = 'Body Height'
Database: synthea
Question: How many care plans has Mrs. Norman Berge taken?
SQL: SELECT count(careplans.patient) FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.prefix = 'Mrs.' AND patients.first = 'Norman' AND patients.last = 'Berge'