instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: how many hours has elapsed since the first time that patient 10855 dextrose 50% was prescribed during 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 = 10855 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'dextrose 50%' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Questions with tag1, without tag2, containing a specific phrase. ### Response:
SELECT q.Id AS "post_link", q.Tags, q.CreationDate, q.LastActivityDate FROM Posts AS q INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName = '##tag1:string?geometry##' AND NOT (q.Tags LIKE '%<##tag2?mg.metric-geometry##>%') AND (q.Body LIKE '%##text?volume##%' COLLATE Latin1_General_CI_AI) ORDER BY q.CreationDate DESC
### Instruction: How many courses for each course description? Show me a bar chart, and show in descending by the Y-axis. ### Response:
SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) 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 ORDER BY COUNT(CRS_DESCRIPTION) DESC
### Instruction: Do you know if 500 -level classes are being held in Spring or Summer term ? ### 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 500 AND 500 + 100 AND semester.semester IN ('SP', 'SS', 'SU') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: What are the drivers' first names,last names, and ids for all those that had more than 8 stops or participated in more than 5 races? ### Response:
SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN pitstops AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 8 UNION SELECT T1.forename, T1.surname, T1.driverid FROM drivers AS T1 JOIN results AS T2 ON T1.driverid = T2.driverid GROUP BY T1.driverid HAVING COUNT(*) > 5
### Instruction: patient 011-52460 underwent vte prophylaxis - compression stockings in other hospitals? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '011-52460' AND patient.hospitalid <> (SELECT DISTINCT patient.hospitalid FROM patient WHERE patient.uniquepid = '011-52460' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'vte prophylaxis - compression stockings'
### Instruction: how many times did patient 18866 make a or urine out on the current icu visit? ### Response:
SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 18866) AND icustays.outtime IS NULL) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'or urine' AND d_items.linksto = 'outputevents')
### Instruction: thanks comments on accepted answers. ### Response:
SELECT Id AS "comment_link" FROM Comments WHERE (Text LIKE '%thank you%' COLLATE SQL_Latin1_General_CP1_CI_AS OR Text LIKE '%thanks%' COLLATE SQL_Latin1_General_CP1_CI_AS OR Text LIKE '%gracias%' COLLATE SQL_Latin1_General_CP1_CI_AS OR Text LIKE '%edit%' COLLATE SQL_Latin1_General_CP1_CI_AS) AND LENGTH(Text) <= 20 AND EXISTS(SELECT * FROM Votes WHERE PostId = Comments.PostId)
### Instruction: count the number of times that patient 006-133605 has received a methemoglobin lab test since 4 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 = '006-133605')) AND lab.labname = 'methemoglobin' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-4 year')
### Instruction: Is it true that Prof. Messer is the only person who teaches A History of the Economy ? ### 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 '%A History of the Economy%' AND NOT instructor.name LIKE '%Messer%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: when was patient 88659 first tested for microbiology in 09/last year? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 88659) AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '09' ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: what is the number of patients whose admission location is transfer from hosp/extram and primary disease is neoplasm of uncertain behavior of other lymphatic and hematopoietic tissues\bone marrow transplant? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT"
### Instruction: How many upper-level 1 -credit courses will there be in this Spring for ELI ? ### Response:
SELECT COUNT(DISTINCT course.course_id) FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.credits = 1 AND course.department = 'ELI' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Do we have morning classes for NERS 211 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course_offering.start_time < '12:00:00' AND course_offering.start_time >= '08:00:00' AND course.course_id = course_offering.course_id AND course.department = 'NERS' AND course.number = 211 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what is the drug that patient 033-12085 was prescribed two or more times? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-12085')) GROUP BY medication.drugname) AS t1 WHERE t1.c1 >= 2
### Instruction: For BIOPHYS 995 , what are the prerequisites ? ### 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 = 'BIOPHYS' AND COURSE_0.number = 995
### Instruction: when was the last time that patient 013-33898's respiration was measured or taken on the current icu 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 = '013-33898') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.respiration IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: GitHub users who have answered at least one question. ### Response:
WITH GitHubUsers AS (SELECT u.Id, COUNT(a.Id) AS answersCount, SUM(a.Score) AS answersScore FROM Users AS u LEFT JOIN Posts AS a ON a.PostTypeId = 2 AND a.OwnerUserId = u.Id WHERE u.WebsiteUrl LIKE '%github%' GROUP BY u.Id) SELECT u.Id, u.WebsiteUrl, u.UpVotes, u.Reputation, u.AboutMe, g.answersCount, g.answersScore FROM GitHubUsers AS g JOIN Users AS u ON u.Id = g.Id WHERE answersCount >= 1
### Instruction: Number of questions asked for a specific tag over time (absolute). ### Response:
SELECT TIME_TO_STR(CreationDate, '%y') * 100 + TIME_TO_STR(CreationDate, '%M') AS yyyymm, COUNT(*) AS cnt FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName = 'c++' GROUP BY TIME_TO_STR(CreationDate, '%y') * 100 + TIME_TO_STR(CreationDate, '%M') ORDER BY 1, 2
### Instruction: what was the drug name of the drug that was last prescribed to patient 97734 in 09/this year? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97734) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '09' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: when was patient 14110's last incision of mediastinum treatment? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'incision of mediastinum') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14110) ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: what is the daily average amount of ph patient 58928 has in their last hospital visit? ### Response:
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 58928 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ph') GROUP BY STRFTIME('%y-%m-%d', labevents.charttime)
### Instruction: what is the number of patients diagnosed with lack of coordination until 2102? ### 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 = 'lack of coordination') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2102')
### Instruction: Most popular questions per tag in a year. ### Response:
SELECT p.Id, p.Body, p.CreationDate, p.Score, p.ParentId, p.Title, p.Tags, p.ViewCount, p.AnswerCount, p.FavoriteCount, p.CommentCount, p.AcceptedAnswerId FROM Posts AS p LEFT JOIN PostTags AS pt ON p.Id = pt.PostId LEFT JOIN Tags AS t ON pt.TagId = t.Id WHERE t.TagName = '##TagName:string##' AND YEAR(p.CreationDate) = 2019 AND p.DeletionDate IS NULL ORDER BY Score DESC
### Instruction: What is the average Total Freshwater Withdrawal (km 3 /yr), when Industrial Use (m 3 /p/yr)(in %) is 337(63%), and when Per Capita Withdrawal (m 3 /p/yr) is greater than 535? ### Response:
SELECT AVG(total_freshwater_withdrawal__km_3__yr_) FROM table_name_5 WHERE industrial_use__m_3__p_yr__in__percentage_ = "337(63%)" AND per_capita_withdrawal__m_3__p_yr_ > 535
### Instruction: what is the last total co2 value for patient 030-41709 during their first hospital encounter? ### Response:
SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-41709' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'total co2' ORDER BY lab.labresulttime DESC LIMIT 1
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of hire_date and the sum of manager_id bin hire_date by time, and order by the total number in desc. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(MANAGER_ID) DESC
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, draw a bar chart about the distribution of hire_date and the sum of department_id bin hire_date by time, and order Y from low to high order please. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(DEPARTMENT_ID)
### Instruction: what is the dose of sodium bicarbonate that is first prescribed to patient 10811 since 05/2103? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10811) AND prescriptions.drug = 'sodium bicarbonate' AND STRFTIME('%y-%m', prescriptions.startdate) >= '2103-05' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: What are all the employee ids and the names of the countries in which they work Visualize by bar chart, and show total number in ascending order. ### Response:
SELECT COUNTRY_NAME, SUM(EMPLOYEE_ID) FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID JOIN locations AS T3 ON T2.LOCATION_ID = T3.LOCATION_ID JOIN countries AS T4 ON T3.COUNTRY_ID = T4.COUNTRY_ID GROUP BY COUNTRY_NAME ORDER BY SUM(EMPLOYEE_ID)
### Instruction: What courses are available for me to participate in once I finish AUTO 563 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.pre_course_id WHERE COURSE_1.department = 'AUTO' AND COURSE_1.number = 563
### Instruction: when was the first time patient 009-5001 was prescribed drugs via intravenou in their current hospital visit? ### Response:
SELECT medication.drugstarttime FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'intravenou' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: does patient 031-1337 have any organisms that were found in his last sputum, expectorated microbiology test? ### 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-1337')) AND microlab.culturesite = 'sputum, expectorated' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: what is the hospitals minimum cost that involves a procedure called a fiber-optic bronchoscopy? ### Response:
SELECT MIN(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 = 'fiber-optic bronchoscopy')) GROUP BY cost.hadm_id) AS t1
### Instruction: what was the last value of an chloride lab test in patient 84346 until 51 months ago? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 84346) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'chloride') AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-51 month') ORDER BY labevents.charttime DESC LIMIT 1
### Instruction: what is the drug that patient 30789 was prescribed two times in 01/2104? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 30789) AND STRFTIME('%y-%m', prescriptions.startdate) = '2104-01' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: what is patient 53176's average value for bilirubin, total, body fluid since 2 months ago? ### Response:
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 53176) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'bilirubin, total, body fluid') AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-2 month')
### Instruction: A stacked bar chart showing the number of faults for different fault short name and skills required to fix them The x-axis is falut short name and group by skill description, and sort y axis in desc order. ### Response:
SELECT fault_short_name, COUNT(fault_short_name) FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY skill_description, fault_short_name ORDER BY COUNT(fault_short_name) DESC
### Instruction: What are the upper-level elective options for the Spring and Summer ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course.course_id WHERE course.department = 'EECS' AND program_course.category LIKE '%ULCS%' AND semester.semester IN ('SP', 'SS', 'SU') AND semester.year = 2016
### Instruction: Find lone answers to questions asked by users with low reputation. ### Response:
SELECT p.CreationDate, p.Id AS "post_link", a.Id AS "post_link" FROM Posts AS p JOIN Posts AS a ON p.Id = a.ParentId JOIN Users AS u ON p.OwnerUserId = u.Id JOIN Users AS au ON a.OwnerUserId = au.Id WHERE a.PostTypeId = 2 AND p.AnswerCount = 1 AND p.AcceptedAnswerId IS NULL AND u.Reputation <= '##MaxRep##' AND a.OwnerUserId = '##UserId##' ORDER BY p.CreationDate DESC
### Instruction: until 2103, how many patients had been diagnosed with diplopia? ### 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 = 'diplopia') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2103')
### Instruction: Find 'me too' (so-called) answers. Finds the answers to questions that appear to be the 'me too' style of answers that contribute absolutely nothiing to the question and should either be removed or converted to a comment by a mod. ### Response:
SELECT Id AS "post_link", SUBSTRING(Body, STR_POSITION(Body, 'me too') - 15, 45) AS "occurrence" FROM Posts WHERE PostTypeId = 2 AND (Body LIKE 'me too%' OR Body LIKE '% me too%') AND NOT Body LIKE '%affects me too%' AND NOT Body LIKE '%fixed it%' AND NOT Body LIKE '%resolved%'
### Instruction: Number of questions asked over time for a particular topic (tag). ### Response:
SELECT DATEADD(month, DATEDIFF(month, 0, CreationDate), 0) AS "month", COUNT(q.Id) AS NumQuests FROM Posts AS q INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE q.PostTypeId = 1 AND q.CreationDate >= '2016-01-01 00:00:00' GROUP BY DATEDIFF(month, 0, CreationDate), t.TagName ORDER BY NumQuests DESC
### Instruction: since 04/2104 patient 013-33898 had been prescribed labetalol? ### 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 = '013-33898')) AND medication.drugname = 'labetalol' AND STRFTIME('%y-%m', medication.drugstarttime) >= '2104-04'
### Instruction: Show the number of students who are living in a dorm with a TV Lounge and group by first name in a bar chart, and rank in ascending by the Y-axis. ### Response:
SELECT Fname, COUNT(Fname) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM Has_amenity AS T3 JOIN Dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge') GROUP BY Fname ORDER BY COUNT(Fname)
### Instruction: when did the first time during the first hospital visit patient 033-4763 received a bun lab test? ### 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 = '033-4763' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'bun' ORDER BY lab.labresulttime LIMIT 1
### Instruction: tell me what the total output amt-jackson pratt drain output of patient 006-99708 is. ### Response:
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-99708')) AND intakeoutput.celllabel = 'output amt-jackson pratt drain' AND intakeoutput.cellpath LIKE '%output%'
### Instruction: what is the average total cost of a hospital which involves the spontaneous rate since 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 lab.patientunitstayid FROM lab WHERE lab.labname = 'spontaneous rate')) AND STRFTIME('%y', cost.chargetime) >= '2105' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: Which Pocona Municipality (%) is the lowest one that has a Puerto Villarroel Municipality (%) smaller than 14.6, and a Chimor Municipality (%) of 5.1, and an Entre R os Municipality (%) smaller than 0.9? ### Response:
SELECT MIN(pocona_municipality___percentage_) FROM table_name_61 WHERE puerto_villarroel_municipality___percentage_ < 14.6 AND chimoré_municipality___percentage_ = 5.1 AND entre_ríos_municipality___percentage_ < 0.9
### Instruction: Questions Count with Tag by Month. ### Response:
SELECT date1, COUNT(DISTINCT Id) FROM (SELECT DISTINCT TIME_TO_STR(d.CreationDate, '%Y-%m') AS "date1", (d.Id) AS id, d.Body, Score, AnswerCount, CommentCount, FavoriteCount FROM Posts AS d WHERE d.PostTypeId = 1 AND d.CreationDate >= '2019-01-01' AND d.CreationDate <= '2020-11-01' AND d.Tags LIKE '%kotlin%') AS z GROUP BY date1 ORDER BY date1
### Instruction: has patient 030-42006 ever undergone a hypotonic fluid administration - d5 half-normal saline during this hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-42006' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'hypotonic fluid administration - d5 half-normal saline'
### Instruction: My Answers to Negatively Scored Questions. ### Response:
SELECT P.Id AS "post_link", (SELECT P2.Score FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "question_score", (SELECT P2.ClosedDate FROM Posts AS P2 WHERE P2.Id = P.ParentId) AS "question_closed_date" FROM Posts AS P WHERE P.ParentId IN (SELECT Id FROM Posts AS P2 WHERE P2.PostTypeId = 1 AND P2.Score < 0) AND P.PostTypeId = 2 AND P.OwnerUserId = '##userid##'
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the sum of manager_id over the hire_date bin hire_date by time, and sort in descending by the total number. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(MANAGER_ID) DESC
### Instruction: what was the name of the drug prescribed to patient 22756, two times until 17 months ago? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22756) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-17 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### 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 job_id and the sum of salary , and group by attribute job_id, list Y-axis from low to high order. ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(SALARY)
### Instruction: Find all movies featuring ' Benedict Cumberbatch ' and ' Keira Knightley ### Response:
SELECT movie.title FROM actor AS ACTOR_0, actor AS ACTOR_1, cast AS CAST_0, cast AS CAST_1, movie WHERE ACTOR_0.name = 'Benedict Cumberbatch' AND ACTOR_1.name = 'Keira Knightley' AND CAST_0.aid = ACTOR_0.aid AND CAST_1.aid = ACTOR_1.aid AND movie.mid = CAST_0.msid AND movie.mid = CAST_1.msid
### Instruction: what was the name of the drug that patient 6440 had been prescribed for two times since 58 months ago? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6440) AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-58 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: since 106 months ago, what was the minimum tibc value for patient 027-135249? ### Response:
SELECT MIN(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-135249')) AND lab.labname = 'tibc' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-106 month')
### Instruction: give me the total amount of output of patient 028-42654 on the last icu visit. ### 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 = '028-42654') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND intakeoutput.cellpath LIKE '%output%'
### Instruction: what was the 'output' patient 013-38992 got on the current intensive care unit visit for the first time? ### 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 = '013-38992') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%output%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: patient 002-16314 had been prescribed 4 ml syringe : labetalol hcl 5 mg/ml iv soln? ### 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 = '002-16314')) AND medication.drugname = '4 ml syringe : labetalol hcl 5 mg/ml iv soln'
### Instruction: what is the number of patients whose diagnoses long title is diabetes with neurological manifestations, type i [juvenile type], not stated as uncontrolled and lab test fluid is blood? ### 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 = "Diabetes with neurological manifestations, type I [juvenile type], not stated as uncontrolled" AND lab.fluid = "Blood"
### Instruction: in this month, what was the first value of the po2 for patient 1561? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1561) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'po2') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.charttime LIMIT 1
### Instruction: tell me the first procedure patient 025-39356 had the previous year? ### 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 = '025-39356')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: provide the number of patients whose procedure long title is other closed [endoscopic] biopsy of biliary duct or sphincter of oddi and lab test category is chemistry? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE procedures.long_title = "Other closed [endoscopic] biopsy of biliary duct or sphincter of Oddi" AND lab."CATEGORY" = "Chemistry"
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of manager_id over the hire_date bin hire_date by time, show by the y-axis in asc. ### Response:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(MANAGER_ID)
### Instruction: what is a drug that patient 73075 was prescribed two times since 11/2100? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, COUNT(prescriptions.startdate) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73075) AND STRFTIME('%y-%m', prescriptions.startdate) >= '2100-11' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: List all the reviews by Michelle for Italian restaurant ### Response:
SELECT review.text FROM business, category AS CATEGORY_0, category AS CATEGORY_1, review, user WHERE CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'Italian' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'restaurant' AND review.business_id = business.business_id AND user.name = 'Michelle' AND user.user_id = review.user_id
### Instruction: During the Fall and Winter term , how many 500 level classes are offered ? ### Response:
SELECT COUNT(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 = 'department0' AND course.number BETWEEN 500 AND 500 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: when has patient 58730 first had the minimum value of hemoglobin during their last hospital visit? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 58730 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hemoglobin') ORDER BY labevents.valuenum, labevents.charttime LIMIT 1
### Instruction: what is the maximum total cost of the hospital, which includes the laboratory pressure control test until 2102? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'pressure control')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: what was the drug prescribed for patient 006-232560 for the first time on their last 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 = '006-232560' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY medication.drugstarttime LIMIT 1
### Instruction: During the Spring or Summer terms , are any 400 -level classes being offered ? ### 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 400 AND 400 + 100 AND semester.semester IN ('SP', 'SS', 'SU') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: How close is a site to awarding the Generalist Badge. There needs to be 200 questions on each of the top 40 tags for the badge to be awarded ### Response:
WITH topTags AS (SELECT t.TagId FROM PostTags AS t GROUP BY t.TagId ORDER BY COUNT(*) DESC LIMIT 40) SELECT t.TagName, COUNT(*) AS Count FROM Posts AS q JOIN PostTags AS pt ON q.Id = pt.PostId JOIN Tags AS t ON t.Id = pt.TagId WHERE pt.TagId IN (SELECT * FROM topTags) AND q.CommunityOwnedDate IS NULL GROUP BY t.TagName ORDER BY Count DESC
### Instruction: Recent comments by Mathematics moderators. ### Response:
SELECT u.Id AS "user_link", u.LastAccessDate, c.CreationDate, c.Id AS "comment_link" FROM Users AS u INNER JOIN Comments AS c ON c.UserId = u.Id WHERE u.Id IN (622, 9754, 12952, 13854, 21674, 23350, 44121, 59234, 83702, 85306) ORDER BY c.CreationDate DESC LIMIT 100
### Instruction: had there been any organism found in the last mrsa screen microbiology test of patient 6374 in the last hospital encounter? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6374 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND microbiologyevents.spec_type_desc = 'mrsa screen' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: has there been any microbiological test on the influenza a/b by dfa - bronch lavage of patient 11732 since 38 months ago? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11732) AND microbiologyevents.spec_type_desc = 'influenza a/b by dfa - bronch lavage' AND DATETIME(microbiologyevents.charttime) >= DATETIME(CURRENT_TIME(), '-38 month')
### Instruction: Unsung heroes with exactly 10 zero score accepted answers. ### Response:
SELECT u.Id FROM Users AS u JOIN Badges AS b ON u.Id = b.UserId JOIN (Posts AS q INNER JOIN Posts AS a ON a.Id = q.AcceptedAnswerId) ON u.Id = a.OwnerUserId WHERE b.Name = 'Unsung Hero' AND q.OwnerUserId != a.OwnerUserId AND a.PostTypeId = 2 AND b.Date > a.CreationDate GROUP BY (u.Id) HAVING SUM(CASE WHEN a.Score = 0 THEN 1 ELSE 0 END) = 10
### Instruction: what was the name of the organism at the last sputum test of patient 26886 on the first hospital encounter? ### Response:
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26886 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND microbiologyevents.spec_type_desc = 'sputum' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: how many times did patient 028-23341 produce a urinary catheter output: indwelling/continuous ure 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 = '028-23341')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'urinary catheter output: indwelling/continuous ure'
### Instruction: what was the first procedure time of the revision of pedicle grft of patient 2004? ### Response:
SELECT procedures_icd.charttime 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 pedicle grft') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2004) ORDER BY procedures_icd.charttime LIMIT 1
### Instruction: Q's with no A's >= 0 after three months. Finds number of questions that have no accepted answer and no answers with a score >= 0 after three months ### Response:
SELECT COUNT(*), MIN(CreationDate), MAX(CreationDate), COUNT(DISTINCT OwnerUserId) FROM Posts AS q WHERE PostTypeId = 1 AND Score < 1 AND CreationDate < DATEADD(MONTH, -3, GETDATE()) AND ClosedDate IS NULL AND AcceptedAnswerId IS NULL AND NOT EXISTS(SELECT * FROM Posts AS a WHERE PostTypeId = 2 AND ParentId = q.Id AND Score >= 0)
### Instruction: what are the four most frequently performed procedures for patients of the 50s in 2100? ### 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 STRFTIME('%y', treatment.treatmenttime) = '2100' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4
### Instruction: what is the name of the medication that was first prescribed to patient 12775 in 12/this year? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '12' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: what did patient 95280 have first as the output on the first icu visit? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 95280) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) ORDER BY outputevents.charttime LIMIT 1)
### Instruction: when did patient 49176 receive an mcv laboratory test for the first time since 01/2105? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mcv') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49176) AND STRFTIME('%y-%m', labevents.charttime) >= '2105-01' ORDER BY labevents.charttime LIMIT 1
### Instruction: what is the minimum hospital cost when it involves lung abscess in 2100? ### 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 = 'lung abscess')) AND STRFTIME('%y', cost.chargetime) = '2100' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: how many times are the magnesium tests given to patient 006-21143 during the last year? ### 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-21143')) AND lab.labname = 'magnesium' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, draw a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, and display by the bar in asc. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: Questions (possibly) with MathJax in the title. ### Response:
SELECT p.Id AS "post_link", p.Score AS "Score", p.Tags AS "Tags", LENGTH(p.Title) - LENGTH(REPLACE(p.Title, '$', '')) AS "$ Count" FROM Posts AS p WHERE p.PostTypeId = 1 AND LENGTH(p.Title) - LENGTH(REPLACE(p.Title, '$', '')) >= 1 ORDER BY LENGTH(p.Title) - LENGTH(REPLACE(p.Title, '$', '')) DESC
### Instruction: The course prerequisites for PHYSED 425 are ? ### 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 = 'PHYSED' AND COURSE_0.number = 425
### Instruction: in the previous month when did patient 51177 last receive the ptt test? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ptt') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 51177) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY labevents.charttime DESC LIMIT 1
### Instruction: what is the minimum respiration of patient 006-153042 on the first icu visit? ### Response:
SELECT MIN(vitalperiodic.respiration) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-153042') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.respiration IS NULL
### Instruction: what is the highest ANSI code with a latitude more than 47.623288 and a geo id more than 3805508060 with land (sqmi) more than 35.66 and a longitude less than -102.054248 ### Response:
SELECT MAX(ansi_code) FROM table_name_98 WHERE latitude > 47.623288 AND geo_id > 3805508060 AND land___sqmi__ > 35.66 AND longitude < -102.054248
### Instruction: Can the 300 -level classes be taken in the Spring or Summer term ? ### 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 ('SP', 'SS', 'SU') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: last time patient 018-20179 was diagnosed with coagulopathy - heparin administration? ### Response:
SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '018-20179')) AND diagnosis.diagnosisname = 'coagulopathy - heparin administration' ORDER BY diagnosis.diagnosistime DESC LIMIT 1
### Instruction: Kindly give me a list of the upper level ALA classes offered this Spring-Summer . ### 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 = 'ALA' 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: count the number of patients that have had a intraaortic balloon pump removal procedure two or more times since 2103. ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'intraaortic balloon pump removal' AND STRFTIME('%y', treatment.treatmenttime) >= '2103') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 >= 2
### Instruction: Which upper-level electives are offered in the Spring and Summer ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester INNER JOIN program_course ON program_course.course_id = course.course_id WHERE course.department = 'EECS' AND program_course.category LIKE '%ULCS%' AND semester.semester IN ('SP', 'SS', 'SU') AND semester.year = 2016
### Instruction: what was the name of the lab test that in 11/2104 patient 004-54892 received for the first time? ### 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 = '004-54892')) AND STRFTIME('%y-%m', lab.labresulttime) = '2104-11' ORDER BY lab.labresulttime LIMIT 1