problem
stringlengths
121
422
db_id
stringclasses
69 values
solution
stringlengths
23
804
Write SQL query to solve given problem: List the titles and air dates of episodes that were produced by Billy Fox.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.title, T1.air_date FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T2.category = 'Produced by' AND T2.role = 'producer' AND T3.name = 'Billy Fox'
Write SQL query to solve given problem: Among the American casts, how many were uncredited on episode ID tt0629228?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT COUNT(T1.person_id) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T1.episode_id = 'tt0629228' AND T1.category = 'Cast' AND T1.credited = 'false' AND T2.birth_country = 'USA'
Write SQL query to solve given problem: What was the role of Jason Kuschner in episode 9?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.role FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T3.episode = 9 AND T2.name = 'Jason Kuschner'
Write SQL query to solve given problem: Who played the role of the "president of NBC West Coast" in the first episode?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.name FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id INNER JOIN Episode AS T3 ON T1.episode_id = T3.episode_id WHERE T3.episode = 1 AND T1.role = 'president of NBC West Coast'
Write SQL query to solve given problem: List down the titles of the top 3 episodes, from highest to lowest, in terms of their weighted stars.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.title FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars BETWEEN 1 AND 10 GROUP BY T2.title ORDER BY CAST(SUM(T1.stars * T1.percent) AS REAL) / 100 DESC LIMIT 3
Write SQL query to solve given problem: What is the ratio of American casts on episode 2 of the series? Please include their roles.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT CAST(SUM(CASE WHEN T2.category = 'Cast' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.category), T1.role FROM Award AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Episode AS T3 ON T2.episode_id = T3.episode_id INNER JOIN Person AS T4 ON T2.person_id = T4.person_id WHERE T3.episode = 2 AND T4.birth_country = 'USA'
Write SQL query to solve given problem: How many people from Canada are nominated for an award?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT COUNT(T1.person_id) FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id WHERE T1.birth_country = 'Canada'
Write SQL query to solve given problem: How many episodes are credited to Jerry Orbach?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT COUNT(T2.person_id) FROM Credit AS T1 INNER JOIN Person AS T2 ON T2.person_id = T1.person_id WHERE T2.name = 'Jerry Orbach'
Write SQL query to solve given problem: List out all the credit names for episode 9.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T3.name FROM Episode AS T1 INNER JOIN Credit AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T3.person_id = T2.person_id WHERE T1.episode = 9
Write SQL query to solve given problem: List out all award titles nominated for episode 20.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.award FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T1.episode = 20 AND T2.result IN ('Winner', 'Nominee')
Write SQL query to solve given problem: Which role have won at least two awards for the entire season and list out the name?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.name FROM Person AS T1 INNER JOIN Award AS T2 ON T1.person_id = T2.person_id GROUP BY T2.role HAVING COUNT(T2.award_id) > 1
Write SQL query to solve given problem: List out director names that received an award along with the episode number.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T3.name, T1.episode_id FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id INNER JOIN Person AS T3 ON T2.person_id = T3.person_id WHERE T2.role = 'director' AND T2.result = 'Winner'
Write SQL query to solve given problem: Which episodes are nominated for an awards but not win?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.episode FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.result = 'Nominee'
Write SQL query to solve given problem: What is the average rating for each episode in season 9?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT SUM(rating) / COUNT(episode_id) FROM Episode WHERE season = 9
Write SQL query to solve given problem: What is the difference of 10 stars votes between the first episode and the last episode?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT SUM(CASE WHEN T2.episode = 24 THEN T1.votes ELSE 0 END) - SUM(CASE WHEN T2.episode = 1 THEN T1.votes ELSE 0 END) FROM Vote AS T1 INNER JOIN Episode AS T2 ON T2.episode_id = T1.episode_id WHERE T1.stars = 10
Write SQL query to solve given problem: What is the episode rating with the most award won?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.rating FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id WHERE T2.result = 'Winner' GROUP BY T1.episode_id ORDER BY COUNT(T2.award_id) DESC LIMIT 1
Write SQL query to solve given problem: How many credits have been displayed from episode 1 until 10?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT COUNT(T1.person_id) FROM Credit AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.credited = 'true' AND T2.episode BETWEEN 1 AND 10
Write SQL query to solve given problem: What is the episode that has mafia keyword?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.episode FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.Keyword = 'mafia'
Write SQL query to solve given problem: What is the average star with highest percentage for episodes that have received award?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.person_id FROM Vote AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id ORDER BY T1.percent DESC LIMIT 1
Write SQL query to solve given problem: What is the average ranking episodes that are nominated for an award?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT SUM(T1.rating) / COUNT(T1.episode) FROM Episode AS T1 INNER JOIN Award AS T2 ON T1.episode_id = T2.episode_id
Write SQL query to solve given problem: How many winners have been awarded a Television award by the "American Bar Association Silver Gavel Awards for Media and the Arts"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
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'
Write SQL query to solve given problem: Which continent was Michael Preston born on?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT birth_country FROM Person WHERE name = 'Michael Preston'
Write SQL query to solve given problem: Who was the nominee playing the role of Katrina Ludlow in the Law & Order series?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.name FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.result = 'Nominee' AND T1.role = 'Katrina Ludlow' AND T1.series = 'Law and Order'
Write SQL query to solve given problem: Who played the role of a teleplay in the episode that won "Best Television Episode"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.name FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.result = 'Winner' AND T1.award = 'Best Television Episode'
Write SQL query to solve given problem: What is the date of birth of the actor who played the role of a "writer"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.birthdate FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.role = 'writer'
Write SQL query to solve given problem: Which episode was nominated for the award for "Outstanding Costume Design for a Series"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.title FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award = 'Outstanding Costume Design for a Series'
Write SQL query to solve given problem: Which episode has the highest total number of viewer votes?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id GROUP BY T1.title ORDER BY SUM(T1.votes) DESC LIMIT 1
Write SQL query to solve given problem: Who was the actor who was portraying "Alex Brown" and has been credited?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.name FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.person_id = T2.person_id WHERE T2.role = 'Alex Brown' AND T2.credited = 'true'
Write SQL query to solve given problem: 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"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT DISTINCT T1.birth_place FROM Person AS T1 INNER JOIN Credit AS T2 ON T1.person_id = T2.person_id WHERE T1.person_id = 'nm0007064' AND T2.role = 'Narrator' AND T2.credited = 'false'
Write SQL query to solve given problem: What are the keywords of the episode "Shield"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.keyword FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T1.title = 'Shield'
Write SQL query to solve given problem: Who are the actors with a height of over 1.80m in an episode that won an award?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.name FROM Award AS T1 INNER JOIN Person AS T2 ON T1.person_id = T2.person_id WHERE T1.result = 'Winner' AND T2.height_meters > 1.80
Write SQL query to solve given problem: Which episode has the two keywords "nun" and "priest"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.title FROM Episode AS T1 INNER JOIN Keyword AS T2 ON T1.episode_id = T2.episode_id WHERE T2.keyword IN ('nun', 'priest')
Write SQL query to solve given problem: Which episode number has the second highest positive viewer comments and has been awarded "Best Television Episode"?. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T2.episode_id FROM Award AS T1 INNER JOIN Episode AS T2 ON T1.episode_id = T2.episode_id WHERE T1.award = 'Best Television Episode' AND T1.result = 'Winner' ORDER BY T2.rating DESC LIMIT 2
Write SQL query to solve given problem: Please list any three episodes that were most enjoyed by the viewers.. Keep the solution inside sql tag ```sql [SQL-Query] ```
law_episode
SELECT T1.title FROM Episode AS T1 INNER JOIN Vote AS T2 ON T1.episode_id = T2.episode_id WHERE T2.stars = 10 LIMIT 3
Write SQL query to solve given problem: According to the observation on 2008/3/11, what was the height of Elly Koss?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.value, T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.date = '2008-03-11' AND T2.description = 'Body Height'
Write SQL query to solve given problem: By how much did Elly Koss's weight increase from the observation in 2008 to the observation in 2009?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT SUM(CASE WHEN strftime('%Y', T2.date) = '2009' THEN T2.VALUE END) - SUM(CASE WHEN strftime('%Y', T2.date) = '2008' THEN T2.VALUE END) AS increase , T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Body Height'
Write SQL query to solve given problem: During all the observations of Elly Koss, what was the highest Systolic Blood Pressure observed?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.value, T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure' ORDER BY T2.VALUE DESC LIMIT 1
Write SQL query to solve given problem: For how many times had Elly Koss have her Systolic Blood Pressure observed?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.description) FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Systolic Blood Pressure'
Write SQL query to solve given problem: The highest Systolic Blood Pressure was observed in which patient? Please give his or her full name.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T2.VALUE = ( SELECT MAX(VALUE) FROM observations WHERE description = 'Systolic Blood Pressure' ) LIMIT 1
Write SQL query to solve given problem: For how long was Elly Koss required to take Acetaminophen?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT strftime('%J', T2.STOP) - strftime('%J', T2.START) AS days FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'
Write SQL query to solve given problem: Please list all the medication that are prescribed to Elly Koss.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss'
Write SQL query to solve given problem: Why did Elly Koss need to take Acetaminophen?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.REASONDESCRIPTION FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description LIKE 'Acetaminophen%'
Write SQL query to solve given problem: What medication did Elly Koss take when she had Streptococcal sore throat?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.description FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.reasondescription = 'Streptococcal sore throat (disorder)'
Write SQL query to solve given problem: Please give the full names of all the patients who had been prescribed with Acetaminophen.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.description LIKE 'Acetaminophen%'
Write SQL query to solve given problem: What was the condition of Elly Koss on 2009/1/8?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.START = '2009-01-08'
Write SQL query to solve given problem: For how long did Elly Koss's cystitis last?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT strftime('%J', T2.STOP) - strftime('%J', T2.START) AS days FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Cystitis'
Write SQL query to solve given problem: According to all the observations of Elly Koss, what was her average weight?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT AVG(T2.VALUE), T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.description = 'Body Weight'
Write SQL query to solve given problem: Among all the patients who once had cystitis, what was the percentage of them being married?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT CAST(SUM(CASE WHEN T1.marital = 'M' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.description = 'Cystitis'
Write SQL query to solve given problem: Give the body height status of Mr. Vincent Wyman on 2010/8/2.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.description, T2.VALUE, T2.units FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mr.' AND T1.first = 'Vincent' AND T1.last = 'Wyman' AND T2.date = '2010-08-02' AND T2.description = 'Body Height'
Write SQL query to solve given problem: How many care plans has Mrs. Norman Berge taken?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Norman' AND T1.last = 'Berge'
Write SQL query to solve given problem: Why did Mrs. Annabelle Pouros take leucovorin 100 mg injection on 1970/12/19? State the reason.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.reasondescription FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Annabelle' AND T1.last = 'Pouros' AND T2.start = '1970-12-19' AND T2.description = 'Leucovorin 100 MG Injection'
Write SQL query to solve given problem: What is the prevalence percentage of condition no. 64859006?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T1."PREVALENCE PERCENTAGE" FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) WHERE T2.code = '64859006'
Write SQL query to solve given problem: State the prevalence rate of condition no. 368581000119106.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T1."PREVALENCE RATE" FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) WHERE T2.code = '368581000119106'
Write SQL query to solve given problem: Give the procedure description of Ms. Jacquelyn Shanahan on 2009/8/9.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T2.description FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Jacquelyn' AND T1.last = 'Shanahan' AND T2.DATE = '2009-08-09'
Write SQL query to solve given problem: Give the number of claims did Ms. Abbie Cole have in the year of 2011.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.BILLABLEPERIOD) FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Abbie' AND T1.last = 'Cole' AND T2.BILLABLEPERIOD BETWEEN '2010-12-31' AND '2012-01-01'
Write SQL query to solve given problem: How many allergies does Mrs. Saundra Monahan have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.code) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Saundra' AND T1.last = 'Monahan'
Write SQL query to solve given problem: Provide the name of the patient who had a claim on 1947/9/11.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T2.billableperiod = '1947-09-11'
Write SQL query to solve given problem: Describe the encounter of Mr. Hubert Baumbach on 2008/10/25.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.description FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mr.' AND T1.first = 'Hubert' AND T1.last = 'Baumbach' AND T2.date = '2008-10-25'
Write SQL query to solve given problem: What kind of condition did Keven Kuhn have from 2016/9/24 to 2016/10/10? Describe the condition.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.description FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Keven' AND T1.last = 'Kuhn' AND T2.start = '2016-09-24' AND T2.stop = '2016-10-10'
Write SQL query to solve given problem: When did Mrs. Ira Deckow have the standard pregnancy test?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.date FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mrs.' AND T1.first = 'Ira' AND T1.last = 'Deckow' AND T2.description = 'Standard pregnancy test'
Write SQL query to solve given problem: Calculate the average period of Mr. Wesley Lemke's care plans.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT CAST(SUM(strftime('%J', T2.STOP) - strftime('%J', T2.START)) AS REAL) / COUNT(T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Mr.' AND T1.first = 'Wesley' AND T1.last = 'Lemke'
Write SQL query to solve given problem: State the average period of Ms. Angelena Kertzmann's several normal pregnancies.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT CAST(SUM(strftime('%J', T2.STOP) - strftime('%J', T2.START)) AS REAL) / COUNT(T2.PATIENT) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.prefix = 'Ms.' AND T1.first = 'Angelena' AND T1.last = 'Kertzmann' AND T2.description = 'Normal pregnancy'
Write SQL query to solve given problem: What is the id of the patient who has the longest allergy period?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT PATIENT FROM allergies WHERE STOP IS NOT NULL GROUP BY PATIENT ORDER BY CASE WHEN SUBSTR(STOP, -2, 1) != '9' THEN SUBSTR(STOP, LENGTH(STOP) - 1) + 2000 END - CASE WHEN SUBSTR(START, -2, 1) = '9' THEN SUBSTR(START, LENGTH(START) - 1) + 1900 ELSE SUBSTR(START, LENGTH(START) - 1) + 2000 END LIMIT 1
Write SQL query to solve given problem: How many patients have diabetes that started in 1988?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(PATIENT) FROM conditions WHERE DESCRIPTION = 'Diabetes' AND strftime('%Y', START) = '1988'
Write SQL query to solve given problem: How many patients are allergic to eggs?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(PATIENT) FROM allergies WHERE DESCRIPTION = 'Allergy to eggs'
Write SQL query to solve given problem: What is the id of the patient whose hypertension started most recently?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT PATIENT FROM conditions WHERE START = ( SELECT MAX(START) FROM conditions WHERE DESCRIPTION = 'Hypertension' )
Write SQL query to solve given problem: What is the most common allergy among patients?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DESCRIPTION FROM allergies GROUP BY DESCRIPTION ORDER BY COUNT(DESCRIPTION) DESC LIMIT 1
Write SQL query to solve given problem: What is/are the ids of the tallest patient/s?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT PATIENT FROM observations WHERE DESCRIPTION = 'Body Height' AND UNITS = 'cm' ORDER BY VALUE DESC LIMIT 1
Write SQL query to solve given problem: What is the most common condition among the female Americans?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.gender = 'F' AND T1.ethnicity = 'american' GROUP BY T2.DESCRIPTION ORDER BY COUNT(T2.DESCRIPTION) DESC LIMIT 1
Write SQL query to solve given problem: Among the patients that started taking Ibuprofen 200mg Oral Tablet in 2016, how many Dominican patients stopped taking the medicine after exactly one month?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Ibuprofen 200 MG Oral Tablet' AND T1.ethnicity = 'dominican' AND strftime('%Y', T2.START) = '2016' AND strftime('%m', T2.STOP) - strftime('%m', T2.START) = 1
Write SQL query to solve given problem: How many of the patients born in 1920s had pneumonia?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE DESCRIPTION = 'Pneumonia' AND strftime('%Y', T1.birthdate) LIKE '192%'
Write SQL query to solve given problem: What are the full names of the patients who started taking Yaz 28 Day Pack in 2011?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T1.first, T1.last, T1.suffix FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Yaz 28 Day Pack' AND strftime('%Y', T2.START) = '2011'
Write SQL query to solve given problem: How many Black patients were immunized with DTaP in 2013?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T1.race = 'black' AND T2.DESCRIPTION = 'DTaP' AND strftime('%Y', T2.DATE) = '2013'
Write SQL query to solve given problem: How many immunizations did the patient with the most prevalent condition that started recently get?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.patient) FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) INNER JOIN immunizations AS T3 ON T2.PATIENT = T3.PATIENT GROUP BY T2.PATIENT ORDER BY T2.START DESC, T1."PREVALENCE RATE" DESC LIMIT 1
Write SQL query to solve given problem: How many patients have the most prevalent conditions?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.patient) FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON lower(T1.ITEM) = lower(T2.DESCRIPTION) ORDER BY T1."PREVALENCE RATE" DESC LIMIT 1
Write SQL query to solve given problem: What is the most common condition among the patients who received influenza seasonal injectable preservative free immunization?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.DESCRIPTION FROM immunizations AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.DESCRIPTION = 'Influenza seasonal injectable preservative free' GROUP BY T2.DESCRIPTION ORDER BY COUNT(T2.DESCRIPTION) DESC LIMIT 1
Write SQL query to solve given problem: List the ids of all the patients with condition that has a prevalence percentage of 18.8%.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T1.PATIENT FROM conditions AS T1 INNER JOIN all_prevalences AS T2 ON lower(T2.ITEM) = lower(T1.DESCRIPTION) WHERE T2."PREVALENCE PERCENTAGE" = CAST(18.8 AS float)
Write SQL query to solve given problem: How many conditions did Tyree Eichmann have?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.DESCRIPTION) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Tyree' AND T1.last = 'Eichmann'
Write SQL query to solve given problem: Among the patients who were immunized with meningococcal MCV4P, how many have viral sinusitis disorder after getting the immunization?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T1.patient) FROM immunizations AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T1.DESCRIPTION = 'meningococcal MCV4P' AND T2.DESCRIPTION = 'Viral sinusitis (disorder)'
Write SQL query to solve given problem: Among the patients with prediabetes, how many are female?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.gender = 'F' AND T1.DESCRIPTION = 'Prediabetes'
Write SQL query to solve given problem: Indicate the patient's full name with the lowest body mass index in kg/m2.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Body Mass Index' AND T2.UNITS = 'kg/m2' ORDER BY T2.VALUE LIMIT 1
Write SQL query to solve given problem: What is the age of the patient with hypertension named Giovanni Russel?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) AS age FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.first = 'Giovanni' AND T2.last = 'Russel' AND T1.DESCRIPTION = 'Hypertension'
Write SQL query to solve given problem: How many Asian female patients take oxaliplatin 5 MG/ML [Eloxatin]?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.patient) FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'oxaliplatin 5 MG/ML [Eloxatin]' AND T2.race = 'asian' AND T2.gender = 'F'
Write SQL query to solve given problem: Count all of the living patients that had a stroke.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(DISTINCT T2.patient) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.description = 'Stroke' AND T2.deathdate IS NULL
Write SQL query to solve given problem: What is the total number of Asian patients who are allergic to peanuts?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.patient) FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Allergy to peanuts' AND T2.race = 'asian'
Write SQL query to solve given problem: Among the patients with hypertension, what is the average of their diastolic blood pressure?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT AVG(T1.VALUE) FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN conditions AS T3 ON T2.patient = T3.PATIENT WHERE T3.DESCRIPTION = 'Hypertension' AND T1.DESCRIPTION = 'Diastolic Blood Pressure'
Write SQL query to solve given problem: What is the medicine prescribed for the patient with social security number 999-94-3751?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.DESCRIPTION FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ssn = '999-94-3751'
Write SQL query to solve given problem: Give the social security number of the female Irish patient allergic to grass pollen.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.ssn FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Allergy to grass pollen' AND T2.ethnicity = 'irish' AND T2.gender = 'F'
Write SQL query to solve given problem: Who is the patient involved in the care plan with code 311791003?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.CODE = 315043002
Write SQL query to solve given problem: Among the patients that died, what is the condition of the oldest patient?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.DESCRIPTION FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.deathdate IS NOT NULL ORDER BY strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) DESC LIMIT 1
Write SQL query to solve given problem: What is the code of the prevalent disease with the highest occurrences?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.code FROM all_prevalences AS T1 INNER JOIN conditions AS T2 ON T1.ITEM = T2.DESCRIPTION ORDER BY T1.OCCURRENCES DESC LIMIT 1
Write SQL query to solve given problem: What is the glucose level of the patient that lives at 365 Della Crossroad Suite 202, Deerfield, MA 01342 US?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T2.DESCRIPTION, T2.VALUE, T2.UNITS FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Glucose' AND T1.address = '365 Della Crossroad Suite 202 Deerfield MA 01342 US'
Write SQL query to solve given problem: Provide at least 5 social security numbers of patients with a prevalent disease with a prevalence percentage lower than 30% of the average prevalence percentage of conditions.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT DISTINCT T2.ssn FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN all_prevalences AS T3 ON lower(T1.DESCRIPTION) = lower(T3.ITEM) WHERE CAST(T3."PREVALENCE PERCENTAGE" AS REAL) * 100 / ( SELECT AVG('PREVALENCE PERCENTAGE') FROM all_prevalences ) < 30 LIMIT 5
Write SQL query to solve given problem: Among the patients with acute bronchitis, what is the percentage of Asian women?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT CAST(SUM(CASE WHEN T2.gender = 'F' AND T2.race = 'asian' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T2.gender) FROM conditions AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Acute bronchitis (disorder)'
Write SQL query to solve given problem: Provide the number of encounters for Major D'Amore.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.ID) FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Major' AND T1.last = 'D''Amore'
Write SQL query to solve given problem: List the procedures received by Emmy Waelchi.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Emmy' AND T1.last = 'Waelchi'
Write SQL query to solve given problem: Provide the patients' full names who received the extraction of wisdom tooth.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Extraction of wisdom tooth'
Write SQL query to solve given problem: Provide the body weight of Elly Koss in every observation.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T2.DESCRIPTION, T2.VALUE, T2.UNITS FROM patients AS T1 INNER JOIN observations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Elly' AND T1.last = 'Koss' AND T2.DESCRIPTION = 'Body Weight'
Write SQL query to solve given problem: Name the patients who had an allergy to soy.. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to soya'
Write SQL query to solve given problem: How many times did Keven Kuhn receive DTaP immunization?. Keep the solution inside sql tag ```sql [SQL-Query] ```
synthea
SELECT COUNT(T2.CODE) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Keven' AND T1.last = 'Kuhn' AND T2.DESCRIPTION = 'DTaP'