instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
what was the daily maximum intake of enteral ogt meds that patient 027-110585 had received until 07/30/2105?
### Response:
|
SELECT MAX(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 = '027-110585')) AND intakeoutput.celllabel = 'enteral ogt meds' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-07-30' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
### Instruction:
what were the new prescriptions on the prescription of patient 025-44842 today compared to the prescription yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '025-44842') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '025-44842') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
what was the name of the procedure that was given two times to patient 51200 a month before?
### 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, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 51200) AND DATETIME(procedures_icd.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 = 2)
|
### Instruction:
what airlines fly between BOSTON and SAN FRANCISCO
### Response:
|
SELECT DISTINCT airline.airline_code FROM airline, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
what is the medication that patient 012-4131 had been prescribed two times in 11/this year?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-4131')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '11' GROUP BY medication.drugname) AS t1 WHERE t1.c1 = 2
|
### Instruction:
okay all right do you have a flight on UA from ATLANTA to WASHINGTON
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'WASHINGTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
Top 100 users in a given tag (TeX version). This query fetches the top 100 users on a given tag name. The original
query is available here: data.stackexchange.com/stackoverflow/s/1791
### Response:
|
SELECT u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t WITH (nolock) INNER JOIN PostTags AS pt WITH (nolock) ON pt.TagId = t.Id INNER JOIN Posts AS p WITH (nolock) ON p.ParentId = pt.PostId INNER JOIN Votes AS v WITH (nolock) ON v.PostId = p.Id AND v.VoteTypeId = 2 INNER JOIN Users AS u WITH (nolock) ON u.Id = p.OwnerUserId WHERE p.CommunityOwnedDate IS NULL AND t.TagName = @TagName GROUP BY u.Id ORDER BY UpVotes DESC LIMIT 1000
|
### Instruction:
when last did patient 31482 have the minimum arterial bp mean during a day before?
### Response:
|
SELECT chartevents.charttime 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 = 31482)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.valuenum, chartevents.charttime DESC LIMIT 1
|
### Instruction:
show me all DAILY flights from MILWAUKEE to ORLANDO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MILWAUKEE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.flight_days = 'DAILY'
|
### Instruction:
what were the five most common procedures among the patients 20s this year?
### 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 procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 20 AND 29) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
enoxaparin 40 mg/0.4 ml syr, prinivil, or famotidine 20 mg po tabs had been ordered for patient 022-199074 since 10/2104?
### Response:
|
SELECT COUNT(*) > 0 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 medication.drugname IN ('enoxaparin 40 mg/0.4 ml syr', 'prinivil', 'famotidine 20 mg po tabs') AND STRFTIME('%y-%m', medication.drugstarttime) >= '2104-10'
|
### Instruction:
how many days have elapsed since the first time patient 10855 had an intake of .9% normal saline on the current icu visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 10855) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
what was the drug patient 013-15869 had been prescribed in 02/last year two times.
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-15869')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '02' GROUP BY medication.drugname) AS t1 WHERE t1.c1 = 2
|
### Instruction:
List of all sites with Stack Exchange Domain.
### Response:
|
SELECT Site = LEFT(LEFT(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), STR_POSITION(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), '.')), LENGTH(LEFT(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), STR_POSITION(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), '.'))) - 1) FROM sys.databases WHERE Name LIKE '%StackExchange.%' AND NOT LEFT(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), STR_POSITION(RIGHT(name, LENGTH(name) - STR_POSITION(name, '.')), '.')) LIKE ''
|
### Instruction:
how many days has it been since patient 007-16517 had its last prescription of hydrocodone-acetaminophen 5-325 mg po tabs during the current hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '007-16517') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'hydrocodone-acetaminophen 5-325 mg po tabs' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
which airlines fly between BOSTON and PITTSBURGH
### Response:
|
SELECT DISTINCT airline.airline_code FROM airline, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
how many days has passed since the last time patient 15447 has had lactated ringers intake on the current intensive care unit visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 15447) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'lactated ringers' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
list airlines serving between DENVER and SAN FRANCISCO
### Response:
|
SELECT DISTINCT airline.airline_code FROM airline, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
how much weight has change of patient 013-28507 last measured on the current hospital visit compared to the first value measured on the current hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-28507' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
Count of posts edited by two users.
### Response:
|
SELECT Week, '22', '17163', '17702', '13438' FROM (SELECT DATEADD(WEEK, DATEDIFF(WEEK, 0, CreationDate), 0) AS "week", c.UserId, COUNT(*) AS Count FROM Comments AS c WHERE c.UserId IN (22, 17163, 17702, 13438) AND YEAR(c.CreationDate) >= 2016 GROUP BY DATEADD(WEEK, DATEDIFF(WEEK, 0, CreationDate), 0), c.UserId) AS src PIVOT(MAX(Count) FOR UserId IN ('22', '17163', '17702', '13438')) AS piv ORDER BY 'week' DESC
|
### Instruction:
how many days have passed since the first time that patient 12726 had a .9% normal saline intake on the current icu visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 12726) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
i would like to fly from DENVER to PITTSBURGH on UA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
information on AA from FORT WORTH texas to PHILADELPHIA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'FORT WORTH' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
what was the name of the organism found in the last other microbiology test of patient 031-16123 in 09/last year?
### 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-16123')) AND microlab.culturesite = 'other' AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microlab.culturetakentime) = '09' ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
Amount of votes by top 5 voters.
### Response:
|
SELECT SUM(DownVotes), SUM(UpVotes), SUM(DownVotes) / CAST(TotalDown AS FLOAT) * 100 AS "% of downvotes", SUM(DownVotes) / CAST(TotalPosts AS FLOAT) * 100 AS "% of Posts Downvoted" FROM (SELECT Users.DownVotes, Users.UpVotes FROM Users ORDER BY Users.DownVotes DESC LIMIT 5) AS T CROSS JOIN (SELECT SUM(DownVotes) AS TotalDown FROM Users WHERE Users.Id != -1) AS D CROSS JOIN (SELECT SUM(DownVotes) AS TotalUp FROM Users WHERE Users.Id != -1) AS U CROSS JOIN (SELECT SUM(DownVotes) AS TotalPosts FROM Users WHERE Users.Id != -1) AS P GROUP BY TotalDown, TotalUp, TotalPosts
|
### Instruction:
indicate the monthly minimum arterial bp mean of patient 26195 since 1199 days ago.
### Response:
|
SELECT MIN(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 = 26195)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-1199 day') GROUP BY STRFTIME('%y-%m', chartevents.charttime)
|
### Instruction:
how many hours has it been since the first time that patient 6170 on the current icu visit received a .9% normal saline intake?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 6170) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
what is the top five most frequent diagnoses for the patients 50s since 1 year ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 50 AND 59) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
RxSwift query counts by month.
### Response:
|
SELECT TIME_TO_STR(Posts.CreationDate, '%Y') * 100 + TIME_TO_STR(Posts.CreationDate, '%m') AS YYYYMM, COUNT(0) AS CT FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId WHERE Posts.CreationDate > '2015-01-01' AND Tags.TagName = 'lldb' GROUP BY TIME_TO_STR(Posts.CreationDate, '%Y') * 100 + TIME_TO_STR(Posts.CreationDate, '%m') ORDER BY TIME_TO_STR(Posts.CreationDate, '%Y') * 100 + TIME_TO_STR(Posts.CreationDate, '%m')
|
### Instruction:
tell me the average arterial bp [systolic] for patient 18677's body on 05/05/2102?
### Response:
|
SELECT AVG(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 = 18677)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) = '2102-05-05'
|
### Instruction:
Which products have problems reported by both the staff named Lacey Bosco and the staff named Kenton Champlin?
### Response:
|
SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Lacey" AND T3.staff_last_name = "Bosco" INTERSECT SELECT T2.product_name FROM problems AS T1 JOIN product AS T2 JOIN staff AS T3 ON T1.product_id = T2.product_id AND T1.reported_by_staff_id = T3.staff_id WHERE T3.staff_first_name = "Kenton" AND T3.staff_last_name = "Champlin"
|
### Instruction:
today, what was first value of arterial bp [systolic] for patient 14671?
### 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 = 14671)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
flights from HOUSTON to LOS ANGELES departing after 2226
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'LOS ANGELES' AND flight.departure_time > 2226 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'HOUSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what were the new prescriptions of patient 016-38131 today compared to the prescription they received yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '016-38131') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '016-38131') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
what are the four most frequent diagnoses among the patients aged 30s since 1 year ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
What are the prereqs for the course where Sidney Soto is the GSI ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.pre_course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.course_id INNER JOIN course_offering ON COURSE_1.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id WHERE student.firstname LIKE 'Sidney' AND student.lastname LIKE 'Soto'
|
### Instruction:
when was first time patient 739 was measured with a greater arterial bp [systolic] than 101.0 on the current intensive care unit visit?
### Response:
|
SELECT chartevents.charttime 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 = 739) AND icustays.outtime IS NULL) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 101.0 ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
Get all suggested edits on a specific post.
### Response:
|
SELECT rt.PostId AS "post_link", 'site://review/suggested-edits/' + CAST(rt.Id AS TEXT) + '|review' AS review, CASE WHEN se.ApprovalDate IS NULL THEN 'Rejected' ELSE 'Approved' END AS "status", 'site://users/' + CAST(u.Id AS TEXT) + '|' + u.DisplayName AS "suggested_by", COALESCE(se.ApprovalDate, se.RejectionDate) AS "date" FROM ReviewTasks AS rt JOIN SuggestedEdits AS se ON rt.SuggestedEditId = se.Id JOIN Users AS u ON se.OwnerUserId = u.Id WHERE rt.ReviewTaskTypeId = 1 AND rt.PostId = '##postid:int##' ORDER BY 'date'
|
### Instruction:
when was the last time patient 3267 arterial bp mean was measured less than 84.0 on the first icu visit.
### Response:
|
SELECT chartevents.charttime 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 = 3267) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 84.0 ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
Top users sorted by percentage of answers on closed questions.
### Response:
|
SELECT Id AS "user_link", Reputation, (SELECT COUNT(*) FROM Posts WHERE OwnerUserId = Users.Id AND PostTypeId = 2) AS TotalAnswers, (SELECT COUNT(*) FROM Posts AS aPosts LEFT JOIN Posts AS qPosts ON qPosts.PostTypeId = 1 AND qPosts.Id = aPosts.ParentId WHERE aPosts.OwnerUserId = Users.Id AND aPosts.PostTypeId = 2 AND NOT qPosts.ClosedDate IS NULL) / (SELECT COUNT(*) + 0.000000001 FROM Posts WHERE OwnerUserId = Users.Id AND PostTypeId = 2) * 100 AS PercentageOnClosedQns, LastAccessDate FROM Users WHERE Reputation > 5000 ORDER BY PercentageOnClosedQns DESC
|
### Instruction:
what is the yearly maximum intake of sc 24 fe ng that patient 21454 is getting until 438 days ago?
### Response:
|
SELECT MAX(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 = 21454)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sc 24 fe ng' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-438 day') GROUP BY STRFTIME('%y', inputevents_cv.charttime)
|
### Instruction:
does patient 027-85328 produce any output (ml)-urethral catheter diana acuna, rn latex;straight-tip 14 fr. since 09/2105.
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-85328')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output (ml)-urethral catheter diana acuna, rn latex;straight-tip 14 fr.' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) >= '2105-09'
|
### Instruction:
on the last intensive care unit visit, when did patient 015-96048 have the last output y (ml)-chest tube y - a #1 right mid b #1 left mid output?
### Response:
|
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-96048') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output y (ml)-chest tube y - a #1 right mid b #1 left mid' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
what are the five most frequent diagnoses of patients with age 30s since 6 years ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
patient 2498 had any d10w on 08/27/last year?
### Response:
|
SELECT COUNT(*) > 0 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 = 2498)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd10w' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '08-27'
|
### Instruction:
Compare monthly usage of tags with graph.
### Response:
|
SELECT DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1) AS "date", t.TagName, COUNT(*) FROM Posts AS p JOIN PostTags AS pt ON pt.PostId = p.Id JOIN Tags AS t ON t.Id = pt.TagId WHERE DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1) < DATEFROMPARTS(YEAR(CURRENT_TIMESTAMP()), MONTH(CURRENT_TIMESTAMP()), 1) AND (t.TagName = '##Tag1:string?android##' OR t.TagName = '##Tag2:string?python##') GROUP BY t.TagName, DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1) ORDER BY 'date' DESC
|
### Instruction:
how many hours have elapsed since patient 20898 first received an intake of criticare hn on the current intensive care unit visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'criticare hn' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
indicate the monthly average arterial bp mean of patient 19175 since 1113 days ago.
### Response:
|
SELECT AVG(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 = 19175)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-1113 day') GROUP BY STRFTIME('%y-%m', chartevents.charttime)
|
### Instruction:
Tag Activity By Month - questions, answers, comments, votes. Summarize activity for a given list of tags by month for the previous X number of days.
Activity includes questions, answers, comments, votes and a total of all of them.
### Response:
|
SELECT Tags.TagName, DATE(Posts.CreationDate) AS CreationDate, Posts.Id, Comments.Id FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId LEFT JOIN Comments ON Comments.PostId = Posts.Id INNER JOIN (SELECT Value AS TagName FROM STRING_SPLIT(@Tags, ',')) AS MyTags ON MyTags.TagName = Tags.TagName WHERE Posts.CreationDate >= CAST(DATE(CURRENT_TIMESTAMP()) AS DATETIME) - @Days ORDER BY DATE(Posts.CreationDate), Tags.TagName LIMIT 100
|
### Instruction:
Where did my rep come from?.
### Response:
|
SELECT MAX(U.DisplayName), SUM(CASE WHEN V.VoteTypeId = 1 THEN 15 WHEN V.VoteTypeId = 2 AND P.PostTypeId = 1 THEN 5 WHEN V.VoteTypeId = 2 AND P.PostTypeId = 2 THEN 10 WHEN V.VoteTypeId = 3 AND P.PostTypeId = 1 THEN -1 WHEN V.VoteTypeId = 3 AND P.PostTypeId = 2 THEN -2 ELSE 0 END) FROM Votes AS V INNER JOIN Posts AS P ON V.PostId = P.Id AND V.VoteTypeId IN (1, 2, 3) AND P.PostTypeId IN (1, 2) INNER JOIN Users AS U ON V.UserId = U.Id WHERE P.OwnerUserId = 11659 GROUP BY U.Id
|
### Instruction:
show me the morning flights from MEMPHIS to NEW YORK
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE ((from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'MEMPHIS')) AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'NEW YORK'))) AND departure_time BETWEEN 0 AND 1200)
|
### Instruction:
Questions where answer was accepted before a bounty was started.
### Response:
|
SELECT p.Id AS "post_link", p.AcceptedAnswerId, bs.CreationDate, ac.CreationDate, p.CreationDate, url = 'site://posts/' + CAST(p.Id AS TEXT) + '/revisions', url = 'site://posts/' + CAST(p.Id AS TEXT) + '/timeline' FROM Posts AS p INNER JOIN Votes AS bs ON (p.Id = bs.PostId AND bs.VoteTypeId = 8) LEFT JOIN Votes AS ac ON (p.AcceptedAnswerId = ac.PostId AND ac.VoteTypeId = 1) WHERE (p.PostTypeId = 1) AND (NOT p.AcceptedAnswerId IS NULL) AND (ac.CreationDate < bs.CreationDate) ORDER BY p.CreationDate DESC LIMIT 100
|
### Instruction:
Those times you were stupid and you asked twice on the same day. ... so they don't count for the Asking Days badges curious/inquisitive/socratic.
### Response:
|
SELECT questions.Id AS "post_link", DATE(questions.CreationDate) AS "date", initialQs.Id AS "post_link" FROM Posts AS questions JOIN Posts AS initialQs ON DATE(initialQs.CreationDate) = DATE(questions.CreationDate) WHERE questions.OwnerUserId = '##UserId##' AND questions.PostTypeId = 1 AND initialQs.OwnerUserId = '##UserId##' AND initialQs.PostTypeId = 1 GROUP BY questions.CreationDate, questions.Id, initialQs.Id, DATE(initialQs.CreationDate) HAVING questions.CreationDate > MIN(initialQs.CreationDate) ORDER BY questions.CreationDate DESC
|
### Instruction:
list the morning flights between ATLANTA and DALLAS
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'ATLANTA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
show afternoon flights from HOUSTON to DALLAS
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'HOUSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
|
### Instruction:
tell me the top three most common diagnoses in patients in the age of 30s since 2103?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND STRFTIME('%y', diagnoses_icd.charttime) >= '2103' GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
what is the cost of a round trip ticket FIRST class between OAK and ATL
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport AS AIRPORT_0, airport AS AIRPORT_1, fare, fare_basis, flight, flight_fare WHERE (AIRPORT_0.airport_code = 'OAK' AND AIRPORT_1.airport_code = 'ATL' AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_0.airport_code AND flight.to_airport = AIRPORT_1.airport_code) AND NOT fare.round_trip_cost IS NULL
|
### Instruction:
show me the flights from TACOMA to MIAMI after 1800
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MIAMI' AND flight.departure_time > 1800 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'TACOMA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what are the new prescriptions today of patient 006-47576 compared to the prescriptions yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-47576') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-47576') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
tell me how many doses of volume (ml) milrinone patient 021-25705 had consumed on last month/29.
### 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 = '021-25705')) AND intakeoutput.celllabel = 'volume (ml) milrinone' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '29'
|
### Instruction:
what is the name of procedure patient 14397 has been given two times in this month?
### 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, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14397) AND DATETIME(procedures_icd.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 = 2)
|
### Instruction:
of the patients with age 40s until 2103, what is the top four most frequent diagnoses?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND STRFTIME('%y', diagnoses_icd.charttime) <= '2103' GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
tell me the total amount of gastric jejunostomy tube that patient 12927 had on this month/27.
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12927)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'gastric jejunostomy tube' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', outputevents.charttime) = '27'
|
### Instruction:
what is the percentile of 89.1 in a laboratory test of neutrophils with the same age as patient 10431 in the last hospital encounter?
### Response:
|
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'neutrophils') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 10431 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1))) AS t1 WHERE t1.valuenum = 89.1
|
### Instruction:
Most Popular StackOverflow tags in 2018.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS TotalRank, num.Num AS QuestionsTotal FROM (SELECT COUNT(PostId) AS Rate, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate < '2018-07-31' AND Posts.CreationDate > '2018-01-01' GROUP BY TagName) AS rate INNER JOIN (SELECT COUNT(PostId) AS Num, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId GROUP BY TagName HAVING COUNT(PostId) > 800) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
what time did patient 92846 get his last urine out foley output on this month/20?
### Response:
|
SELECT outputevents.charttime FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 92846)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', outputevents.charttime) = '20' ORDER BY outputevents.charttime DESC LIMIT 1
|
### Instruction:
what's the maximum heart rate of patient 19175 on last month/04?
### Response:
|
SELECT MAX(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 = 19175)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', chartevents.charttime) = '04'
|
### Instruction:
had patient 11362 had any chest tubes cticu ct 1 output on last month/24?
### Response:
|
SELECT COUNT(*) > 0 FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11362)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'chest tubes cticu ct 1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', outputevents.charttime) = '24'
|
### Instruction:
count the number of times on this month/21 patient 71558 has produced cerebral drain r ventricular drain.
### Response:
|
SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 71558)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'cerebral drain r ventricular drain' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', outputevents.charttime) = '21'
|
### Instruction:
hi i'd like a flight on AS from SAN DIEGO to TORONTO please
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'TORONTO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN DIEGO' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AS'
|
### Instruction:
when was first the arterial bp [systolic] of patient 8116 measured during a day before?
### Response:
|
SELECT chartevents.charttime 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 = 8116)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
calculate the total amount of jackson pratt #1 output for patient 1902 on 12/30/this year.
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1902)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'jackson pratt #1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', outputevents.charttime) = '12-30'
|
### Instruction:
Top-most socratic users and their socratism.
### Response:
|
SELECT question_days.OwnerUserId AS "user_link", SUM(CASE WHEN question_days.up > 0 AND question_days.down = 0 THEN 1 ELSE 0 END) AS socratism, Users.Reputation FROM (SELECT OwnerUserId, MAX(CASE WHEN Score > 0 THEN 1 ELSE 0 END) AS up, MAX(CASE WHEN Score < 1 THEN 1 ELSE 0 END) AS down FROM Posts WHERE PostTypeId = 1 AND NOT OwnerUserId IS NULL GROUP BY CAST(TIME_TO_STR(CreationDate, '%Y/%m/%d') AS TEXT(10)), OwnerUserId) AS question_days JOIN Users ON question_days.OwnerUserId = Users.Id GROUP BY question_days.OwnerUserId, Users.Reputation ORDER BY socratism DESC LIMIT 100
|
### Instruction:
what are the new meds of patient 006-172277 today compared to the one yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-172277') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-172277') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
what is the daily minimum amount of output amount-ileostomy in patient 022-199074 since 04/23/2103?
### Response:
|
SELECT MIN(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 = '022-199074')) AND intakeoutput.celllabel = 'output amount-ileostomy' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2103-04-23' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
### Instruction:
what are the new prescription drug of patient 022-187132 today compared to that yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '022-187132') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '022-187132') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
Would you say that SPANISH 287 is more difficult that SPANISH 859 ?
### Response:
|
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, program_course AS PROGRAM_COURSE_0, program_course AS PROGRAM_COURSE_1 WHERE COURSE_0.department = 'SPANISH' AND COURSE_0.number = 287 AND COURSE_1.department = 'SPANISH' AND COURSE_1.number = 859 AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id AND PROGRAM_COURSE_0.workload < PROGRAM_COURSE_1.workload AND PROGRAM_COURSE_1.course_id = COURSE_1.course_id
|
### Instruction:
what were the newly prescribed drugs of patient 006-80884 today compared to those prescribed yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-80884') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-80884') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
what drugs are being added to patient 006-123134 today as compared to those yesterday?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-123134') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-123134') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
|
### Instruction:
how many hours has passed since the first time that patient 006-181433 has been prescribed potassium chloride 20 meq/50ml iv soln on their current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '006-181433') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'potassium chloride 20 meq/50ml iv soln' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
StackOverflow Users by Location and Skill sorted by Average Score.
### Response:
|
SELECT DISTINCT Users.Id, Users.DisplayName, Users.Location, Users.Id AS "user_link", COUNT(Posts.Id) AS Answers, CAST(AVG(CAST(Score AS FLOAT)) AS FLOAT(6, 2)) AS "average_score", Users.AboutMe AS About, Users.Reputation AS Reputation FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL AND Location LIKE '%##Location##%' AND LOWER(Users.AboutMe) LIKE LOWER('%##Skill##%') GROUP BY Users.Id, DisplayName, Location, AboutMe, Reputation HAVING COUNT(Posts.Id) > 5 ORDER BY 'average_score' DESC LIMIT 500
|
### Instruction:
how many hours is it since the last time patient 31854 had a criticare hn intake on the current icu visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 31854) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'criticare hn' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
All Info About Mobile Android Testing.
### Response:
|
SELECT P.OwnerUserId, P.Title, P.Tags, P.ViewCount, P.Score, P.AnswerCount, P.CreationDate FROM Posts AS P WHERE (P.Tags LIKE '%android-testing%') OR (P.Tags LIKE '%robotium%') OR (P.Tags LIKE '%androidviewclient%') OR (P.Tags LIKE '%monkeyrunner%') OR (P.Tags LIKE '%android-espresso%') OR (P.Tags LIKE '%android-emulator%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%uiautomator%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%appium%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%calabash%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%test%') ORDER BY P.Score DESC
|
### Instruction:
what was the daily average dose of chemo:alb w/ sargram that patient 1272 was taking during the last hospital visit?
### Response:
|
SELECT AVG(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 = 1272 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'chemo:alb w/ sargram' AND d_items.linksto = 'inputevents_cv') GROUP BY STRFTIME('%y-%m-%d', inputevents_cv.charttime)
|
### Instruction:
count the number of times patient 19175 had received a lipids 20% on last month/03.
### Response:
|
SELECT COUNT(*) 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 = 19175)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'lipids 20%' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', inputevents_cv.charttime) = '03'
|
### Instruction:
What are the prerequisites for GSI Randall Payne 's course ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.pre_course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.course_id INNER JOIN course_offering ON COURSE_1.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id WHERE student.firstname LIKE 'Randall' AND student.lastname LIKE 'Payne'
|
### Instruction:
when was patient 031-16123 tested for other microbiology for the last time in 09/last year?
### 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 = '031-16123')) AND microlab.culturesite = 'other' AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microlab.culturetakentime) = '09' ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
list all UA flights from BOSTON to SAN FRANCISCO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
how many hours have passed since the last time that patient 1902 has had an d5ns intake on the current intensive care unit visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', inputevents_cv.charttime)) 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 = 1902) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5ns' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
when the first time that patient 11080 had a arterial bp [diastolic] measured until 287 days ago.
### Response:
|
SELECT chartevents.charttime 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 = 11080)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime) <= DATETIME(CURRENT_TIME(), '-287 day') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
are patient 1902's arterial bp [diastolic] normal on their first hospital encounter?
### Response:
|
SELECT COUNT(*) > 0 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 = 1902 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN diastolic_bp_lower AND diastolic_bp_upper
|
### Instruction:
show me patient 85895's daily average cerebral ventricular #1 output amount in the last month.
### Response:
|
SELECT AVG(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 85895)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'cerebral ventricular #1' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
|
### Instruction:
what was the name of the procedure performed to patient 14467, two or more times since 136 months ago?
### 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, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14467) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-136 month') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 >= 2)
|
### Instruction:
when was the first time patient 14990 respiratory rate was measured less than 25.0 on the first icu visit.
### Response:
|
SELECT chartevents.charttime 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 = 14990) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'respiratory rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 25.0 ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
when had patient 006-195316 last had the maximum respiration on 04/17/this year?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-195316')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '04-17' ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
when are the AA flights from PHOENIX to MILWAUKEE
### Response:
|
SELECT DISTINCT flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHOENIX' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MILWAUKEE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
what was the yearly average dose of vascular 5 flush amount (ml) that patient 021-111547 was taking since 04/2105?
### Response:
|
SELECT AVG(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 = '021-111547')) AND intakeoutput.celllabel = 'vascular 5 flush amount (ml)' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) >= '2105-04' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
|
### Instruction:
how many times patient 1902 has had tpn d17.0 taken on this month/30?
### Response:
|
SELECT COUNT(*) 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 = 1902)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d17.0' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '30'
|
### Instruction:
what was the name of the procedure that patient 5310 received two or more times last month.
### 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, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 5310) AND DATETIME(procedures_icd.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 >= 2)
|
### Instruction:
Most score on security tag answers.
### Response:
|
SELECT q.Id AS "qid", q.Title AS "title", q.Score AS "qscore", q.ViewCount AS "qviewcount", q.Tags AS "tags", q.LastActivityDate AS "qdate", q.Body AS "question", a.Id AS "aid", a.Body AS "answer", a.ViewCount AS "aviewcount", a.Score AS "ascore", a.LastActivityDate AS "adate", a.CommentCount AS "acommentcount", u.Id AS "uid", u.DisplayName AS "uname", u.Reputation AS "ureputation" FROM Posts AS q JOIN Posts AS a ON a.ParentId = q.Id JOIN Users AS u ON u.Id = a.OwnerUserId WHERE q.Tags LIKE '%<tornado>%' AND q.PostTypeId = 1 AND a.PostTypeId = 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.