input
stringlengths 193
2.69k
| output
stringlengths 24
744
|
|---|---|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: According to the observation on 2008/3/11, what was the height of Elly Koss? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: By how much did Elly Koss's weight increase from the observation in 2008 to the observation in 2009? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: During all the observations of Elly Koss, what was the highest Systolic Blood Pressure observed? [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: For how many times had Elly Koss have her Systolic Blood Pressure observed? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: The highest Systolic Blood Pressure was observed in which patient? Please give his or her full name. [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: For how long was Elly Koss required to take Acetaminophen? [/INST]
|
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%';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Please list all the medication that are prescribed to Elly Koss. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Why did Elly Koss need to take Acetaminophen? [/INST]
|
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%';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What medication did Elly Koss take when she had Streptococcal sore throat? [/INST]
|
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)';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Please give the full names of all the patients who had been prescribed with Acetaminophen. [/INST]
|
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%';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What was the condition of Elly Koss on 2009/1/8? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: For how long did Elly Koss's cystitis last? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: According to all the observations of Elly Koss, what was her average weight? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Among all the patients who once had cystitis, what was the percentage of them being married? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: Give the body height status of Mr. Vincent Wyman on 2010/8/2. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many care plans has Mrs. Norman Berge taken? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Why did Mrs. Annabelle Pouros take leucovorin 100 mg injection on 1970/12/19? State the reason. [/INST]
|
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';
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the prevalence percentage of condition no. 64859006? [/INST]
|
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';
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: State the prevalence rate of condition no. 368581000119106. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Give the procedure description of Ms. Jacquelyn Shanahan on 2009/8/9. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
claims :
ID [ TEXT ] primary_key
PATIENT [ TEXT ]
BILLABLEPERIOD [ DATE ]
ORGANIZATION [ TEXT ]
ENCOUNTER [ TEXT ]
DIAGNOSIS [ TEXT ]
TOTAL [ INTEGER ]
Please write me a SQL statement that answers the following question: Give the number of claims did Ms. Abbie Cole have in the year of 2011. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many allergies does Mrs. Saundra Monahan have? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
claims :
ID [ TEXT ] primary_key
PATIENT [ TEXT ]
BILLABLEPERIOD [ DATE ]
ORGANIZATION [ TEXT ]
ENCOUNTER [ TEXT ]
DIAGNOSIS [ TEXT ]
TOTAL [ INTEGER ]
Please write me a SQL statement that answers the following question: Provide the name of the patient who had a claim on 1947/9/11. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
encounters :
ID [ TEXT ] primary_key
DATE [ DATE ]
PATIENT [ TEXT ] encounters.PATIENT = patients.patient
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Describe the encounter of Mr. Hubert Baumbach on 2008/10/25. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What kind of condition did Keven Kuhn have from 2016/9/24 to 2016/10/10? Describe the condition. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: When did Mrs. Ira Deckow have the standard pregnancy test? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the average period of Mr. Wesley Lemke's care plans. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: State the average period of Ms. Angelena Kertzmann's several normal pregnancies. [/INST]
|
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';
|
[INST] Here is a database schema:
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What is the id of the patient who has the longest allergy period? [/INST]
|
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;
|
[INST] Here is a database schema:
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: How many patients have diabetes that started in 1988? [/INST]
|
SELECT COUNT(PATIENT) FROM conditions WHERE DESCRIPTION = 'Diabetes' AND strftime('%Y', START) = '1988';
|
[INST] Here is a database schema:
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients are allergic to eggs? [/INST]
|
SELECT COUNT(PATIENT) FROM allergies WHERE DESCRIPTION = 'Allergy to eggs';
|
[INST] Here is a database schema:
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the id of the patient whose hypertension started most recently? [/INST]
|
SELECT PATIENT FROM conditions WHERE START = ( SELECT MAX(START) FROM conditions WHERE DESCRIPTION = 'Hypertension' );
|
[INST] Here is a database schema:
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What is the most common allergy among patients? [/INST]
|
SELECT DESCRIPTION FROM allergies GROUP BY DESCRIPTION ORDER BY COUNT(DESCRIPTION) DESC LIMIT 1;
|
[INST] Here is a database schema:
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: What is/are the ids of the tallest patient/s? [/INST]
|
SELECT PATIENT FROM observations WHERE DESCRIPTION = 'Body Height' AND UNITS = 'cm' ORDER BY VALUE DESC LIMIT 1;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the most common condition among the female Americans? [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Among the patients that started taking Ibuprofen 200mg Oral Tablet in 2016, how many Dominican patients stopped taking the medicine after exactly one month? [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: How many of the patients born in 1920s had pneumonia? [/INST]
|
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%';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What are the full names of the patients who started taking Yaz 28 Day Pack in 2011? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many Black patients were immunized with DTaP in 2013? [/INST]
|
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';
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many immunizations did the patient with the most prevalent condition that started recently get? [/INST]
|
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;
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: How many patients have the most prevalent conditions? [/INST]
|
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;
|
[INST] Here is a database schema:
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What is the most common condition among the patients who received influenza seasonal injectable preservative free immunization? [/INST]
|
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;
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: List the ids of all the patients with condition that has a prevalence percentage of 18.8%. [/INST]
|
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);
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: How many conditions did Tyree Eichmann have? [/INST]
|
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';
|
[INST] Here is a database schema:
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Among the patients who were immunized with meningococcal MCV4P, how many have viral sinusitis disorder after getting the immunization? [/INST]
|
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)';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Among the patients with prediabetes, how many are female? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: Indicate the patient's full name with the lowest body mass index in kg/m2. [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the age of the patient with hypertension named Giovanni Russel? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many Asian female patients take oxaliplatin 5 MG/ML [Eloxatin]? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Count all of the living patients that had a stroke. [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What is the total number of Asian patients who are allergic to peanuts? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: Among the patients with hypertension, what is the average of their diastolic blood pressure? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What is the medicine prescribed for the patient with social security number 999-94-3751? [/INST]
|
SELECT T1.DESCRIPTION FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T2.ssn = '999-94-3751';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Give the social security number of the female Irish patient allergic to grass pollen. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Who is the patient involved in the care plan with code 311791003? [/INST]
|
SELECT T2.first, T2.last FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.CODE = 315043002;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Among the patients that died, what is the condition of the oldest patient? [/INST]
|
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;
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the code of the prevalent disease with the highest occurrences? [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: What is the glucose level of the patient that lives at 365 Della Crossroad Suite 202, Deerfield, MA 01342 US? [/INST]
|
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';
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: 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. [/INST]
|
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;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Among the patients with acute bronchitis, what is the percentage of Asian women? [/INST]
|
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)';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
encounters :
ID [ TEXT ] primary_key
DATE [ DATE ]
PATIENT [ TEXT ] encounters.PATIENT = patients.patient
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Provide the number of encounters for Major D'Amore. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: List the procedures received by Emmy Waelchi. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Provide the patients' full names who received the extraction of wisdom tooth. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: Provide the body weight of Elly Koss in every observation. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Name the patients who had an allergy to soy. [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many times did Keven Kuhn receive DTaP immunization? [/INST]
|
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';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Who had to take Clopidogrel 75 MG Oral Tablet for over 10 years? [/INST]
|
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Clopidogrel 75 MG Oral Tablet' AND strftime('%Y', T2.STOP) - strftime('%Y', T2.START) > 10;
|
[INST] Here is a database schema:
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Which procedures and medications were received by the patient with the third-degree burn? [/INST]
|
SELECT DISTINCT T1.DESCRIPTION, T3.DESCRIPTION FROM procedures AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT INNER JOIN medications AS T3 ON T2.patient = T3.PATIENT WHERE T2.DESCRIPTION = 'Third degree burn';
|
[INST] Here is a database schema:
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Provide medications received by patients with an allergy to mould on 6th June 2016. [/INST]
|
SELECT T2.DESCRIPTION FROM allergies AS T1 INNER JOIN medications AS T2 ON T1.PATIENT = T2.PATIENT WHERE T1.START = '6/6/16' AND T1.DESCRIPTION = 'Allergy to mould';
|
[INST] Here is a database schema:
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: Describe the care plans received by the patient with secondary malignant neoplasm of the colon. [/INST]
|
SELECT DISTINCT T1.DESCRIPTION FROM careplans AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Secondary malignant neoplasm of colon';
|
[INST] Here is a database schema:
all_prevalences :
ITEM [ TEXT ] primary_key
POPULATION TYPE [ TEXT ]
OCCURRENCES [ INTEGER ]
POPULATION COUNT [ INTEGER ]
PREVALENCE RATE [ REAL ]
PREVALENCE PERCENTAGE [ REAL ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: What is the prevalence rate of the patients' diseases started on 9th May 2014? [/INST]
|
SELECT T2."PREVALENCE RATE" FROM conditions AS T1 INNER JOIN all_prevalences AS T2 ON lower(T1.DESCRIPTION) = lower(T2.ITEM) WHERE T1.START = '2014-05-09';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: Among observations in 2011, provide the names and ages of patients whose Systolic Blood Pressures are 200mmHg. [/INST]
|
SELECT T2.first, T2.last , CASE WHEN T2.deathdate IS NULL THEN strftime('%Y', T1.DATE) - strftime('%Y', T2.birthdate) ELSE strftime('%Y', T2.deathdate) - strftime('%Y', T2.birthdate) END AS age FROM observations AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.DESCRIPTION = 'Systolic Blood Pressure' AND T1.VALUE = 200 AND T1.UNITS = 'mmHg' AND strftime('%Y', T1.DATE) = '2011';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following 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? [/INST]
|
SELECT CAST(SUM(CASE WHEN T2.DESCRIPTION = 'Influenza seasonal injectable preservative free' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.patient), SUM(CASE WHEN T1.ethnicity = 'english' THEN 1 ELSE 0 END) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE strftime('%Y', T2.DATE) = '2017';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
encounters :
ID [ TEXT ] primary_key
DATE [ DATE ]
PATIENT [ TEXT ] encounters.PATIENT = patients.patient
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: List down the first name of patients who encountered normal pregnancy. [/INST]
|
SELECT DISTINCT T1.first FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'Normal pregnancy';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
encounters :
ID [ TEXT ] primary_key
DATE [ DATE ]
PATIENT [ TEXT ] encounters.PATIENT = patients.patient
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What are the birth date of patients who took outpatient encounter care plan? [/INST]
|
SELECT DISTINCT T1.birthdate FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Outpatient Encounter';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: List down the first name of patients who have cystitis condition. [/INST]
|
SELECT DISTINCT T1.first FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Cystitis';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: How many stroke patients have married? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Stroke' AND T1.marital = 'M';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
claims :
ID [ TEXT ] primary_key
PATIENT [ TEXT ]
BILLABLEPERIOD [ DATE ]
ORGANIZATION [ TEXT ]
ENCOUNTER [ TEXT ]
DIAGNOSIS [ TEXT ]
TOTAL [ INTEGER ]
Please write me a SQL statement that answers the following question: List down the address of patients who have billable period in 2010. [/INST]
|
SELECT DISTINCT T1.address FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T2.BILLABLEPERIOD LIKE '2010%';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: List down the last name of patients who are allergic to dairy products. [/INST]
|
SELECT DISTINCT T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to dairy product';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: When the allergy starts for Angelo Buckridge. [/INST]
|
SELECT T2.START FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Adolfo' AND T1.last = 'Schmitt' AND T2.STOP IS NOT NULL;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many of the male patients are allergic to house dust mites? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'House dust mite allergy' AND T1.gender = 'M';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What kind of allergy is most common among white people? [/INST]
|
SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.race = 'white' GROUP BY T2.DESCRIPTION ORDER BY COUNT(T2.DESCRIPTION) DESC LIMIT 1;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: List down the first name of patients who received "Influenza seasonal injectable preservative free" immunization. [/INST]
|
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Influenza seasonal injectable preservative free';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the number of female patients who accepted "HPV quadrivalent" immunization. [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV quadrivalent' AND T1.gender = 'F';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
encounters :
ID [ TEXT ] primary_key
DATE [ DATE ]
PATIENT [ TEXT ] encounters.PATIENT = patients.patient
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: List down the encounter descriptions of patients who were born in Pittsfield MA US. [/INST]
|
SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.birthplace = 'Pittsfield MA US';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the total type of allergies for German people. [/INST]
|
SELECT COUNT(DISTINCT T2.DESCRIPTION) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.ethnicity = 'german';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Calculate the average age of patients with prediabetes care plan. [/INST]
|
SELECT CAST(SUM(CASE WHEN T1.deathdate IS NULL THEN strftime('%Y', T2.STOP) - strftime('%Y', T1.birthdate) ELSE strftime('%Y', T1.deathdate) - strftime('%Y', T1.birthdate) END) AS REAL) / COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'Prediabetes';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many of the patients who have stopped taking medication for 'coronary heart disease' are still alive? [/INST]
|
SELECT COUNT(DISTINCT T2.patient) FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.REASONDESCRIPTION = 'Coronary Heart Disease' AND T1.STOP IS NOT NULL AND T2.deathdate IS NULL;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
procedures :
DATE [ DATE ]
PATIENT [ TEXT ] procedures.PATIENT = patients.patient
ENCOUNTER [ TEXT ] procedures.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many of the patients who underwent a 'bone immobilization' procedure have a driver's license? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Bone immobilization' AND T1.drivers IS NOT NULL;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: Indicate the full name of the patients who have 3 different allergies. [/INST]
|
SELECT T1.first, T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT GROUP BY T1.patient ORDER BY COUNT(DISTINCT T2.DESCRIPTION) > 3;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients with 'allergy to eggs' have been immunized with 'Td (adult) preservative free'? [/INST]
|
SELECT COUNT(DISTINCT T2.patient) FROM allergies AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN immunizations AS T3 ON T2.patient = T3.PATIENT WHERE T1.DESCRIPTION = 'Allergy to eggs' AND T3.DESCRIPTION = 'Td (adult) preservative free';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
observations :
DATE [ DATE ]
PATIENT [ TEXT ] observations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] observations.ENCOUNTER = encounters.ID
CODE [ TEXT ]
DESCRIPTION [ TEXT ]
VALUE [ REAL ]
UNITS [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients with a body weight of more than 100 kg have a 'diabetes self-management plan' care plan? [/INST]
|
SELECT COUNT(DISTINCT T2.patient) FROM careplans AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient INNER JOIN observations AS T3 ON T2.patient = T3.PATIENT WHERE T3.DESCRIPTION = 'Body Weight' AND T1.DESCRIPTION = 'Diabetes self management plan' AND T3.VALUE > 100 AND T3.UNITS = 'kg';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What gender is more prone to 'dander (animal) allergy'? [/INST]
|
SELECT T1.gender FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Dander (animal) allergy' GROUP BY T1.gender ORDER BY COUNT(T1.gender) DESC LIMIT 1;
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
claims :
ID [ TEXT ] primary_key
PATIENT [ TEXT ]
BILLABLEPERIOD [ DATE ]
ORGANIZATION [ TEXT ]
ENCOUNTER [ TEXT ]
DIAGNOSIS [ TEXT ]
TOTAL [ INTEGER ]
Please write me a SQL statement that answers the following question: On what dates did the billable period begin for patients with the last name Dickinson? [/INST]
|
SELECT DISTINCT T2.BILLABLEPERIOD FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T1.last = 'Dickinson';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
conditions :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] conditions.PATIENT = patients.patient
ENCOUNTER [ TEXT ] conditions.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ] conditions.DESCRIPTION = all_prevalences.ITEM
Please write me a SQL statement that answers the following question: List the full name of all patients with 'otitis media'. [/INST]
|
SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Otitis media';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients of Irish ethnicity take medication for 'myocardial infarction'? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'Myocardial Infarction' AND T1.ethnicity = 'irish';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients with care plan for 'concussion with loss of consciousness' are married? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T1.marital = 'M' AND T2.REASONDESCRIPTION = 'Concussion with loss of consciousness';
|
[INST] Here is a database schema:
careplans :
ID [ TEXT ]
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] careplans.PATIENT = patients.patient
ENCOUNTER [ TEXT ] careplans.ENCOUNTER = encounters.ID
CODE [ REAL ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
immunizations :
DATE [ DATE ]
PATIENT [ TEXT ] immunizations.PATIENT = patients.patient
ENCOUNTER [ TEXT ] immunizations.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many patients immunized against 'monovalent rotavirus' ceased their care plan on 11/23/2013? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM careplans AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'rotavirus monovalent' AND T1.STOP = '2013-11-23';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
medications :
START [ DATE ]
STOP [ DATE ]
PATIENT [ TEXT ] medications.PATIENT = patients.patient
ENCOUNTER [ TEXT ] medications.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
REASONCODE [ INTEGER ]
REASONDESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: How many women need to take 'Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual]'? [/INST]
|
SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN medications AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Nitroglycerin 0.4 MG/ACTUAT [Nitrolingual]' AND T1.gender = 'F';
|
[INST] Here is a database schema:
patients :
patient [ TEXT ] primary_key
birthdate [ DATE ]
deathdate [ DATE ]
ssn [ TEXT ]
drivers [ TEXT ]
passport [ TEXT ]
prefix [ TEXT ]
first [ TEXT ]
last [ TEXT ]
suffix [ TEXT ]
maiden [ TEXT ]
marital [ TEXT ]
race [ TEXT ]
ethnicity [ TEXT ]
gender [ TEXT ]
birthplace [ TEXT ]
address [ TEXT ]
allergies :
START [ TEXT ]
STOP [ TEXT ]
PATIENT [ TEXT ] allergies.PATIENT = patients.patient
ENCOUNTER [ TEXT ] allergies.ENCOUNTER = encounters.ID
CODE [ INTEGER ]
DESCRIPTION [ TEXT ]
Please write me a SQL statement that answers the following question: What percentage of patients born in 'Pembroke MA US' have 'allergy to grass pollen'? [/INST]
|
SELECT CAST(SUM(CASE WHEN T2.DESCRIPTION = 'Allergy to grass pollen' THEN 1 ELSE 0 END) AS REL) * 100 / COUNT(T1.patient) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.birthplace = 'Pembroke MA US';
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.