instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
is there ground transportation from the airport in DENVER to downtown
### Response:
|
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_code = airport_service.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_name = 'DENVER' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_1.city_code
|
### Instruction:
what was the last time during their last hospital encounter patient 031-24460 had the maximum bun value?
### Response:
|
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-24460' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'bun' ORDER BY lab.labresult DESC, lab.labresulttime DESC LIMIT 1
|
### Instruction:
renal disease ( serum creatinine >= 1.4 mg / dl for male ; >= 1.3 mg / dl for female ) or serum potassium abnormality ( < 3.4 or > 5.5 mmol / l )
### Response:
|
SELECT * FROM table_dev_55 WHERE renal_disease = 1 OR ((serum_creatinine >= 1.4 AND gender = 'male') OR (serum_creatinine >= 1.3 AND gender = 'female')) OR (serum_potassium_abnormality < 3.4 OR serum_potassium_abnormality > 5.5)
|
### Instruction:
how many days has it been since the last time patient 011-55642's procedure during the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-55642' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
how many days has it been since patient 15447 first stayed during this hospital encounter in the ward 23?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15447 AND admissions.dischtime IS NULL)) AND transfers.wardid = 23 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
what is the monthly maximum amount of parathyroid hormone of patient 26849 on the first hospital visit?
### Response:
|
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26849 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'parathyroid hormone') GROUP BY STRFTIME('%y-%m', labevents.charttime)
|
### Instruction:
what were the three most frequent diagnoses for the patients of 20s since 2 years ago?
### Response:
|
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
Post CreationDate is not unique.
### Response:
|
SELECT p.Id AS "a_id", twn.Id AS "b_id", p.CreationDate, p.PostTypeId AS "a_type", twn.PostTypeId AS "b_type", p.Tags AS "a_tags", twn.Tags AS "b_tags", p.Title AS "a_title", twn.Title AS "b_title" FROM Posts AS p INNER JOIN Posts AS twn ON (p.CreationDate = twn.CreationDate AND p.Id < twn.Id) ORDER BY p.CreationDate, p.Id, twn.Id LIMIT 20000
|
### Instruction:
count the number of patients who have undergone ot cerv fusion post/post treatment until 1 year ago.
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'ot cerv fusion post/post') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year'))
|
### Instruction:
how many hours has it passed since the last time patient 015-23047 received a procedure in this hospital visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-23047' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
how many hours has elapsed since patient 027-154299's first procedure on their current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-154299' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
Show the number of courses for each office in a stacked bar chart The x-axis is office name and group by course description, list total number in desc order.
### Response:
|
SELECT PROF_OFFICE, COUNT(PROF_OFFICE) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY CRS_DESCRIPTION, PROF_OFFICE ORDER BY COUNT(PROF_OFFICE) DESC
|
### Instruction:
What is the 2000 kwh p y with a 2400 kwh/kw p y less than 12.5, a 3.8 1600 kwh/kw p y, and a 1800 kwh/kw p y less than 3.3?
### Response:
|
SELECT MAX("2000 kWh/kW p y") FROM table_41662 WHERE "2400 kWh/kW p y" < '12.5' AND "1600 kWh/kW p y" = '3.8' AND "1800 kWh/kW p y" < '3.3'
|
### Instruction:
Questions with outstanding close votes by tag.
### Response:
|
SELECT * FROM (SELECT Posts.Id AS "post_link", AVG(Posts.Score) AS "score", COUNT(*) AS "close_votes", MAX(Votes.CreationDate) AS "last_vote", MIN(Votes.CreationDate) AS "first_vote" FROM Posts JOIN Votes ON Posts.Id = Votes.PostId WHERE Votes.VoteTypeId = 6 AND Posts.ClosedDate IS NULL AND Posts.Tags LIKE '%<##Tag##>%' GROUP BY Posts.Id) AS t WHERE 'close_votes' > 3 ORDER BY 'last_vote' DESC
|
### Instruction:
ground transportation please in the city of BOS between airport and downtown
### Response:
|
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'BOSTON' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
|
### Instruction:
What papers have been written by both Peter Mertens and Dina Barbian ?
### Response:
|
SELECT DISTINCT WRITES_0.paperid FROM author AS AUTHOR_0, author AS AUTHOR_1, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'Peter Mertens' AND AUTHOR_1.authorname = 'Dina Barbian' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = WRITES_0.paperid
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of job_id and the sum of employee_id , and group by attribute job_id, sort by the y axis from low to high.
### Response:
|
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(EMPLOYEE_ID)
|
### Instruction:
how many hours have elapsed since the last time during the current hospital visit patient 55360 got a po2 lab test?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'po2') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 55360 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
what is the monthly average ldl value for patient 006-133605 since 2105?
### Response:
|
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-133605')) AND lab.labname = 'ldl' AND STRFTIME('%y', lab.labresulttime) >= '2105' GROUP BY STRFTIME('%y-%m', lab.labresulttime)
|
### Instruction:
how many days have elapsed since the first time that patient 012-66291 had a procedure on the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-66291' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
did patient 031-17834 have any results of the microbiological sputum, expectorated test in 2105?
### Response:
|
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-17834')) AND microlab.culturesite = 'sputum, expectorated' AND STRFTIME('%y', microlab.culturetakentime) = '2105'
|
### Instruction:
what was patient 031-1337's last intake, on the last intensive care unit visit?
### Response:
|
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
until 3 years ago, what are the top three most frequently prescribed drugs for patients in the 50s?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
count the number of people who were diagnosed with chr osteomyelit nec in 2105.
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'chr osteomyelit nec') AND STRFTIME('%y', diagnoses_icd.charttime) = '2105')
|
### Instruction:
Select tag name, tag synonyms, post excerpt and post wiki body of stackoverflow tags..
### Response:
|
SELECT DISTINCT t.Id, t.TagName, t.Count, GROUP_CONCAT(syn.SourceTagName, ','), e.Body AS "Excerpt", w.Body AS "WikiBody" FROM Tags AS t LEFT JOIN TagSynonyms AS syn ON syn.TargetTagName = t.TagName LEFT JOIN Posts AS e ON t.ExcerptPostId = e.Id LEFT JOIN Posts AS w ON t.WikiPostId = w.Id GROUP BY t.Id, t.TagName, t.Count, e.Body, w.Body ORDER BY t.TagName, t.Id
|
### Instruction:
What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
### Response:
|
SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid, T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix"
|
### Instruction:
when was the last time that patient 022-199074 was prescribed a medication via the oral mucosa route in their current hospital visit?
### Response:
|
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-199074' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'oral mucosa' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
Top .NET programmers in North Carolina. Rank .NET programmers (anyone who has answered a question relating to .NET) in North Carolina
### Response:
|
SELECT DISTINCT Users.Id, Reputation, DisplayName, WebsiteUrl, Location FROM Users INNER JOIN Posts AS A ON Users.Id = A.OwnerUserId INNER JOIN Posts AS Q ON Q.Id = A.ParentId INNER JOIN PostTags ON PostTags.PostId = Q.Id INNER JOIN Tags ON Tags.Id = PostTags.TagId AND Tags.TagName IN ('.net', 'c#', 'asp.net', 'asp.net-mvc') WHERE Location LIKE '%london' OR Location LIKE '%London%' ORDER BY Reputation DESC
|
### Instruction:
find the number of patients primarily diagnosed with neoplasm of uncertain behavior of other lymphatic and hamatopoiteic tissues /bone marrow transplant and their drug route is dialys.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT" AND prescriptions.route = "DIALYS"
|
### Instruction:
What is the total population of American Samoa (US) that has less than 16,280 km arable land, less than 240 km land area, and has a population density of more than 291?
### Response:
|
SELECT COUNT("Population (July 2005 est.)") FROM table_46090 WHERE "Arable Land (km\u00b2)" < '16,280' AND "Land Area (km\u00b2)" < '240' AND "Country" = 'american samoa (us)' AND "Population Density (pop per km\u00b2)" > '291'
|
### Instruction:
Which classes are allowed for PreMajor this coming semester ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category LIKE '%PreMajor%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
Find best answer to my question.
### Response:
|
SELECT Q.Title, Q.Body, A.Body, A.Score, Q.Id AS "post_link" FROM Posts AS Q JOIN Posts AS A ON (Q.AcceptedAnswerId = A.Id) WHERE Q.PostTypeId = 1 AND A.PostTypeId = 2 AND (Q.Title LIKE '%' + REPLACE(@question, ' ', '% ') + '%' OR Q.Body LIKE '%' + REPLACE(@question, ' ', '% ') + '%') ORDER BY DIFFERENCE(@question, Q.Title), DIFFERENCE(@question, Q.Body), Q.Score DESC, A.Score DESC LIMIT 1
|
### Instruction:
provide me the number of patients diagnosed with hypertensive chronic kidney disease, unspecified, with chronic kidney disease stage v or end stage renal disease who had csf lab test done.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Hypertensive chronic kidney disease, unspecified, with chronic kidney disease stage V or end stage renal disease" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
|
### Instruction:
has patient 17667 been prescribed in this year acetaminophen (liquid), ns, or 0.9% sodium chloride?
### Response:
|
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17667) AND prescriptions.drug IN ('acetaminophen (liquid)', 'ns', '0.9% sodium chloride') AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
Total questions and answers per calendar month.
### Response:
|
SELECT TIME_TO_STR(CreationDate, '%Y') * 100 + TIME_TO_STR(CreationDate, '%m') AS YearMonth, SUM(CASE WHEN ParentId IS NULL THEN 1 ELSE 0 END) AS TotalQuestions, SUM(CASE WHEN NOT ParentId IS NULL THEN 1 ELSE 0 END) AS TotalAnswers FROM Posts GROUP BY TIME_TO_STR(CreationDate, '%Y'), TIME_TO_STR(CreationDate, '%m') ORDER BY TIME_TO_STR(CreationDate, '%Y'), TIME_TO_STR(CreationDate, '%m')
|
### Instruction:
Most viewed duplicates missing the 'Possible Duplicate' bit.
### Response:
|
SELECT p.Score, p.Id AS "post_link", p.ViewCount, p.OwnerUserId AS "user_link", p.CreationDate FROM Posts AS p INNER JOIN PostHistory AS h ON h.PostId = p.Id WHERE NOT p.ClosedDate IS NULL AND p.ClosedDate = h.CreationDate AND h.PostHistoryTypeId = 10 AND h.Comment = '1' AND NOT p.Body LIKE '%<strong>Possible Duplicate:</strong>%' AND NOT p.Body LIKE '%<strong>Possible Duplicates:</strong>%' ORDER BY p.ViewCount DESC
|
### Instruction:
Research Health Ed is taught by whom this semester ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.name LIKE '%Research Health Ed%' AND semester.semester = 'WN' AND semester.year = 2016
|
### Instruction:
what was the name of the organism detected in patient 71091's last urine microbiology test until 2 months ago?
### Response:
|
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 71091) AND microbiologyevents.spec_type_desc = 'urine' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime) <= DATETIME(CURRENT_TIME(), '-2 month') ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
what is the maximum hospital cost for a procedure that involves sedative agent - propofol until 3 years ago?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'sedative agent - propofol')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
Which 2007/ 08 has a 2010/ 11 of not held, and a 2011/ 12 of not held, and a 2008/ 09 of not held, and a 2006/ 07 of lq?
### Response:
|
SELECT "2007/ 08" FROM table_37818 WHERE "2010/ 11" = 'not held' AND "2011/ 12" = 'not held' AND "2008/ 09" = 'not held' AND "2006/ 07" = 'lq'
|
### Instruction:
tell me what the total output the previous day is for patient 006-2586.
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-2586')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
list the patient ids of patients who had been diagnosed with jt contracture-jt nec since 5 years ago.
### Response:
|
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'jt contracture-jt nec') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-5 year'))
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, visualize a bar chart about the distribution of job_id and the sum of manager_id , and group by attribute job_id, I want to sort by the Y in descending.
### Response:
|
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(MANAGER_ID) DESC
|
### Instruction:
what was the last heart rate value patient 26886 had?
### Response:
|
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26886)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
what is the maximum total cost to the hospital that includes a vent rate lab test during the previous year?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'vent rate')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
What is the highest Crude Death Rate (per 1000), when Natural Change (Per 1000) is greater than 16.1, when Natural Change is 5,049, and when Crude Birth Rate (Per 1000) is less than 27.1?
### Response:
|
SELECT MAX("Crude death rate (per 1000)") FROM table_40964 WHERE "Natural change (per 1000)" > '16.1' AND "Natural change" = '5,049' AND "Crude birth rate (per 1000)" < '27.1'
|
### Instruction:
what was the last value of patient 022-44805's bun laboratory test since 12/2101?
### Response:
|
SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-44805')) AND lab.labname = 'bun' AND STRFTIME('%y-%m', lab.labresulttime) >= '2101-12' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of department_id over the job_id , and group by attribute job_id by a bar chart, and could you order in descending by the x-axis?
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID DESC
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of department_id over the job_id , and group by attribute job_id, could you rank from high to low by the y axis?
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID) DESC
|
### Instruction:
what was the name of the organism found in the microbiology test of the first other of patient 031-3355 on the current hospital visit?
### Response:
|
SELECT microlab.organism FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355' AND patient.hospitaldischargetime IS NULL)) AND microlab.culturesite = 'other' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
list the ids of all those patients diagnosed with rupt abd aortic aneurysm in 2103.
### Response:
|
SELECT admissions.subject_id FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'rupt abd aortic aneurysm') AND STRFTIME('%y', diagnoses_icd.charttime) = '2103')
|
### Instruction:
calculate patient 20898's total amount of neosure 30 pg intake.
### Response:
|
SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20898)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'neosure 30 pg' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
What would be the correct year in the 1940s, if the 1980s is before 1986, the 1990s is before 1995, the 1970s is before 1973, and the 2000s are after 2001?
### Response:
|
SELECT "1940s" FROM table_15596 WHERE "1980s" < '1986' AND "1990s" < '1995' AND "1970s" < '1973' AND "2000s" > '2001'
|
### Instruction:
tell me about ground transportation between MCO and ORLANDO
### Response:
|
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_name = 'ORLANDO' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'ORLANDO' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
|
### Instruction:
tell me the maximum cost of a hospital visit that involved a folate lab test during the previous year?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'folate')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
What is the average L/100km urban (cold) for engine capacities over 1910, mpg in the US (urban) under 25.3, mpg in the UK (combined) over 27.2, and mpg in the UK (urban, cold) of 22.4?
### Response:
|
SELECT AVG(l_100km_urban__cold_) FROM table_name_27 WHERE engine_capacity > 1910 AND mpg_us_urban < 25.3 AND mpg_uk_combined > 27.2 AND mpg_uk_urban__cold_ = 22.4
|
### Instruction:
Has Frank Keller and Mirella Lapata written a paper together ?
### Response:
|
SELECT DISTINCT WRITES_0.paperid FROM author AS AUTHOR_0, author AS AUTHOR_1, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'Frank Keller' AND AUTHOR_1.authorname = 'Mirella Lapata' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = WRITES_0.paperid
|
### Instruction:
what is the maximum total cost of the hospital that includes the laboratory urinary osmolality test until 1 year ago?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'urinary osmolality')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
Users with non-CW answers in most tags (including deleted users).
### Response:
|
SELECT RANK() OVER (ORDER BY COUNT(DISTINCT pt.TagId) DESC) AS Rank, a.OwnerUserId AS "user_link", a.OwnerDisplayName, COUNT(DISTINCT pt.TagId) AS "#_of_tags" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id WHERE (a.CommunityOwnedDate IS NULL) GROUP BY a.OwnerUserId, a.OwnerDisplayName ORDER BY COUNT(DISTINCT pt.TagId) DESC LIMIT 100
|
### Instruction:
Which non-violent crime rate per 1000 peope has the following criteria: crime rate per 1000 greater than 82.8, violent crime smaller than 305, robbery less than 147 and a crime index total greater than 1540?
### Response:
|
SELECT AVG("Violent crime Rate per 1000") FROM table_14909 WHERE "Crime rate Per 1000" > '82.8' AND "Violent crime" < '305' AND "Robbery" < '147' AND "Crime Index Total" > '1540'
|
### Instruction:
What is the highest number of tourism receipts in 2011 US $ per capita with 19.4 % of GDP in 2003 tourism receipts and less than 655 US $ per arrival in 2011 tourism receipts?
### Response:
|
SELECT MAX(tourism_receipts__2011___us) AS $_per_capita_ FROM table_name_99 WHERE tourism_receipts__2003___as__percentage_of_gdp_ = "19.4" AND tourism_receipts__2011___us$_per_arrival_ < 655
|
### Instruction:
what's the average total cost of the hospital that involves a procedure called glycoprotein iib/iiia inhibitor - eptifibatide?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'glycoprotein iib/iiia inhibitor - eptifibatide')) GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
what number of days have elapsed since the first time patient 92788 received a ptt lab test on the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ptt') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 92788 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
How can the PreMajor requirement be satisfied with American Board of Orthodontics Phase II Review Course courses ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%American Board of Orthodontics Phase II Review Course%' OR course.description LIKE '%American Board of Orthodontics Phase II Review Course%' OR course.name LIKE '%American Board of Orthodontics Phase II Review Course%') AND program_course.category LIKE '%PreMajor%'
|
### Instruction:
how many hours have passed since patient 013-28507 has last had a procedure in the current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
how many days has elapsed since patient 31088's first lab test of white blood cells during their current hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'white blood cells') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31088 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the sum of employee_id over the job_id , and group by attribute job_id, and order by the y axis in descending.
### Response:
|
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(EMPLOYEE_ID) DESC
|
### Instruction:
whats the first height of patient 008-40862 in 12/this year?
### Response:
|
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-40862') AND NOT patient.admissionheight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', patient.unitadmittime) = '12' ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
how many hours have elapsed since patient 027-188709 last received procedure during this hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', treatment.treatmenttime)) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-188709' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
count the number of patients who since 2102 had been diagnosed with staph pneumonia nec.
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'staph pneumonia nec') AND STRFTIME('%y', diagnoses_icd.charttime) >= '2102')
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, show me about the distribution of hire_date and the sum of department_id bin hire_date by time in a bar chart, and I want to display by the total number of department id in desc.
### Response:
|
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(DEPARTMENT_ID) DESC
|
### Instruction:
what is the average total cost of a hospital which involves the reticulocyte count, manual in the previous year?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'reticulocyte count, manual')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.hadm_id) AS t1
|
### Instruction:
tell me, what were the three most common procedures in 2102?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE STRFTIME('%y', procedures_icd.charttime) = '2102' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
What is required for MCDB 680 and 489 ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE (COURSE_1.number = 680 OR COURSE_1.number = 489) AND COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'MCDB'
|
### Instruction:
When Prof. Edward Chamberlin teaches it , does PROSTHOD 879 have a lab ?
### Response:
|
SELECT COUNT(*) = 0 FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE course.department = 'PROSTHOD' AND course.has_lab = 'N' AND course.number = 879 AND instructor.name LIKE '%Edward Chamberlin%'
|
### Instruction:
how many days has it been since the last time patient 76332 was given a sodium test on this hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'sodium') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76332 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
Users with the most Favorites.
### Response:
|
SELECT U.Id AS "user_link", (SELECT COUNT(V.Id) AS "favorites" FROM Votes AS V, VoteTypes AS Vt WHERE Vt.Id = V.VoteTypeId AND U.Id = V.UserId AND Vt.Id = 5) AS "favs" FROM Users AS U WHERE (SELECT COUNT(V.Id) AS "favorites" FROM Votes AS V, VoteTypes AS Vt WHERE Vt.Id = V.VoteTypeId AND U.Id = V.UserId AND Vt.Id = 5) > 1000 ORDER BY FAVS DESC
|
### Instruction:
Where does Col Sharpnel place in downvoting percentage. Where does Col Sharpnel place in downvoting percentage
### Response:
|
SELECT SUM(CASE WHEN DownVotes = 0 THEN 1 WHEN 1.0 * UpVotes / NULLIF(DownVotes, 0) >= y THEN 1 END), SUM(CASE WHEN 1.0 * UpVotes / NULLIF(DownVotes, 0) < y THEN 1 END) FROM Users CROSS JOIN (SELECT y = 1.0 * UpVotes / DownVotes FROM Users WHERE Id = 285587) AS x WHERE Users.UpVotes > 0 AND Users.Reputation > 1000
|
### Instruction:
when patient 025-44495 has received a microbiology test for the last time on the last hospital visit?
### Response:
|
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-44495' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
tell me the total amount of output that patient 013-3028 has had since 1631 days ago?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-3028')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-1631 day')
|
### Instruction:
count the number of patients who have undergone a exc pituit les-transphen procedure since 2105.
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'exc pituit les-transphen') AND STRFTIME('%y', procedures_icd.charttime) >= '2105')
|
### Instruction:
Find non-accepted answers by a given user with comments.
### Response:
|
SELECT q.CreationDate AS "Question Date", a.Id AS "Answer", q.AcceptedAnswerId AS "Accepted Answer", q.Id AS "Question ID", q.Title AS "Question Title" FROM Posts AS a JOIN Posts AS q ON q.Id = a.ParentId JOIN Comments AS c ON c.PostId = a.Id JOIN Users AS u ON u.Id = a.OwnerUserId WHERE c.UserId != '##UserId:int##' AND a.OwnerUserId = '##UserId:int##' AND q.AcceptedAnswerId != a.Id ORDER BY q.CreationDate
|
### Instruction:
had patient 31243 received a replace trach tube treatment since 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'replace trach tube') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31243) AND STRFTIME('%y', procedures_icd.charttime) >= '2105'
|
### Instruction:
in their current hospital visit had patient 013-28507 undergone any therapeutic antibacterials - directed antibacterial therapy procedure?
### Response:
|
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'therapeutic antibacterials - directed antibacterial therapy'
|
### Instruction:
Posts tagged with only [tag] with no answers and low [views].
### Response:
|
SELECT Posts.Id AS "post_link", Posts.CommentCount AS "#_comments", Posts.ViewCount AS "#_views" FROM Tags RIGHT JOIN Posts ON Posts.Tags = '<' + TagName + '>' WHERE Posts.AnswerCount = 0 AND Posts.Score >= 0 AND Posts.ViewCount <= @views AND TagName LIKE ('%' + CASE WHEN @tagToSearch != 'all' THEN @tagToSearch ELSE '' END + '%') AND Posts.CommentCount <= CASE WHEN @comments < 0 THEN Posts.CommentCount ELSE @comments END ORDER BY '#_views'
|
### Instruction:
when is the first time patient 016-29746 received a alpha/beta blocker treatment in 2104?
### Response:
|
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-29746')) AND treatment.treatmentname = 'alpha/beta blocker' AND STRFTIME('%y', treatment.treatmenttime) = '2104' ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
what is the average total cost for the hospital involving a procedure called implantation of rvad since 2100?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'implantation of rvad')) AND STRFTIME('%y', cost.chargetime) >= '2100' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
is there any bronchial lavage microbiology test result for patient 031-19622 until 1 year ago?
### Response:
|
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-19622')) AND microlab.culturesite = 'bronchial lavage' AND DATETIME(microlab.culturetakentime) <= DATETIME(CURRENT_TIME(), '-1 year')
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the sum of employee_id over the job_id , and group by attribute job_id, could you display y axis from low to high order?
### Response:
|
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(EMPLOYEE_ID)
|
### Instruction:
on their first hospital encounter what was diagnosed with patient 10425 for the first time?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT diagnoses_icd.icd9_code FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10425 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY diagnoses_icd.charttime LIMIT 1)
|
### Instruction:
Days with score >= 200.
### Response:
|
WITH scores AS (SELECT CAST(TIME_TO_STR(Votes.CreationDate, '%Y-%m-%d %H:%M:%S') AS TEXT(10)) AS "date", SUM(CASE VoteTypeId WHEN 1 THEN 15 WHEN 2 THEN 10 WHEN 3 THEN -2 END) AS score FROM Votes INNER JOIN Posts ON Posts.Id = Votes.PostId WHERE Posts.OwnerUserId = @userid AND Posts.CommunityOwnedDate IS NULL GROUP BY Votes.CreationDate) SELECT * FROM scores WHERE Score >= 200 ORDER BY 'date' DESC
|
### Instruction:
how much sertraline has been prescribed to patient 64292 in 02/this year in total?
### Response:
|
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 64292) AND prescriptions.drug = 'sertraline' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '02'
|
### Instruction:
did patient 9299 receive the lingual thyroid excision procedure since 2103?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'lingual thyroid excision') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9299) AND STRFTIME('%y', procedures_icd.charttime) >= '2103'
|
### Instruction:
how many patients in 2101 had an intake of carrier?
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT icustays.hadm_id FROM icustays WHERE icustays.icustay_id IN (SELECT inputevents_cv.icustay_id FROM inputevents_cv WHERE inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'carrier' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y', inputevents_cv.charttime) = '2101'))
|
### Instruction:
What is the median reputation level on SO?. http://stackoverflow.com/a/7227860/578411
http://meta.stackoverflow.com/questions/296967/what-is-the-median-reputation-level-on-so
### Response:
|
SELECT AVG(Reputation) AS median FROM (SELECT Reputation, rnasc = ROW_NUMBER() OVER (ORDER BY Reputation), rndesc = ROW_NUMBER() OVER (ORDER BY Reputation DESC) FROM Users WHERE Reputation > 102) AS b WHERE rnasc BETWEEN rndesc - 1 AND rndesc + 1
|
### Instruction:
how many days it's been since patient 27172 last got a platelet count lab test during this hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', labevents.charttime)) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'platelet count') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27172 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
what is the average total cost of hospitals that include seizures - partial complex since 2103?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'seizures - partial complex')) AND STRFTIME('%y', cost.chargetime) >= '2103' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
SO - Total Posts by Database Server Per Month - MsAccess.
### Response:
|
SELECT CONCAT(YEAR(P.CreationDate), '-', MONTH(P.CreationDate)) AS YearMonth, 'MsAccess' AS TagName, COUNT(*) AS PostCount FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE T.TagName LIKE 'ms-access%' GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY YEAR(P.CreationDate) DESC, MONTH(P.CreationDate) DESC
|
### Instruction:
User with most famous/notable/popular badges.
### Response:
|
SELECT UserId AS "user_link", SUM(CASE WHEN Class = 1 THEN 1 ELSE 0 END) AS gold, SUM(CASE WHEN Class = 2 THEN 1 ELSE 0 END) AS silver, SUM(CASE WHEN Class = 3 THEN 1 ELSE 0 END) AS bronze, COUNT(Id) AS total FROM Badges WHERE (Name = '##name1?Famous Question##') OR (Name = '##name2?Notable Question##') OR (Name = '##name3?Popular Question##') GROUP BY UserId ORDER BY gold DESC, silver DESC, bronze DESC, total DESC LIMIT 200
|
### Instruction:
among the patients aged 60 or above in this year, what were the top five most frequent procedures?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age >= 60) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 5
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.