Chinastark/bird_dataset huggingface dataset:
Database: synthea
Note: care plans refer to description from careplans; secondary malignant neoplasm of the colon refers to conditions where description = 'Secondary malignant neoplasm of colon';
Question: Describe the care plans received by the patient with secondary malignant neoplasm of the colon.
SQL: SELECT DISTINCT careplans.description FROM careplans INNER JOIN conditions ON careplans.patient = conditions.patient WHERE conditions.description = 'Secondary malignant neoplasm of colon'
Database: synthea
Note: diseases started on 9th May 2014 refer to description from conditions where start = '5/9/2014';
Question: What is the prevalence rate of the patients' diseases started on 9th May 2014?
SQL: SELECT all_prevalences."PREVALENCE RATE" FROM conditions INNER JOIN all_prevalences ON lower(conditions.description) = lower(all_prevalences.item) WHERE conditions.start = '2014-05-09'
Database: synthea
Note: name implies the patient's full name which refers to first, last; age refers to deathdate is null then SUBTRACT(strftime('%Y', date), strftime('%Y', birthdate)); Systolic Blood Pressures are 200mmHg refers to description = 'Systolic Blood Pressure' and value = 200 and units = 'mmHg' from observations; in 2011 refers to date like '2011%';
Question: Among observations in 2011, provide the names and ages of patients whose Systolic Blood Pressures are 200mmHg.
SQL: SELECT patients.first, patients.last , CASE WHEN patients.deathdate IS NULL THEN strftime('%Y', observations.date) - strftime('%Y', patients.birthdate) ELSE strftime('%Y', patients.deathdate) - strftime('%Y', patients.birthdate) END AS age FROM observations INNER JOIN patients ON observations.patient = patients.patient WHERE observations.description = 'Systolic Blood Pressure' AND observations.value = 200 AND observations.units = 'mmHg' AND strftime('%Y', observations.date) = '2011'
Database: synthea
Note: DIVidE(COUNT(patient when description = 'Influenza seasonal injectable preservative free'), COUNT(patient)) as percentage where strftime('%Y', 2017); English refers ethnicity = 'english';
Question: Among the immunizations in 2017, calculate the percentage of patients who received the Influenza seasonal injectable preservative free. Among them, how many patients are English?
SQL: SELECT cast(sum(CASE WHEN immunizations.description = 'Influenza seasonal injectable preservative free' THEN 1 ELSE 0 END) AS REAL) * 100 / count(patients.patient), sum(CASE WHEN patients.ethnicity = 'english' THEN 1 ELSE 0 END) FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE strftime('%Y', immunizations.date) = '2017'
Database: synthea
Note: encountered normal pregnancy refers to encounters where reasondescription = 'Normal pregnancy';
Question: List down the first name of patients who encountered normal pregnancy.
SQL: SELECT DISTINCT patients.first FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE encounters.reasondescription = 'Normal pregnancy'
Database: synthea
Note: outpatient encounter care plan refers to careplans where description = 'Outpatient encounter';
Question: What are the birth date of patients who took outpatient encounter care plan?
SQL: SELECT DISTINCT patients.birthdate FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE encounters.description = 'Outpatient Encounter'
Database: synthea
Note: cystitis refers to conditions where description = 'Cystitis';
Question: List down the first name of patients who have cystitis condition.
SQL: SELECT DISTINCT patients.first FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Cystitis'
Database: synthea
Note: stroke refers to conditions where description = 'Stroke'; married refers to the marital status of the patient in which marital = 'M';
Question: How many stroke patients have married?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Stroke' AND patients.marital = 'M'
Database: synthea
Question: List down the address of patients who have billable period in 2010.
SQL: SELECT DISTINCT patients.address FROM patients INNER JOIN claims ON patients.patient = claims.patient WHERE claims.billableperiod LIKE '2010%'
Database: synthea
Note: allergic to dairy products refers to allergies where description = 'Allergy to dairy product';
Question: List down the last name of patients who are allergic to dairy products.
SQL: SELECT DISTINCT patients.last FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'Allergy to dairy product'
Database: synthea
Question: When the allergy starts for Angelo Buckridge.
SQL: SELECT allergies.start FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE patients.first = 'Adolfo' AND patients.last = 'Schmitt' AND allergies.stop IS NOT NULL
Database: synthea
Note: male patients refer to patient where gender = 'M'; allergic to house dust mites refers to allergies where description = 'House dust mite allergy';
Question: How many of the male patients are allergic to house dust mites?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'House dust mite allergy' AND patients.gender = 'M'
Database: synthea
Note: kind of allergy is most common refers to MAX(COUNT(description)) from allergies; white refers to race = 'white';
Question: What kind of allergy is most common among white people?
SQL: SELECT allergies.description FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE patients.race = 'white' GROUP BY allergies.description ORDER BY count(allergies.description) DESC LIMIT 1
Database: synthea
Note: "Influenza seasonal injectable preservative free" immunization refers to immunizations where description = 'Influenza seasonal injectable preservative free';
Question: List down the first name of patients who received "Influenza seasonal injectable preservative free" immunization.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'Influenza  seasonal  injectable  preservative free'
Database: synthea
Note: female refers to gender = 'F'; "HPV quadrivalent" immunization refers to immunizations where description = 'HPV quadrivalent';
Question: Calculate the number of female patients who accepted "HPV quadrivalent" immunization.
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'HPV  quadrivalent' AND patients.gender = 'F'
Database: synthea
Note: born in Pittsfield MA US refers to birthplace = 'Pittsfield MA US';
Question: List down the encounter descriptions of patients who were born in Pittsfield MA US.
SQL: SELECT DISTINCT encounters.description FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.birthplace = 'Pittsfield MA US'
Database: synthea
Note: type of allergies refers to description from allergies; German people refer to patient where ethnicity = 'german';
Question: Calculate the total type of allergies for German people.
SQL: SELECT count(DISTINCT allergies.description) FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE patients.ethnicity = 'german'
Database: synthea
Note: SUBTRACT(SUM(deathdate), SUM(birthdate)), COUNT(patient) where reasondescription = 'Prediabetes' from careplans;
Question: Calculate the average age of patients with prediabetes care plan.
SQL: SELECT cast(sum(CASE WHEN patients.deathdate IS NULL THEN strftime('%Y', careplans.stop) - strftime('%Y', patients.birthdate) ELSE strftime('%Y', patients.deathdate) - strftime('%Y', patients.birthdate) END) AS REAL) / count(DISTINCT patients.patient) FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE careplans.reasondescription = 'Prediabetes'
Database: synthea
Note: patients who have stopped taking medication for 'coronary heart disease' refer to patient where reasondescription = 'Coronary Heart Disease' and stop is not null from medications; if deathdate is null, it means this patient is still alive;
Question: How many of the patients who have stopped taking medication for 'coronary heart disease' are still alive?
SQL: SELECT count(DISTINCT patients.patient) FROM medications INNER JOIN patients ON medications.patient = patients.patient WHERE medications.reasondescription = 'Coronary Heart Disease' AND medications.stop IS NOT NULL AND patients.deathdate IS NULL
Database: synthea
Note: patients who underwent a 'bone immobilization' procedure refer to patient from procedures where description = 'Bone immobilization'; have a driver's license refers to drivers is not null;
Question: How many of the patients who underwent a 'bone immobilization' procedure have a driver's license?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN procedures ON patients.patient = procedures.patient WHERE procedures.description = 'Bone immobilization' AND patients.drivers IS NOT NULL
Database: synthea
Note: full name refers to first, last; have 3 different allergies refer to allergies where COUNT(description) > 3;
Question: Indicate the full name of the patients who have 3 different allergies.
SQL: SELECT patients.first, patients.last FROM patients INNER JOIN allergies ON patients.patient = allergies.patient GROUP BY patients.patient ORDER BY count(DISTINCT allergies.description) > 3
Database: synthea
Note: allergy to eggs' refers to allergies where description = 'Allergy to eggs'; immunized with 'Td (adult) preservative free' refers to immunizations where description = 'Td (adult) preservative free';
Question: How many patients with 'allergy to eggs' have been immunized with 'Td (adult) preservative free'?
SQL: SELECT count(DISTINCT patients.patient) FROM allergies INNER JOIN patients ON allergies.patient = patients.patient INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE allergies.description = 'Allergy to eggs' AND immunizations.description = 'Td (adult) preservative free'
Database: synthea
Note: body weight of more than 100 kg refers to observations.description = 'Body Weight' AND observations.value > 100 AND observations.units = 'kg'; diabetes self-management plan refers to careplans.description = 'Diabetes self management plan';
Question: How many patients with a body weight of more than 100 kg have a 'diabetes self-management plan' care plan?
SQL: SELECT count(DISTINCT patients.patient) FROM careplans INNER JOIN patients ON careplans.patient = patients.patient INNER JOIN observations ON patients.patient = observations.patient WHERE observations.description = 'Body Weight' AND careplans.description = 'Diabetes self management plan' AND observations.value > 100 AND observations.units = 'kg'
Database: synthea
Note: gender who is more prone to dander (animal) allergy refers to MAX(COUNT(gender WHERE allergies.description = 'Dander (animal) allergy'));
Question: What gender is more prone to 'dander (animal) allergy'?
SQL: SELECT patients.gender FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'Dander (animal) allergy' GROUP BY patients.gender ORDER BY count(patients.gender) DESC LIMIT 1
Database: synthea
Note: dates when the billable period begin refers to billableperiod;
Question: On what dates did the billable period begin for patients with the last name Dickinson?
SQL: SELECT DISTINCT claims.billableperiod FROM patients INNER JOIN claims ON patients.patient = claims.patient WHERE patients.last = 'Dickinson'
Database: synthea
Note: full name = first, last; otitis media refers to conditions.description = 'Otitis media';
Question: List the full name of all patients with 'otitis media'.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Otitis media'
Database: synthea
Note: take medication for myocardial infarction refers to medications.reasondescription = 'Myocardial Infarction';
Question: How many patients of Irish ethnicity take medication for 'myocardial infarction'?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.reasondescription = 'Myocardial Infarction' AND patients.ethnicity = 'irish'
Database: synthea
Note: concussion with loss of consciousness refers to careplans.description = 'Concussion with loss of consciousness'; married refers to marital = 'M';
Question: How many patients with care plan for 'concussion with loss of consciousness' are married?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.marital = 'M' AND careplans.reasondescription = 'Concussion with loss of consciousness'
Database: synthea
Note: immunized against monovalent rotavirus refers to immunizations.description = 'rotavirus monovalent'; ceased their care plan on 11/23/2013 refers to careplans.stop = '2013-11-23';
Question: How many patients immunized against 'monovalent rotavirus' ceased their care plan on 11/23/2013?
SQL: SELECT count(DISTINCT careplans.patient) FROM careplans INNER JOIN immunizations ON careplans.patient = immunizations.patient WHERE immunizations.description = 'rotavirus  monovalent' AND careplans.stop = '2013-11-23'
Database: synthea
Note: women refers to gender = 'F'; Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual] refers to medications.description = 'Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual]';
Question: How many women need to take 'Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual]'?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.description = 'Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual]' AND patients.gender = 'F'
Database: synthea
Note: percentage = MULTIPLY(DIVidE(SUM(patient WHERE allergies.description = 'Allergy to grass pollen'), COUNT(patient) WHERE birthplace = 'Pembroke MA US'), 100.0); born in Pembroke MA US refers to birthplace = 'Pembroke MA US'; allergy to grass pollen refers to allergies.description = 'Allergy to grass';
Question: What percentage of patients born in 'Pembroke MA US' have 'allergy to grass pollen'?
SQL: SELECT cast(sum(CASE WHEN allergies.description = 'Allergy to grass pollen' THEN 1 ELSE 0 END) AS rel) * 100 / count(patients.patient) FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE patients.birthplace = 'Pembroke MA US'
Database: synthea
Note: average = AVG(observations.value WHERE observations.description = 'Body Weight' AND observations.units = 'kg'); body weight refers to observations.description = 'Body Weight'; Asian refers to race = 'asian';
Question: What is the average body weight of Asian patients?
SQL: SELECT sum(observations.value) / count(patients.patient) FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.race = 'asian' AND observations.description = 'Body Weight' AND observations.units = 'kg'
Database: synthea
Note: Social Security numbers refers to ssn; latex allergies refers to allergies.description = 'Latex allergy';
Question: Write down the Social Security numbers of patients who have latex allergies.
SQL: SELECT patients.ssn FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'Latex allergy'
Database: synthea
Note: how long the allergies last = SUBTRACT(allergies.stop, allergies.start); kind of allergy refers to allergies.description;
Question: How long did Isadora Moen's allergy last? Tell me what kind of allergy she has.
SQL: SELECT CASE WHEN substr(allergies.stop, -2, 1) != '9' THEN substr(allergies.stop, length(allergies.stop) - 1) + 2000 END - CASE WHEN substr(allergies.start, -2, 1) = '9' THEN substr(allergies.start, length(allergies.start) - 1) + 1900 ELSE substr(allergies.start, length(allergies.start) - 1) + 2000 END AS years , allergies.description FROM allergies INNER JOIN patients ON patients.patient = allergies.patient WHERE allergies.stop IS NOT NULL AND allergies.start IS NOT NULL AND patients.first = 'Isadora' AND patients.last = 'Moen'
Database: synthea
Note: between 1/11/2009 and 10/23/2010 refers to careplans.start between '2009-11-1' and '2010-10-23';
Question: How many times was Elly Koss given a care plan between 1/11/2009 and 10/23/2010?
SQL: SELECT count(careplans.patient) FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND careplans.start BETWEEN '2009-01-11' AND '2010-10-23'
Database: synthea
Note: in 2009 refers to year(careplans.start) = 2009; married patients refers to marital = 'M'; undergone a care plan for more than 60 days refers to SUBTRACT(careplans.stop, careplans.start) > 60;
Question: In 2009, who among the married patients had undergone a care plan for more than 60 days?
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.marital = 'M' AND strftime('%J', careplans.stop) - strftime('%J', careplans.start) > 60
Database: synthea
Note: date of immunization refers to immunizations.date; immunized with the influenza seasonal injectable preservative-free vaccine refers to immunizations.description = 'Influenza seasonal injectable preservative free';
Question: Please provide the dates on which Elly Koss was immunized with the influenza seasonal injectable preservative-free vaccine.
SQL: SELECT immunizations.date FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'Influenza  seasonal  injectable  preservative free' AND patients.first = 'Elly' AND patients.last = 'Koss'
Database: synthea
Note: From 7/9/2010 to 10/29/2013 refers to date between '2010-07-09' and '2013-10-29'; black patients refers to race = 'black'; immunized with the meningococcal MCV4P vaccine refers to immunizations.description = 'meningococcal MCV4P';
Question: From 7/9/2010 to 10/29/2013, how many black patients were immunized with the meningococcal MCV4P vaccine?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'meningococcal MCV4P' AND immunizations.date BETWEEN '2010-07-09' AND '2013-10-29' AND patients.race = 'black'
Database: synthea
Note: immunization codes refers to immunizations.code; immunization dates refers to immunizations.date; immunized with influenza seasonal injectable preservative-free vaccine refers to immunizations.description = 'Influenza seasonal injectable preservative free'; 4 consecutive years refers to 4 succeeding years;
Question: Give me the immunization codes and dates on which Ms. Jacquelyn Shanahan was immunized with influenza seasonal injectable preservative-free vaccine.
SQL: SELECT DISTINCT immunizations.code, immunizations.date FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE patients.prefix = 'Ms.' AND patients.first = 'Jacquelyn' AND patients.last = 'Shanahan' AND immunizations.description = 'Influenza  seasonal  injectable  preservative free'
Database: synthea
Note: how long = SUBTRACT(medications.stop, medications.start); Acetaminophen 160 MG refers to medications.description = 'Acetaminophen 160 MG'; acute bronchitis refers to medications.reasondescription = 'Acute bronchitis (disorder)';
Question: How long did Berry Keebler take the Acetaminophen 160 MG when he was admitted due to acute bronchitis?
SQL: SELECT strftime('%J', medications.stop) - strftime('%J', medications.start) AS takendays FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Berry' AND patients.last = 'Keebler' AND medications.reasondescription = 'Acute bronchitis (disorder)' AND medications.description = 'Acetaminophen 160 MG'
Database: synthea
Note: in 2010 refers to substr(medications.start, 1, 4) = '2010' AND substr(medications.stop, 1, 4) = '2010'; Nitrofurantoin 5 mg/ML [Furadantin] refers to medications.description = 'Nitrofurantoin 5 MG/ML [Furadantin]'; cystitis refers to medications.reasondescription = 'Cystitis';
Question: In 2010, how many single patients took Nitrofurantoin 5 mg/ML [Furadantin] to cure cystitis?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.marital = 'S' AND medications.reasondescription = 'Cystitis' AND medications.description = 'Nitrofurantoin 5 MG/ML [Furadantin]' AND strftime('%Y', medications.start) = '2010'
Database: synthea
Note: reason for encounter refers to encounters.reasondescription; on 11/20/2013 refers to encounters.date = '2013-11-20';
Question: Tell me the reason for Lavelle Vandervort's encounter on 11/20/2013?
SQL: SELECT encounters.reasondescription FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE encounters.date = '2013-11-20' AND patients.first = 'Lavelle' AND patients.last = 'Vandervort'
Database: synthea
Note: From 1/9/2011 to 8/29/2012 refers to encounters.date between '2011-09-01' and '2012-08-29'; German patients refers to ethnicity = 'german'; outpatient encounters refers to encounters.description = 'Outpatient encounter';
Question: From 1/9/2011 to 8/29/2012, how many German patients have their outpatient encounters?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.ethnicity = 'german' AND encounters.date BETWEEN '2011-01-09' AND '2012-08-29' AND encounters.description = 'Outpatient Encounter'
Database: synthea
Note: social security number refers to ssn; encountered viral sinusitis refers to encounters.reasondescription = 'Viral sinusitis (disorder)'; on 6/13/2008 refers to encounters.date = '2008-06-13';
Question: What is the social security number and address of the patient who encountered viral sinusitis symptoms on 6/13/2008?
SQL: SELECT patients.ssn, patients.address FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE encounters.date = '2008-06-13' AND encounters.reasondescription = 'Viral sinusitis (disorder)' AND encounters.description = 'Encounter for symptom'
Database: synthea
Note: reason refers to medications.reasondescription; name of the drug refers to medications.description; duration of medication = SUBTRACT(julianday(medications.stop, julianday(medications.start))); ecounter id refers to encounters.id; encounters.id = '23c293ec-dbae-4a22-896e-f12cf3c8bac3'; if patients.deathdate is null then the patient is alive; if patients.deathdate is not null then the patient is not alive;
Question: Give me the reason, name of the drug, and duration of medication under encounter ID 23c293ec-dbae-4a22-896e-f12cf3c8bac3. Tell me if the patient is still alive.
SQL: SELECT medications.reasondescription, medications.description , strftime('%J', medications.stop) - strftime('%J', medications.start) AS days , CASE WHEN patients.deathdate IS NULL THEN 'alive' ELSE 'dead' END FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.encounter = '23c293ec-dbae-4a22-896e-f12cf3c8bac3'
Database: synthea
Note: shellfish allergies refers to allergies.description = 'Shellfish allergy'; died under 12 years old = DIVidE(SUBTRACT(julianday(patients.deathdate), julianday(patients.birthdate)), 365) < 12; full names = first, last;
Question: How many patients with shellfish allergies died when they were under 12 years old? Please give their full names.
SQL: SELECT patients.first, patients.last FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'Shellfish allergy' AND cast((strftime('%J', patients.deathdate) - strftime('%J', patients.birthdate)) AS REAL) / 365 < 12