instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: what did patient 012-37411 last have as output on the current icu 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 = '012-37411') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: the number of patients who had a colonoscopy procedure in 2103. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'colonoscopy') AND STRFTIME('%y', procedures_icd.charttime) = '2103')
### Instruction: what was patient 30826 diagnosed with first time on this hospital encounter. ### 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 = 30826 AND admissions.dischtime IS NULL) ORDER BY diagnoses_icd.charttime LIMIT 1)
### Instruction: had patient 029-30149 been diagnosed as fungemia in 2105? ### Response:
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '029-30149')) AND diagnosis.diagnosisname = 'fungemia' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105'
### Instruction: the total number of times until 36 months ago patient 010-15363 has had a lab test for -eos. ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-15363')) AND lab.labname = '-eos' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-36 month')
### Instruction: My median and average answer score at given date. Reports median and average answer score. The MedianAnswerScore2 is more precise version of median. ### Response:
SELECT COUNT(Posts.Id) AS Answers, (SELECT MAX(Score) FROM (SELECT percent AS Score FROM Posts AS PU WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND PU.OwnerUserId = '##UserId##' ORDER BY Score LIMIT 50) AS t) AS MedianAnswerScore FROM Posts WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND OwnerUserId = '##UserId##'
### Instruction: has patient 006-140729 been prescribed glucagon in 2105. ### 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-140729')) AND medication.drugname = 'glucagon' AND STRFTIME('%y', medication.drugstarttime) = '2105'
### Instruction: has labetalol hcl, midazolam or midazolam hcl been prescribed to patient 016-19343? ### 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 = '016-19343')) AND medication.drugname IN ('labetalol hcl', 'midazolam', 'midazolam hcl')
### Instruction: count the number of patients who had an intake of enfamil 26 by conc. ### 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 = 'enfamil 26 by conc.' AND d_items.linksto = 'inputevents_cv')))
### Instruction: what is until 04/2105 maximum albumin, body fluid value of patient 31300? ### Response:
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31300) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'albumin, body fluid') AND STRFTIME('%y-%m', labevents.charttime) <= '2105-04'
### Instruction: when was the first time patient 19059 was prescribed in 02/this year? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19059) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '02' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what's the name of the drug that patient 007-16517 is allergic to since 10/2103? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-16517')) AND STRFTIME('%y-%m', allergy.allergytime) >= '2103-10'
### Instruction: what are the four most common procedures for patients with the age 60 or above in 2101? ### Response:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age >= 60) AND STRFTIME('%y', treatment.treatmenttime) = '2101' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4
### Instruction: how many hours have elapsed since the first time patient 92788 was prescribed gabapentin during their current hospital encounter. ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 92788 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'gabapentin' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: when did patient 030-52327 have the last lab test in 12/2105? ### 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-52327')) AND STRFTIME('%y-%m', lab.labresulttime) = '2105-12' ORDER BY lab.labresulttime DESC LIMIT 1
### Instruction: Are there any upper-level PUBPOL classes offered this Fall ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.department = 'PUBPOL' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Fall' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: was there an direct bilirubin lab test performed on patient 009-3149 since 1 year ago? ### Response:
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-3149')) AND lab.labname = 'direct bilirubin' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: what test was given to patient 021-221706 for the last time until 15 months ago. ### Response:
SELECT lab.labname FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-221706')) AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-15 month') ORDER BY lab.labresulttime DESC LIMIT 1
### Instruction: what did patient 007-7646 receive for his or her last procedure since 5 years ago? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-7646')) AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-5 year') ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: count the number of patients whose ethnicity is american indian/alaska native and drug name is potassium chl 40 meq / 1000 ml d5ns? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND prescriptions.drug = "Potassium Chl 40 mEq / 1000 mL D5NS"
### Instruction: when did patient 028-61375 first undergo a surgery until 4 years ago? ### Response:
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-61375')) AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, a bar chart shows the distribution of hire_date and the sum of salary bin hire_date by time, show in descending by the Y. ### Response:
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(SALARY) DESC
### Instruction: The n-th question (excluding questions migrated here). ### Response:
WITH base AS (SELECT DISTINCT q.Id AS qid, q.CreationDate AS qdate FROM Posts AS q JOIN PostHistory AS ph ON (q.Id = ph.PostId) WHERE (q.PostTypeId = 1) AND (ph.PostHistoryTypeId != 36)), ordered AS (SELECT ROW_NUMBER() OVER (ORDER BY qdate) AS rownumber, qid, qdate FROM base) SELECT rownumber, qid AS "post_link", qdate FROM ordered WHERE rownumber = '##num##'
### Instruction: what did patient 035-24054 have first as the output on the current icu 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 = '035-24054') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: what was the last medication prescribed to patient 007-1517 on their first hospital encounter? ### 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 = '007-1517' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: what is the total cost of the maximum hospital involving a laboratory test for granular casts in 2105? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'granular casts')) AND STRFTIME('%y', cost.chargetime) = '2105' GROUP BY cost.hadm_id) AS t1
### Instruction: what is the maximum amount of the total hospital cost which involves failure to wean - due to cns impairment? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'failure to wean - due to cns impairment')) GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: Users who have contributed accepted answers, located in Singapore. ### Response:
SELECT OwnerUserId AS userid, MAX(Users.DisplayName) AS displayname, MAX(Users.Reputation) AS reputation, MAX(Users.AboutMe) AS aboutme, MAX(Users.Location) AS location, COUNT(Posts.Id) AS numanswers FROM Posts, Users WHERE Posts.Id IN (SELECT AcceptedAnswerId FROM Posts WHERE PostTypeId = 1 AND Tags LIKE '%devops%') AND Users.Id = Posts.OwnerUserId AND Location LIKE '%ingapore%' GROUP BY OwnerUserId ORDER BY numanswers DESC
### Instruction: find the number of patients categorized under hematology lab test who have diagnoses of insulins and antidiabetic agents causing adverse effects in therapeutic use. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Insulins and antidiabetic agents causing adverse effects in therapeutic use" AND lab."CATEGORY" = "Hematology"
### Instruction: What is the Spring-Summer schedule for upper-level MO offerings ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MO' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Spring-Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Questions posted in a given year without a bounty. ### Response:
SELECT COUNT(*) FROM Posts AS p WHERE Id NOT IN (SELECT PostId FROM Votes AS v WHERE v.VoteTypeId = 8) AND p.CreationDate > '2015-05-01' AND p.PostTypeId = 1 AND (p.Score >= 2 AND p.Score <= 9) AND (p.ViewCount >= 77 AND p.ViewCount <= 628) AND p.ClosedDate IS NULL AND p.FavoriteCount >= 1 AND NOT p.AcceptedAnswerId IS NULL
### Instruction: what was the name of procedure, that patient 009-5801 was last received during the last hospital encounter? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5801' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: when was patient 030-3372 given for the first time a lab test until 12/2101? ### 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-3372')) AND STRFTIME('%y-%m', lab.labresulttime) <= '2101-12' ORDER BY lab.labresulttime LIMIT 1
### Instruction: What 300 -level courses are available in Fall or Winter terms ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number BETWEEN 300 AND 300 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Are there any professors who teach Survey Research , other than Prof. Hasson ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.name LIKE '%Survey Research%' AND NOT instructor.name LIKE '%Hasson%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: Has the person Anuj Kumar ever taught the class BIOPHYS 521 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'BIOPHYS' AND course.number = 521 AND instructor.name LIKE '%Anuj Kumar%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: what did patient 015-12508 receive for his or her last procedure in the last hospital visit? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-12508' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: give me the total amount of patient 594's input on 05/10/2105? ### Response:
SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 594)) AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) = '2105-05-10'
### Instruction: how many times did patient 016-30273 get -lymphs tested until 22 months ago? ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-30273')) AND lab.labname = '-lymphs' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-22 month')
### Instruction: Weaksauce Rep Per Character. This is dirty because it doesn't strip HTML tags ### Response:
SELECT PostID = p.Id, u.DisplayName, AnswerRep = p.Score * 10, AnswerLength = (LENGTH(p.Body)), RepPerChar = CAST((p.Score * 10) AS FLOAT(23, 13)) / CAST((LENGTH(p.Body)) AS FLOAT(23, 13)) FROM Users AS u JOIN Posts AS p ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 2 ORDER BY u.DisplayName DESC
### Instruction: how many patients are with married marital status diagnosed for subarachnoid hemorrhage following injury without mention of open intracranial wound with loss of consciousness of unspecified duration? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "MARRIED" AND diagnoses.long_title = "Subarachnoid hemorrhage following injury without mention of open intracranial wound, with loss of consciousness of unspecified duration"
### Instruction: Comments from one user under question from another user. ### Response:
SELECT CONCAT('https://stats.meta.stackexchange.com/questions/', Posts.ParentId, '/', MyComments.PostId, '#comment', MyComments.Id, '_', MyComments.PostId) AS Link, MyComments.*, Posts.ParentId FROM (SELECT * FROM Comments WHERE UserId = '805') AS MyComments, Posts AS Posts WHERE Posts.Id = MyComments.PostId AND Posts.OwnerUserId = '58675' AND Posts.PostTypeId = 1
### Instruction: Questions with one tag on [pets.se]. Find all the questions on [pets.se] that have exactly one tag, with the premise that they need more to classify (at least) pet type and the problem. ### Response:
WITH singletons AS (SELECT PostId FROM PostTags GROUP BY PostId HAVING COUNT(PostTags.TagId) = 1) SELECT Id, Id AS "post_link", Tags FROM Posts INNER JOIN singletons ON singletons.PostId = Posts.Id WHERE Posts.PostTypeId = 1 AND Posts.ClosedDate IS NULL ORDER BY Posts.Id
### Instruction: have known hemoglobinopathy or chronic anemia ( hemoglobin concentration < 11.5 g / dl [115 g / l] for male , < 10.5 g / dl [105 g / l] for female ) . ### Response:
SELECT * FROM table_dev_56 WHERE hemoglobinopathy = 1 OR anemia = 1 OR (hemoglobin_concentration < 11.5 AND gender = 'male') OR (hemoglobin_concentration < 10.5 AND gender = 'female')
### Instruction: did 5% dextrose, ranitidine, or albumin 25% (12.5gm) have been ordered for patient 17462 during this hospital visit. ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17462 AND admissions.dischtime IS NULL) AND prescriptions.drug IN ('5% dextrose', 'ranitidine', 'albumin 25% (12.5gm)')
### Instruction: Do any professors besides Pinella teach The Writing of Poetry ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.name LIKE '%The Writing of Poetry%' AND NOT instructor.name LIKE '%Pinella%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: what was the name of the procedure, which patient 015-33415 was first received until 2104? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-33415')) AND STRFTIME('%y', treatment.treatmenttime) <= '2104' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what is patient 52456's minimum value of lipase last month? ### Response:
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 52456) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'lipase') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: how many patients are diagnosed for atherosclerosis of native arteries of the extremities with intermittent claudication and had lab test abnormal status as abnormal? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Atherosclerosis of native arteries of the extremities with intermittent claudication" AND lab.flag = "abnormal"
### Instruction: What is the Pine Rivers total population after 1947 with a Redcliffe population smaller than 68,877, a total population greater than 50,785, and a Caboolture population greater than 12,207? ### Response:
SELECT COUNT("(Pine Rivers)") FROM table_71057 WHERE "Year" > '1947' AND "(Redcliffe)" < '68,877' AND "Population (Total)" > '50,785' AND "(Caboolture)" > '12,207'
### Instruction: Got most down to non-CW answers. ### Response:
SELECT DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS Rank, Posts.OwnerUserId AS "user_link", Posts.OwnerUserId AS UserId, COUNT(*) AS Count FROM Posts, Votes WHERE Posts.Id = Votes.PostId AND Votes.VoteTypeId = 3 AND Posts.PostTypeId = 2 AND Posts.CommunityOwnedDate IS NULL AND Posts.OwnerUserId > 0 GROUP BY Posts.OwnerUserId ORDER BY Count DESC, UserId LIMIT 100
### Instruction: What human computer interaction courses are there in Spring or Summer 2003 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE area.area LIKE '%human computer interaction%' AND semester.semester IN ('SP', 'SU', 'SS') AND semester.year = 2003
### Instruction: show me the flights from IAD to SAN FRANCISCO leaving after 1800 ### Response:
SELECT DISTINCT flight.flight_id FROM airport, airport_service, city, flight WHERE (city.city_code = airport_service.city_code AND city.city_name = 'SAN FRANCISCO' AND flight.departure_time > 1800 AND flight.to_airport = airport_service.airport_code) AND airport.airport_code = 'IAD' AND flight.from_airport = airport.airport_code
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, a line chart shows the trend of commission_pct over hire_date , and order in descending by the HIRE_DATE please. ### Response:
SELECT HIRE_DATE, COMMISSION_PCT FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY HIRE_DATE DESC
### Instruction: count the number of times patient 006-43795 had been tested for phenytoin until 1 month ago. ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-43795')) AND lab.labname = 'phenytoin' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-1 month')
### Instruction: what is the name of a drug that patient 021-49082 was allergic to since 11/2100? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-49082')) AND STRFTIME('%y-%m', allergy.allergytime) >= '2100-11'
### Instruction: provide the number of patients with delta abnormal lab test status who have benign neoplasm of pituitary gland and craniopharyngeal duct diagnoses. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Benign neoplasm of pituitary gland and craniopharyngeal duct" AND lab.flag = "delta"
### Instruction: Which 1990 has a 2005 smaller than 5,361, and a 2007 smaller than 4,841, and a 2006 smaller than 618, and a 2004 smaller than 389? ### Response:
SELECT "1990" FROM table_63887 WHERE "2005" < '5,361' AND "2007" < '4,841' AND "2006" < '618' AND "2004" < '389'
### Instruction: was the senna prescribed to patient 26849 in 08/last year? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26849) AND prescriptions.drug = 'senna' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', prescriptions.startdate) = '08'
### Instruction: what's the minimum cost of a hospital with potassium, urine until 2103? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium, urine')) AND STRFTIME('%y', cost.chargetime) <= '2103' GROUP BY cost.hadm_id) AS t1
### Instruction: 1960 larger than 196, and a 1996[2] smaller than 726, and a 1980 larger than 125, and a 1990 larger than 848, what is the highest 1950? ### Response:
SELECT MAX("1950") FROM table_36165 WHERE "1960" > '196' AND "1996[2]" < '726' AND "1980" > '125' AND "1990" > '848'
### Instruction: Name the courses required for PORTUG 232 ? ### Response:
SELECT DISTINCT COURSE_1.department, COURSE_1.name, COURSE_1.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.pre_course_id WHERE COURSE_0.department = 'PORTUG' AND COURSE_0.number = 232
### Instruction: There's Just No Pleasing Some People. Top 100 most highly upvoted posts that still earnt a downvote from a contrarian. ### Response:
SELECT SUM(CASE WHEN Votes.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN Votes.VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, Votes.PostId AS "post_link" FROM Votes GROUP BY Votes.PostId HAVING SUM(CASE WHEN Votes.VoteTypeId = 3 THEN 1 ELSE 0 END) > 1
### Instruction: what is the three most frequently ordered lab test until 2 years ago for patients in the age of 60 or above? ### Response:
SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age >= 60) AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 3
### Instruction: what is the number of patients who have had a nicardipine hcl intake? ### 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 = 'nicardipine hcl' AND d_items.linksto = 'inputevents_cv')))
### Instruction: what would be patient 028-55868's yearly maximum weight since 07/2105? ### Response:
SELECT MAX(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-55868') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y-%m', patient.unitadmittime) >= '2105-07' GROUP BY STRFTIME('%y', patient.unitadmittime)
### Instruction: how many patients have received revision of lead treatment in 2104? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'revision of lead') AND STRFTIME('%y', procedures_icd.charttime) = '2104')
### Instruction: what is the name of the drug which patient 004-29334 was allergic to since 03/2104? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-29334')) AND STRFTIME('%y-%m', allergy.allergytime) >= '2104-03'
### Instruction: Can 100 -level classes be taken in Fall or Winter ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number BETWEEN 100 AND 100 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what was the name of the procedure, which patient 029-30149 was first received since 2101? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '029-30149')) AND STRFTIME('%y', treatment.treatmenttime) >= '2101' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what is the maximum total cost of a hospital that includes a procedure called a arthrocentesis? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'arthrocentesis')) GROUP BY cost.hadm_id) AS t1
### Instruction: calculate the number of times patient 030-6898 received the bedside glucose test test since 3 years ago. ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-6898')) AND lab.labname = 'bedside glucose' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: How many courses for each office? Show me a stacked bar chart. The x-axis is office name and group by course description. ### Response:
SELECT PROF_OFFICE, COUNT(PROF_OFFICE) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY CRS_DESCRIPTION, PROF_OFFICE
### Instruction: 2016 answers by users with no answers before 2016. ### Response:
SELECT A.Id AS "post_link", A.Score, U.DisplayName FROM Posts AS A JOIN Users AS U ON A.OwnerUserId = U.Id WHERE YEAR(A.CreationDate) = 2017 AND A.PostTypeId = 2 AND NOT EXISTS(SELECT * FROM Posts AS A2 WHERE A2.OwnerUserId = U.Id AND YEAR(A2.CreationDate) < 2016 AND A2.PostTypeId = 2) ORDER BY A.Score DESC
### Instruction: tell me the first test that patient 010-9756 had received this month? ### Response:
SELECT lab.labname FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-9756')) AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY lab.labresulttime LIMIT 1
### Instruction: has since 07/2104 patient 18678 been tested for hematocrit, ascites? ### Response:
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hematocrit, ascites') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 18678) AND STRFTIME('%y-%m', labevents.charttime) >= '2104-07'
### Instruction: Percentage of high-rep users by join date. For a given month, what percentage of users are 'High Reputation' users? ### Response:
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0) AS Date, SUM(CASE WHEN u.Reputation > @highRep THEN 1 ELSE 0 END) AS "high_rep_%" FROM Users AS u GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0) ORDER BY DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0)
### Instruction: what was the first procedure time of intraaortic balloon pump removal for patient 013-29301? ### Response:
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-29301')) AND treatment.treatmentname = 'intraaortic balloon pump removal' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what procedure did patient 007-7646 since 5 years ago receive for the last time? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-7646')) AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-5 year') ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: Meta posts with more than one required tag. ### Response:
SELECT c.PostId AS "post_link", REPLACE(REPLACE(REPLACE(p.Tags, ' ', ' '), '><', ' '), '!= ', '') AS "tags" FROM (SELECT PostId, COUNT(*) AS "count" FROM PostTags WHERE TagId = @TagId1 OR TagId = @TagId2 OR TagId = @TagId3 OR TagId = @TagId4 GROUP BY PostId) AS c LEFT JOIN Posts AS p ON p.Id = c.PostId WHERE c.Count >= 2 ORDER BY c.PostId
### Instruction: Your downvoted questions what you can't delete. Buggy - after the daily mirror is ready, I will be able to fix it ### Response:
WITH Raw AS (SELECT Q.Id AS QId, A.Id AS AId, Votes.Id AS VoteId FROM Posts AS Q INNER JOIN Posts AS A ON Q.Id = A.ParentId LEFT JOIN Votes ON Votes.PostId = A.Id WHERE Q.OwnerUserId = '##UserId:int##' AND Q.Score < 0 AND A.OwnerUserId != '##UserId##') SELECT QId FROM Raw WHERE NOT VoteId IS NULL
### Instruction: give me the total amount of output amount-colostomy that patient 004-86136 has produced? ### 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 = '004-86136')) AND intakeoutput.celllabel = 'output amount-colostomy' AND intakeoutput.cellpath LIKE '%output%'
### Instruction: what is the maximum daily number of patients who had fulminant hepatic failure during the last year? ### Response:
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'fulminant hepatic failure' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY STRFTIME('%y-%m-%d', diagnosis.diagnosistime)) AS t1
### Instruction: on this hospital visit how many days has it been since patient 82132's last trazodone prescription? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 82132 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'trazodone' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: Percent of closed answered negative-scored questions over time. ### Response:
SELECT MAX(h.t), h.pc AS "Percent of closed answered negative-scored questions over time" FROM (SELECT q.t AS t, NTILE(100) OVER (ORDER BY q.t) AS pc FROM (SELECT ClosedDate - CreationDate AS t FROM Posts WHERE PostTypeId = 1 AND AnswerCount > 0 AND Score < 0 AND NOT ClosedDate IS NULL) AS q) AS h WHERE h.t <= '23:59:59' GROUP BY h.pc ORDER BY h.pc
### Instruction: Winforms View Counts by Date. ### Response:
SELECT TIME_TO_STR(CreationDate, '%d') AS "day", TIME_TO_STR(CreationDate, '%M') AS "month", TIME_TO_STR(CreationDate, '%Y') AS "year", SUM(ViewCount) AS "views" FROM Posts WHERE (STR_POSITION(Tags, '<winforms>') > 0) GROUP BY TIME_TO_STR(CreationDate, '%d'), TIME_TO_STR(CreationDate, '%M'), TIME_TO_STR(CreationDate, '%Y')
### Instruction: Search post based on tag and keyword with answers. Limited the results to the posts with check answer ### Response:
SELECT p.Id AS "post_link", p.Id, p.Title, p.CommentCount, p.Body, c.Text, p.ViewCount, a.Score FROM Posts AS p LEFT JOIN Comments AS c ON p.Id = c.PostId INNER JOIN Posts AS a ON a.ParentId = p.Id WHERE p.PostTypeId = 1 OR p.PostTypeId = 2 AND p.Tags = '%##tagname##%' AND p.Title LIKE '%##keyword##%' ORDER BY ViewCount DESC
### Instruction: Tag wiki editors who don't link to anything. ### Response:
SELECT e.LastEditorUserId AS "user_link", COUNT(*), MAX(e.Id) AS "post_link" FROM Tags AS t INNER JOIN Posts AS e ON e.Id = t.ExcerptPostId INNER JOIN Posts AS w ON w.Id = t.WikiPostId WHERE NOT w.Body LIKE '%href%' AND NOT e.Body LIKE '%href%' AND LENGTH(e.Body) > 2 AND LENGTH(w.Body) > 2 GROUP BY e.LastEditorUserId ORDER BY COUNT(*) DESC
### Instruction: Reputation per 1000 characters, for users > 2k.. ### Response:
SELECT u.DisplayName AS "user_link", COUNT(p.Id) AS "post_count", u.Reputation AS "user_reputation", u.Reputation * 1000 / SUM(LENGTH(p.Body)) AS "user_rpc1k" FROM Users AS U JOIN Posts AS p ON p.OwnerUserId = u.Id WHERE u.Reputation > 2000 GROUP BY u.DisplayName, u.Reputation ORDER BY 'user_rpc1k' DESC LIMIT 1000
### Instruction: what's the minimum cost of a hospital with temperature in 2105? ### 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 = 'temperature')) AND STRFTIME('%y', cost.chargetime) = '2105' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: List the medicine name and trade name which can both interact as 'inhibitor' and 'activitor' with enzymes. ### Response:
SELECT T1.name, T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'inhibitor' INTERSECT SELECT T1.name, T1.trade_name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id WHERE interaction_type = 'activitor'
### Instruction: had patient 006-36108 during a month before been allergic to any substance? ### Response:
SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-36108')) AND DATETIME(allergy.allergytime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: Name the professors who teach 560 other than Prof. Joseph Doman . ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 560 AND NOT instructor.name LIKE '%Joseph Doman%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: What class is the easiest that I can take to fulfill the MDE requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%MDE%' AND program_course.course_id = course.course_id AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 WHERE PROGRAM_COURSEalias1.category LIKE '%MDE%')
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, rank by the the average of department id from high to low. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: what were the three most frequently taken lab tests in 2104 for patients 50s? ### Response:
SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND STRFTIME('%y', lab.labresulttime) = '2104' GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 3
### Instruction: has there been a microbiology test conducted since 75 months ago on patient 031-19622? ### Response:
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-19622')) AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-75 month')
### Instruction: Do good questions have question marks?. ### Response:
SELECT COUNT(*) AS "count", SUM(Score) AS "sum", SUM(FavoriteCount) AS FavoriteCount, CAST(SUM(Score) AS FLOAT) / COUNT(*) AS AverageScore, CAST(SUM(FavoriteCount) AS FLOAT) / COUNT(*) AS AverageFavoriteCount, CASE WHEN Body LIKE '%?%' OR Title LIKE '%?%' THEN 1 ELSE 0 END AS QuestionMark FROM Posts WHERE PostTypeId = 1 GROUP BY CASE WHEN Body LIKE '%?%' OR Title LIKE '%?%' THEN 1 ELSE 0 END
### Instruction: what was the name of the allergy that was patient 004-18459 had since 02/2105? ### Response:
SELECT allergy.allergyname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-18459')) AND STRFTIME('%y-%m', allergy.allergytime) >= '2105-02'
### Instruction: how many hours have passed since first hydroxyzine was prescribed to patient 14671 on the current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14671 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'hydroxyzine' ORDER BY prescriptions.startdate LIMIT 1