instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
the temperature of patient 004-13127 had been less than 37.444 on the last icu visit?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-13127') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND vitalperiodic.temperature < 37.444 AND NOT vitalperiodic.temperature IS NULL
|
### Instruction:
how many days have elapsed since patient 22648 stayed in the ward 52 for the last time during this hospital visit?
### 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 = 22648 AND admissions.dischtime IS NULL)) AND transfers.wardid = 52 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
until 291 days ago patient 033-3009's temperature was greater than 37.1?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-3009')) AND vitalperiodic.temperature > 37.1 AND NOT vitalperiodic.temperature IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-291 day')
|
### Instruction:
Find the name and gender of the staff who has been assigned the job of Sales Person but never Clerical Staff.
### Response:
|
SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Sales Person" EXCEPT SELECT T1.staff_name, T1.staff_gender FROM staff AS T1 JOIN Staff_Department_Assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.job_title_code = "Clerical Staff"
|
### Instruction:
What is the best restaurant in san francisco for french food ?
### Response:
|
SELECT location.house_number, restaurant.name FROM location, restaurant WHERE location.city_name = 'san francisco' AND restaurant.food_type = 'french' AND restaurant.id = location.restaurant_id AND restaurant.rating = (SELECT MAX(RESTAURANTalias1.rating) FROM location AS LOCATIONalias1, restaurant AS RESTAURANTalias1 WHERE LOCATIONalias1.city_name = 'san francisco' AND RESTAURANTalias1.food_type = 'french' AND RESTAURANTalias1.id = LOCATIONalias1.restaurant_id)
|
### Instruction:
Users with +5 in smartmatch.
### Response:
|
SELECT Answers.OwnerUserId FROM (SELECT Posts.Id, Posts.Tags FROM Posts JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id WHERE PostTypes.Name = 'Question') AS Questions JOIN (SELECT Posts.Id, Posts.ParentId, Posts.Score, Posts.OwnerUserId FROM Posts JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id WHERE PostTypes.Name = 'Answer') AS Answers ON Questions.Id = Answers.ParentId WHERE Questions.Tags LIKE '%<smartmatch>%' GROUP BY Answers.OwnerUserId HAVING SUM(Answers.Score) >= 5
|
### Instruction:
what were the five most frequently ordered procedures for patients in the age of 30s last year?
### 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 BETWEEN 30 AND 39) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
how many hours have passed since the last time patient 49176 stayed in the ward 33 in the current hospital visit?
### Response:
|
SELECT 24 * (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 = 49176 AND admissions.dischtime IS NULL)) AND transfers.wardid = 33 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
Ratio between downvoted and commented posts.
### Response:
|
SELECT u.Id AS "user_link", u.DownVotes, COUNT(DISTINCT c.PostId) AS CommentedPosts, CAST(u.DownVotes AS FLOAT) / CAST(COUNT(DISTINCT c.PostId) AS FLOAT) AS Ratio FROM Users AS u INNER JOIN Comments AS c ON c.UserId = u.Id WHERE u.DownVotes > '##min?100##' GROUP BY u.Id, u.DownVotes ORDER BY CAST(u.DownVotes AS FLOAT) / CAST(COUNT(DISTINCT c.PostId) AS FLOAT) DESC
|
### Instruction:
top users by tag.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(TagName) = 'qt' AND u.Reputation >= 3000 GROUP BY u.Id) SELECT COUNT(*) FROM USER_BY_TAG
|
### Instruction:
what diagnosis did patient 16879 receive until 2104 for the last 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 = 16879) AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104' ORDER BY diagnoses_icd.charttime DESC LIMIT 1)
|
### Instruction:
how many hours have passed since patient 53176 had a laboratory test for glucose for the last time on the current hospital visit?
### 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 = 'glucose') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 53176 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
Find tags differing by dots and dashes only with no synonym.
### Response:
|
SELECT Tags.TagName AS NoDotDashTagName, Tags.Count AS NoDotDashTagCount, Tags2.TagName AS DotDashTagName, Tags2.Count AS DotDashTagCount FROM Tags CROSS JOIN Tags AS Tags2 WHERE Tags.TagName != Tags2.TagName AND (REPLACE(REPLACE(Tags2.TagName, '.', ''), '-', '') = Tags.TagName) AND NOT EXISTS(SELECT * FROM TagSynonyms WHERE (SourceTagName = Tags.TagName AND TargetTagName = Tags2.TagName) OR (TargetTagName = Tags.TagName AND SourceTagName = Tags2.TagName)) ORDER BY Tags.TagName
|
### Instruction:
what's the number of days that have passed since patient 57050 first stayed in ward 14 on the current hospital encounter?
### 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 = 57050 AND admissions.dischtime IS NULL)) AND transfers.wardid = 14 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
Stackoverflow top users from kerala By Unnikrishnan.
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_link", Reputation FROM Users WHERE LOWER(Location) LIKE '%kerala%' OR UPPER(Location) LIKE '%KERALA' OR UPPER(Location) LIKE '%Kochi' OR UPPER(Location) LIKE 'TRIVANDRUM' OR LOWER(Location) LIKE 'TRIVANDRUM' OR UPPER(Location) LIKE 'THIRUVANANTHAPURAM' OR LOWER(Location) LIKE 'thiruvananthapuram' ORDER BY Reputation DESC LIMIT 100
|
### Instruction:
in 06/last year, how much did patient 006-50368 weigh for the last time?
### Response:
|
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-50368') AND NOT patient.admissionweight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', patient.unitadmittime) = '06' ORDER BY patient.unitadmittime DESC LIMIT 1
|
### Instruction:
did patient 006-50099 have furosemide 80 mg po tabs prescribed until 13 months ago?
### 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 = '006-50099')) AND medication.drugname = 'furosemide 80 mg po tabs' AND DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-13 month')
|
### Instruction:
New users whose first three questions have a positive score.
### Response:
|
SELECT 'site://users/' + CAST(Id AS TEXT) + '?tab=questions&sort=newest|' + DisplayName, CreationDate FROM (SELECT u.Id, u.DisplayName, u.CreationDate, p.Score, RANK() OVER (PARTITION BY u.Id ORDER BY p.CreationDate) AS Rank FROM Users AS u INNER JOIN Posts AS p ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1) AS temp WHERE Rank <= 3 AND Score < 0 GROUP BY Id, DisplayName, CreationDate HAVING COUNT(*) = 3 ORDER BY CreationDate DESC
|
### Instruction:
what is the minimum cost of the hospital which involves hepatic failure during this year?
### Response:
|
SELECT MIN(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 = 'hepatic failure')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
tell me, what were the five most common procedures until 1 year 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, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
|
### Instruction:
When my Suggested Edit decisions were reversed.
### Response:
|
SELECT SE.PostId AS "post_link", V.Name AS "vote_type", SE.ApprovalDate, SE.RejectionDate FROM SuggestedEditVotes AS SEV INNER JOIN SuggestedEdits AS SE ON SEV.SuggestedEditId = SE.Id INNER JOIN VoteTypes AS V ON V.Id = SEV.VoteTypeId WHERE SEV.UserId = @UserId AND ((SEV.VoteTypeId = 2 AND NOT RejectionDate IS NULL) OR (SEV.VoteTypeId = 3 AND NOT ApprovalDate IS NULL)) ORDER BY SEV.Id DESC LIMIT 1000
|
### Instruction:
Which classes is Dr. Brian Short teaching next semester ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Brian Short%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
did any organisms were found in patient 53863's first staph aureus screen microbiology test until 03/2101?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 53863) AND microbiologyevents.spec_type_desc = 'staph aureus screen' AND NOT microbiologyevents.org_name IS NULL AND STRFTIME('%y-%m', microbiologyevents.charttime) <= '2101-03' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
what diagnosis did patient 57050 receive since 2105 for the last 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 = 57050) AND STRFTIME('%y', diagnoses_icd.charttime) >= '2105' ORDER BY diagnoses_icd.charttime DESC LIMIT 1)
|
### Instruction:
when was the last time when patient 65582 had the maximum value of calculated total co2 since 08/2104?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 65582) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'calculated total co2') AND STRFTIME('%y-%m', labevents.charttime) >= '2104-08' ORDER BY labevents.valuenum DESC, labevents.charttime DESC LIMIT 1
|
### Instruction:
when did patient 030-28944 receive a test for creatinine for the last time this month?
### 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 = '030-28944')) AND lab.labname = 'creatinine' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
how many hours have passed since the last time that patient 2957 stayed during the current hospital encounter in the ward 57?
### Response:
|
SELECT 24 * (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 = 2957 AND admissions.dischtime IS NULL)) AND transfers.wardid = 57 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
what was the drug that in 04/this year patient 72198 was prescribed via the ih route for the last time?
### Response:
|
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72198) AND prescriptions.route = 'ih' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '04' ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
has serum creatinine >= 1.5 mg / dl ( >= 133umol / l ) if male or >= 1.4 mg / dl ( >= 124 umol / l ) if female and / or estimated glomerular filtration rate ( egfr ) < 60 ml / min / 1.73 m^2 at screening.
### Response:
|
SELECT * FROM table_dev_27 WHERE (serum_creatinine >= 1.5 AND gender = 'male') OR (serum_creatinine >= 1.4 AND gender = 'female') OR estimated_glomerular_filtration_rate_egfr < 60
|
### Instruction:
count the number of times that patient 031-22988 in their first hospital encounter had a gastric (ng) output.
### Response:
|
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-22988' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'gastric (ng)'
|
### Instruction:
what did patient 14203 receive for his or her first procedure since 6 years ago?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14203) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year') ORDER BY procedures_icd.charttime LIMIT 1)
|
### Instruction:
what is the three most frequently ordered procedure for patients of 50s in the last year?
### 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 BETWEEN 50 AND 59) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
what is the last specimen test given to patient 031-16123 since 08/2104?
### Response:
|
SELECT microlab.culturesite 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 STRFTIME('%y-%m', microlab.culturetakentime) >= '2104-08' ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
list all flights on CO leaving DENVER on monday
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service, city, date_day, days, flight WHERE (city.city_code = airport_service.city_code AND city.city_name = 'DENVER' AND date_day.day_number = 21 AND date_day.month_number = 2 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.from_airport = airport_service.airport_code) AND flight.airline_code = 'CO'
|
### Instruction:
what's the number of patients who had a nepro intake until 2103?
### 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 = 'nepro' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y', inputevents_cv.charttime) <= '2103'))
|
### Instruction:
what is the name of the specimen test that patient 031-23724 was given for the last time when they came to the hospital first time?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23724' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
what is the average total hospital cost, which includes polyuria - post atn diuresis until 2102?
### 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 = 'polyuria - post atn diuresis')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
did patient 59941 have aortocoronary bypass on the first hospital encounter.
### Response:
|
SELECT COUNT(*) > 0 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'aortocoronary bypass') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 59941 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)
|
### Instruction:
when was the last time that patient 027-141301 had a minimum glucose on their last hospital encounter?
### 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 = '027-141301' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'glucose' ORDER BY lab.labresult, lab.labresulttime DESC LIMIT 1
|
### Instruction:
how many hours have passed since the last time patient 27172 stayed in ward 15 during the current hospital visit.
### Response:
|
SELECT 24 * (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 = 27172 AND admissions.dischtime IS NULL)) AND transfers.wardid = 15 ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
i need information on ground transportation between airport and downtown in the city of BOS
### 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 's the next smallest plane after a TURBOPROP
### Response:
|
SELECT DISTINCT aircraft_code FROM aircraft WHERE capacity = (SELECT MIN(AIRCRAFTalias1.capacity) FROM aircraft AS AIRCRAFTalias1 WHERE AIRCRAFTalias1.capacity > ALL (SELECT DISTINCT AIRCRAFTalias2.capacity FROM aircraft AS AIRCRAFTalias2 WHERE AIRCRAFTalias1.propulsion = 'TURBOPROP')) AND capacity > ALL (SELECT DISTINCT AIRCRAFTalias3.capacity FROM aircraft AS AIRCRAFTalias3 WHERE AIRCRAFTalias3.propulsion = 'TURBOPROP')
|
### Instruction:
Average score by day of post.
### Response:
|
SELECT (TIME_TO_STR(CreationDate, 'WEEKDA%Y') - 1) * 24 + TIME_TO_STR(CreationDate, '%-HOUR') AS WeekHour, CAST(SUM(Score) AS FLOAT) / CAST(COUNT(Id) AS FLOAT) FROM Posts WHERE PostTypeId = 1 AND Score >= 0 AND Score < 10 GROUP BY (TIME_TO_STR(CreationDate, 'WEEKDA%Y') - 1) * 24 + TIME_TO_STR(CreationDate, '%-HOUR') ORDER BY WeekHour
|
### Instruction:
what is the total number of days that have passed since patient 13054's last mchc lab test on their 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 = 'mchc') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13054 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
questions without code examples; parameters: tags/keywords/minimum score.
### Response:
|
SELECT Id AS "post_link", Title, Score, Tags, ViewCount, AnswerCount, CommentCount, FavoriteCount, OwnerUserId FROM Posts AS q WHERE PostTypeId = 1 AND ((q.Tags LIKE '%<sap>%') OR (q.Title LIKE '% sap%' OR q.Title LIKE '%SAP%' OR q.Title LIKE '%Sap%') OR (q.Body LIKE '% sap%' OR q.Body LIKE '%SAP%' OR q.Body LIKE '%Sap%')) AND (q.Body LIKE '%<pre><code>%') AND q.Score >= @MinScore ORDER BY Score DESC
|
### Instruction:
Which claims caused more than 2 settlements or have the maximum claim value? List the date the claim was made and the claim id.
### Response:
|
SELECT T1.date_claim_made, T1.claim_id FROM claims AS T1 JOIN settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id HAVING COUNT(*) > 2 UNION SELECT T1.date_claim_made, T1.claim_id FROM claims AS T1 JOIN settlements AS T2 ON T1.claim_id = T2.claim_id WHERE T1.amount_claimed = (SELECT MAX(amount_claimed) FROM claims)
|
### Instruction:
what was patient 19161 diagnosed with when they came to the hospital last time 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 = 19161 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY diagnoses_icd.charttime LIMIT 1)
|
### Instruction:
patient has a systolic blood pressure ( sitting ) of greater than 150 mmhg, a diastolic ( sitting ) greater than 95 mmhg, a decrease in systolic blood pressure of more than 30 mmhg upon standing for 2 minutes from a sitting or supine position, or a pulse ( sitting or supine ) less than 55 or greater than 85 .
### Response:
|
SELECT * FROM table_train_137 WHERE (systolic_blood_pressure_sbp > 150 OR diastolic_greater_than > 95) OR (pulse_rate < 55 OR pulse_rate > 85)
|
### Instruction:
what is the minimum amount of hospital cost that includes oxyhemoglobin the last year?
### Response:
|
SELECT MIN(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 = 'oxyhemoglobin')) 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 procedure, which patient 016-9636 underwent two times during this hospital visit?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, COUNT(treatment.treatmenttime) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-9636' AND patient.hospitaldischargetime IS NULL)) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 = 2
|
### Instruction:
User Activity after joining histogram.
### Response:
|
WITH UserStats AS (SELECT Id, CAST(CreationDate AS DATE) AS CDate FROM Users), UActivity AS (SELECT UserId, CDate, CAST(CreationDate AS DATE) AS ADate, COUNT(DISTINCT RevisionGUID) AS ActCount FROM PostHistory INNER JOIN UserStats ON UserStats.Id = UserId AND PostHistory.CreationDate >= UserStats.CDate GROUP BY UserId, CDate, CAST(CreationDate AS DATE)) SELECT DATEDIFF(week, CDate, ADate) AS Weeks, SUM(ActCount) AS Activity FROM UActivity GROUP BY DATEDIFF(week, CDate, ADate) ORDER BY Weeks
|
### Instruction:
what was patient 005-87465's last output time of the stool on the current icu visit?
### 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 = '005-87465') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'stool' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
when has patient 002-20631 first had the mch minimum value the last month?
### 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 = '002-20631')) AND lab.labname = 'mch' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresult, lab.labresulttime LIMIT 1
|
### Instruction:
when is the first time patient 017-14836 had the maximum value of -polys when they came to the hospital first time?
### 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 = '017-14836' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = '-polys' ORDER BY lab.labresult DESC, lab.labresulttime LIMIT 1
|
### Instruction:
tell me the top three most common diagnoses in patients in the age of 50s until 3 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 50 AND 59) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
Questions going from [status-declined] to [status-completed] after posting a bounty.
### Response:
|
SELECT DISTINCT (d.PostId) AS "post_link" FROM PostHistory AS d INNER JOIN PostHistory AS c ON d.PostId = c.PostId INNER JOIN Votes AS v ON v.PostId = c.PostId AND v.CreationDate > d.CreationDate AND v.CreationDate < c.CreationDate WHERE d.PostHistoryTypeId = 6 AND d.Text LIKE '%<status-declined>%' AND c.PostHistoryTypeId = 6 AND c.Text LIKE '%<status-completed>%' AND v.VoteTypeId = 8
|
### Instruction:
Top 500 Askers on the site. A list of the top 500 askers of questions
ordered by average answer score excluding
community wiki / closed posts.
### Response:
|
SELECT * FROM (SELECT OwnerUserId AS "user_link", COUNT(Posts.Id) AS Questions, CAST(AVG(CAST(Score AS FLOAT)) AS FLOAT(6, 2)) AS "average_question_score" FROM Posts WHERE PostTypeId = 1 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL GROUP BY OwnerUserId ORDER BY COUNT(Posts.Id) DESC LIMIT 500) ORDER BY 'average_question_score' DESC
|
### Instruction:
what was the first time patient 12927 had a maximum of hematocrit in this month?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12927) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hematocrit') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.valuenum DESC, labevents.charttime LIMIT 1
|
### Instruction:
what procedure did patient 64873 undergo for the first time since 3 years ago?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 64873) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-3 year') ORDER BY procedures_icd.charttime LIMIT 1)
|
### Instruction:
how much is patient 017-55081's weight for the first time in 06/last year?
### Response:
|
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-55081') AND NOT patient.admissionweight IS NULL AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', patient.unitadmittime) = '06' ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
how many days have elapsed since the first time patient 83182 stayed in the ward 14 in their current hospital encounter?
### 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 = 83182 AND admissions.dischtime IS NULL)) AND transfers.wardid = 14 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
what is the yearly minimum amount of carboxyhemoglobin patient 29971 has until 5 months ago?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 29971) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'carboxyhemoglobin') AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-5 month') GROUP BY STRFTIME('%y', labevents.charttime)
|
### Instruction:
what was the first thing patient 55360 got diagnosed with in 2105?
### 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 = 55360) AND STRFTIME('%y', diagnoses_icd.charttime) = '2105' ORDER BY diagnoses_icd.charttime LIMIT 1)
|
### Instruction:
what is the first value of patient 027-77260's sao2 on the last intensive care unit visit?
### Response:
|
SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-77260') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1
|
### Instruction:
Does Prof. Valeriy Tenishev 's ARTDES 182 class 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 = 'ARTDES' AND course.has_lab = 'N' AND course.number = 182 AND instructor.name LIKE '%Valeriy Tenishev%'
|
### Instruction:
what is the total number of patients who had received a loc exc les metatar/tar procedure two times?
### Response:
|
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'loc exc les metatar/tar') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2
|
### Instruction:
what is the yearly minimum eosinophils level of patient 50286 since 09/2104?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 50286) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'eosinophils') AND STRFTIME('%y-%m', labevents.charttime) >= '2104-09' GROUP BY STRFTIME('%y', labevents.charttime)
|
### Instruction:
Percent of questions that have [ltn] [one] tag.
### Response:
|
SELECT OUT.Questions, @totalPosted AS Total, OUT.Questions * 100 / @totalPosted AS "percent" FROM (SELECT SUM(CASE WHEN @type = 'ltn' AND IDT.NumTags <= @numOfTags THEN 1 WHEN @type = 'gtn' AND IDT.NumTags >= @numOfTags THEN 1 ELSE 0 END) AS Questions, @totalPosted AS Posted FROM (SELECT Id, COUNT(TagId) AS NumTags FROM Posts JOIN PostTags ON PostId = Id WHERE PostTypeId = 1 GROUP BY Id) AS IDT) AS OUT GROUP BY Questions
|
### Instruction:
how many days have elapsed since patient 17667 received the creatinine laboratory test for the last time 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 = 'creatinine') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17667 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1
|
### Instruction:
How many of closed bounties have been awarded?.
### Response:
|
WITH BountyCloses AS (SELECT COUNT(*) AS Amount FROM Votes WHERE VoteTypeId = 9), BountyAwards AS (SELECT COUNT(*) AS Amount FROM Votes INNER JOIN Posts ON (Votes.PostId = Posts.Id) WHERE VoteTypeId = 9 AND NOT Posts.ParentId IS NULL) SELECT BountyCloses.Amount AS ClosedBounties, BountyAwards.Amount AS AwardedBounties, BountyAwards.Amount * 100 / BountyCloses.Amount AS Percentage FROM BountyCloses, BountyAwards
|
### Instruction:
Approved edits with no votes.
### Response:
|
SELECT E.Id AS SuggestedEditID, E.ApprovalDate, P.Id AS "post_link" FROM (SELECT E.Id, E.PostId, E.ApprovalDate, COUNT(v.Id) AS vote_count FROM SuggestedEdits AS E LEFT JOIN SuggestedEditVotes AS V ON E.Id = V.SuggestedEditId WHERE NOT E.ApprovalDate IS NULL GROUP BY E.Id, E.PostId, E.ApprovalDate HAVING COUNT(v.Id) = 0) AS E LEFT JOIN Posts AS P ON E.PostId = P.Id ORDER BY E.Id DESC
|
### Instruction:
New User's Questions closed after N minutes of registering.
### Response:
|
SELECT DATEADD(D, DATEDIFF(D, 0, ClosedDate), 0) AS ClosedDate, COUNT(*) AS Total FROM Posts AS p INNER JOIN Users AS u ON p.OwnerUserId = u.Id INNER JOIN PostHistory AS ph ON ph.PostId = p.Id WHERE DATEDIFF(MINUTE, u.CreationDate, ClosedDate) < '##ClosureTimeInMinutes##' GROUP BY DATEADD(D, DATEDIFF(D, 0, ClosedDate), 0) ORDER BY DATEADD(D, DATEDIFF(D, 0, ClosedDate), 0) DESC
|
### Instruction:
how many days have elapsed since the last time patient 027-203413 was given a procedure in this hospital visit?
### 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 = '027-203413' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
votes on all posts by a specific user.
### Response:
|
SELECT pt.Name AS PostType, vt.Name AS VoteType, COUNT(v.Id) AS NumVotes FROM Posts AS p LEFT JOIN Votes AS v ON p.Id = v.PostId LEFT JOIN VoteTypes AS vt ON vt.Id = v.VoteTypeId LEFT JOIN PostTypes AS pt ON pt.Id = p.PostTypeId WHERE p.OwnerUserId = '##UserId##' AND p.DeletionDate IS NULL AND p.ClosedDate IS NULL GROUP BY pt.Name, vt.Name HAVING COUNT(v.Id) > 0 ORDER BY pt.Name DESC, vt.Name DESC
|
### Instruction:
what was the name of the output which patient 009-424 had for the last time 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 = '009-424') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
when has patient 021-75161 had the first intake on the last intensive care unit visit?
### 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 = '021-75161') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
count the number of people who were diagnosed with chr kidney dis stage iii until 4 years ago.
### 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 kidney dis stage iii') AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-4 year'))
|
### Instruction:
what did patient 035-3496 first have as his intake until 59 days ago?
### 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 = '035-3496')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-59 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
how many hours have elapsed since patient 25733 had received an anion gap lab test for the first time in this hospital visit?
### 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 = 'anion gap') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25733 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime LIMIT 1
|
### Instruction:
for the first time in 11/2104, what specimen test did patient 031-9128 get?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-9128')) AND STRFTIME('%y-%m', microlab.culturetakentime) = '2104-11' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
what is the name of the drug that was last prescribed for patient 006-36108 during the previous month?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-36108')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
Does any section of RCSSCI 360 start after 10:00 ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'RCSSCI' AND course.number = 360 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
Top 2000 users ranked by average answer score.
### Response:
|
SELECT Users.Id AS "user_link", SUM(Posts.Score) AS "Upvotes", COUNT(*) AS "Answers", 1.0 * SUM(Posts.Score) / COUNT(*) AS "Ave. score", MAX(Posts.Score) AS "Highest score", 1.0 * MAX(Posts.Score) / SUM(Posts.Score) AS "Fraction votes from highest scoring answer" FROM Posts LEFT JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Posts.PostTypeId = 2 GROUP BY Users.Id ORDER BY 'Ave. score' DESC LIMIT 2000
|
### Instruction:
what is the yearly average amount of phenytoin patient 23475 has until 01/2105?
### Response:
|
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23475) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phenytoin') AND STRFTIME('%y-%m', labevents.charttime) <= '2105-01' GROUP BY STRFTIME('%y', labevents.charttime)
|
### Instruction:
Is there a section for CLIMATE 440 after 10:00 ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '10:00' AND course.course_id = course_offering.course_id AND course.department = 'CLIMATE' AND course.number = 440 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
how many hours have passed since patient 90663's first stay in ward 12 during their current hospital encounter?
### Response:
|
SELECT 24 * (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 = 90663 AND admissions.dischtime IS NULL)) AND transfers.wardid = 12 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
Retrieve Answered Questions Tagged as 'Java' Created In The Month of January 2018.
### Response:
|
SELECT Q.Id, Q.AcceptedAnswerId, Q.CreationDate, Q.Score, Q.Body AS "Question Body", Q.Title AS "Question Title", A.Body AS "Answer Body", Q.Tags FROM Posts AS Q INNER JOIN Posts AS A ON Q.AcceptedAnswerId = A.Id WHERE Q.Tags = '<##tag?java##>' AND Q.CreationDate BETWEEN '2018-01-01' AND '2018-01-31' AND Q.Score >= 0 ORDER BY Q.Id
|
### Instruction:
how many hours has passed since patient 82132 stayed in ward 23 for the first time during this hospital visit?
### Response:
|
SELECT 24 * (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 = 82132 AND admissions.dischtime IS NULL)) AND transfers.wardid = 23 ORDER BY transfers.intime LIMIT 1
|
### Instruction:
Which of my posts have been downvoted?. Lets you see where you went wrong.
### Response:
|
SELECT p.Id AS "post_link", (SELECT COUNT(1) FROM Votes AS v JOIN VoteTypes AS t ON v.VoteTypeId = t.Id WHERE v.PostId = p.Id AND t.Name = 'UpMod') AS Upvotes, (SELECT COUNT(1) FROM Votes AS v JOIN VoteTypes AS t ON v.VoteTypeId = t.Id WHERE v.PostId = p.Id AND t.Name = 'DownMod') AS Downvotes FROM Posts AS p WHERE p.OwnerUserId = @UserId ORDER BY Downvotes DESC, Upvotes DESC
|
### Instruction:
how many times have patient 015-94542 produced a fluid removed until 04/2100?
### Response:
|
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-94542')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'fluid removed' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) <= '2100-04'
|
### Instruction:
find candidates for Revival badge with a certain tag. find questions older than 60 days which have no answers of score >= 2
### Response:
|
SELECT Id AS "post_link", Score, ViewCount AS Views, AnswerCount AS Answers, Body, CreationDate FROM Posts WHERE PostTypeId = 1 AND CreationDate < CURRENT_TIMESTAMP() - 30 AND ClosedDate IS NULL AND Tags LIKE '%<' + LOWER(@tag) + '>%' AND NOT EXISTS(SELECT * FROM Posts AS p WHERE p.ParentId = Posts.Id AND p.Score >= 2 AND p.PostTypeId = 2) ORDER BY CreationDate DESC LIMIT 1000
|
### Instruction:
have any organisms appeared in the last biopsy microbiology test of patient 23760 in this year?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23760) AND microbiologyevents.spec_type_desc = 'biopsy' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY microbiologyevents.charttime DESC LIMIT 1
|
### Instruction:
when was the first microbiology test of patient 031-22988, until 16 months ago?
### 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-22988')) AND DATETIME(microlab.culturetakentime) <= DATETIME(CURRENT_TIME(), '-16 month') ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
tell me the maximum sao2 for patient 004-13127's body today?
### Response:
|
SELECT MAX(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-13127')) AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
tell me the average hospital cost that includes mechanical ventilation - permissive hypercapnea in 2105?
### 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 = 'mechanical ventilation - permissive hypercapnea')) AND STRFTIME('%y', cost.chargetime) = '2105' GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
when was the heartrate of patient 006-205326 last measured on the last intensive care unit visit?
### 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-205326') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.heartrate IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
For the next Winter session of Language and Mind , who is teaching ?
### 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 semester ON semester.semester_id = course_offering.semester INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Language and Mind%' AND semester.semester = 'Winter' AND semester.year = 2017
|
### Instruction:
what's the name of the drug that was first prescribed to patient 028-55503 in the previous month?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-55503')) AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Top users by average question score. List the top users by average score (upvotes - downvotes) on answers
### Response:
|
SELECT p.OwnerUserId AS "user_link", MIN(u.Reputation) AS "reputation", COUNT(*) AS "number_of_questions", ROUND(AVG(CAST(p.Score AS FLOAT)), 2) AS "average_score" FROM Posts AS p INNER JOIN Users AS u ON p.OwnerUserId = u.Id WHERE p.PostTypeId = 1 GROUP BY p.OwnerUserId HAVING COUNT(*) >= '##MinimumQuestionsPerUser?10##' ORDER BY 'average_score' LIMIT 1000
|
### Instruction:
Do you know who teaches History of Decor 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 '%History of Decor%' AND semester.semester = 'WN' AND semester.year = 2016
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.