instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: how many patients of american indian/alaska native ethnicity are diagnosed with hypertensive chronic kidney disease, unspecified, with chronic kidney disease stage i through stage iv or unspecified? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND diagnoses.long_title = "Hypertensive chronic kidney disease, unspecified, with chronic kidney disease stage I through stage IV, or unspecified"
### Instruction: what is the name of the drug that has been prescribed two times since 02/2102 to patient 7476? ### 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 = 7476) AND STRFTIME('%y-%m', prescriptions.startdate) >= '2102-02' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: when has patient 2002 first had an intake since 08/01/2101? ### Response:
SELECT inputevents_cv.charttime FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2002)) AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) >= '2101-08-01' ORDER BY inputevents_cv.charttime LIMIT 1
### Instruction: what is during this month minimum urinary specific gravity value of patient 030-28944? ### 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 = '030-28944')) AND lab.labname = 'urinary specific gravity' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: Do I need to take EMBA 640 to take EMBA 604 ? ### Response:
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_0.department = 'EMBA' AND COURSE_0.number = 640 AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'EMBA' AND COURSE_1.number = 604
### Instruction: what were the five most frequently prescribed drugs for patients aged 50s since 2100? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 50 AND 59) AND STRFTIME('%y', medication.drugstarttime) >= '2100' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### Instruction: In Spring or Summer , what courses offered meet the PreMajor requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester 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_offering.course_id WHERE program_course.category LIKE '%PreMajor%' AND semester.semester IN ('SP', 'SS', 'SU') AND semester.year = 2016
### Instruction: what was the last value on the pt lab test of patient 14054 in the previous month? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14054) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'pt') AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY labevents.charttime DESC LIMIT 1
### Instruction: had patient 22449 had any intake of tpn d12.5? ### Response:
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22449)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d12.5' AND d_items.linksto = 'inputevents_cv')
### Instruction: Is there another teacher of Honors Colloquium , Junior aside from Prof. Sundaram ? ### 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 '%Honors Colloquium , Junior%' AND NOT instructor.name LIKE '%Sundaram%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: what was the total output of patient 85895 on last month/02? ### Response:
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 85895)) AND DATETIME(outputevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', outputevents.charttime) = '02'
### Instruction: Find posts in last 60 days with 'coreclr' in title, body or tags. ### Response:
SELECT Posts.Id AS "post_link", Title, Posts.CreationDate, PostTypeId, AnswerCount, Tags, ViewCount, Score, OwnerUserId AS "user_link", DisplayName, LastActivityDate, LastEditDate, ClosedDate, Body FROM Posts, Users WHERE Posts.OwnerUserId = Users.Id AND Posts.CreationDate >= CURRENT_TIMESTAMP() - 60 AND (Title LIKE '%coreclr%' OR Body LIKE '%coreclr%' OR Tags LIKE '%<coreclr>%')
### Instruction: Answer score badge acquisition for users with just one Nice-and-Great answer. ### Response:
SELECT U.Id AS "user_link" FROM Users AS U INNER JOIN Posts AS A ON A.OwnerUserId = U.Id INNER JOIN PostTags AS PT ON PT.PostId = A.Id INNER JOIN Tags AS T ON T.Id = PT.TagId INNER JOIN (SELECT OwnerUserId, MAX(Score) AS MaxScore FROM Posts WHERE PostTypeId = 2 AND Score >= 10 GROUP BY OwnerUserId) AS AC ON AC.OwnerUserId = U.Id WHERE T.TagName = '##TagName?haskell##'
### 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 amount of job_id over the job_id , and group by attribute job_id, and sort by the y axis in desc. ### Response:
SELECT JOB_ID, COUNT(JOB_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY COUNT(JOB_ID) DESC
### Instruction: what was the minimum value of patient 030-44598's sodium this month? ### 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 = '030-44598')) AND lab.labname = 'sodium' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: tell me the number of times patient 006-2586 had a continuous infusion meds intake on the current intensive care unit visit? ### 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 = '006-2586') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'continuous infusion meds'
### Instruction: Show the number of courses for each course description in a stacked bar chart. The x-axis is course description and group by instructor's first name. ### 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 EMP_FNAME, CRS_DESCRIPTION
### Instruction: had patient 035-6788 been prescribed regular insulin, acetaminophen 325 mg po tabs, or glucose? ### 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 = '035-6788')) AND medication.drugname IN ('acetaminophen 325 mg po tabs', 'regular insulin', 'glucose')
### Instruction: Who is the usual teacher for ARTDES 301 ? ### Response:
SELECT COUNT(instructor.name), instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'ARTDES' AND course.number = 301 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id GROUP BY instructor.name ORDER BY COUNT(instructor.name) DESC LIMIT 5
### Instruction: when did patient 62983 get the oxygen saturation lab test last time until 26 months ago? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'oxygen saturation') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 62983) AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-26 month') ORDER BY labevents.charttime DESC LIMIT 1
### Instruction: what were the four most commonly prescribed drugs for patients 20s since 2100? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND STRFTIME('%y', medication.drugstarttime) >= '2100' GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 4
### Instruction: Recent Python Posts by Score. ### Response:
SELECT p.Title, p.Body, p.CreationDate, p.Id AS "post_link", p.Tags, p.Score, u.AboutMe FROM Posts AS p LEFT JOIN Users AS u ON p.OwnerUserId = u.Id WHERE p.PostTypeId IN (1) AND p.CreationDate > '2020-01-01' AND p.CreationDate < '2020-12-31' AND p.Tags LIKE ('%python%') AND p.Score >= 15 AND u.AboutMe != '' ORDER BY p.CreationDate DESC
### Instruction: what was the first procedure time of nephrology consultation for patient 015-59552 on their current hospital encounter? ### 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 = '015-59552' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'nephrology consultation' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what is the total cost of a minimum hospital with a drug called propofol 1000 mg/100 ml? ### 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 medication.patientunitstayid FROM medication WHERE medication.drugname = 'propofol 1000 mg/100 ml')) GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: tag answerer greater than score. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY SUM(a.Score) DESC) AS Pos, a.OwnerUserId AS UserId, SUM(a.Score) AS Score FROM Posts AS a, Posts AS q INNER JOIN PostTags AS qt ON q.Id = qt.PostId INNER JOIN Tags AS t ON t.Id = qt.TagId WHERE a.ParentId = q.Id AND a.PostTypeId = 2 AND a.CommunityOwnedDate IS NULL AND t.TagName LIKE @TagName GROUP BY a.OwnerUserId HAVING SUM(a.Score) >= @MinimumScore
### Instruction: what procedure did patient 017-74343 the previous year receive for the first 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 = '017-74343')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: Accepted Answer Rate for Users > 3000 rep. ### Response:
SELECT (CAST(COUNT(a.Id) AS FLOAT) / (SELECT COUNT(p.Id) FROM Posts AS p INNER JOIN Users AS u ON p.OwnerUserId = u.Id WHERE u.Reputation > 3000 AND PostTypeId = 2) * 100) AS AcceptedPercentage FROM Posts AS q INNER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id INNER JOIN Users AS u ON a.OwnerUserId = u.Id WHERE u.Reputation > 100 AND a.PostTypeId = 2
### Instruction: the first intake that patient 006-202970 had on the current icu visit what is the name of it? ### 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 = '006-202970') AND patient.unitdischargetime IS NULL) AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: Probable tag creations for a specific user. ### Response:
SELECT p.Id AS "post_link", t.TagName FROM (SELECT pt.TagId, MIN(p.CreationDate) AS CreationDate FROM PostTags AS pt INNER JOIN Posts AS p ON p.Id = pt.PostId GROUP BY pt.TagId) AS temp INNER JOIN PostTags AS pt ON pt.TagId = temp.TagId INNER JOIN Posts AS p ON p.Id = pt.PostId AND p.CreationDate = temp.CreationDate INNER JOIN Tags AS t ON temp.TagId = t.Id WHERE p.OwnerUserId = '##UserId:int##'
### Instruction: Total Posts by Database Server Per Month - Oracle. ### Response:
SELECT CONCAT(YEAR(P.CreationDate), '-', MONTH(P.CreationDate)) AS YearMonth, 'Oracle' AS TagName, COUNT(*) AS PostCount FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE T.TagName LIKE 'oracle%' GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY YEAR(P.CreationDate) DESC, MONTH(P.CreationDate) 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, show me about the distribution of hire_date and the sum of department_id bin hire_date by time in a bar chart, order from low to high by the Y. ### 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: Is there anything for which MEDCHEM 660 is an enforced prerequisite ? ### Response:
SELECT DISTINCT COURSE_1.department, COURSE_1.name, COURSE_1.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_0.department = 'MEDCHEM' AND COURSE_0.number = 660 AND COURSE_1.course_id = course_prerequisite.course_id
### Instruction: whats the name of the organism found in the last blood, venipuncture microbiology test of patient 031-4987. ### Response:
SELECT microlab.organism FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4987')) AND microlab.culturesite = 'blood, venipuncture' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: was there any calcium gluconate or lisinopril or iso-osmotic dextrose ordered until 4 years ago for patient 41132? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 41132) AND prescriptions.drug IN ('calcium gluconate', 'lisinopril', 'iso-osmotic dextrose') AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-4 year')
### Instruction: how much is the minimum cost of a hospital that involves vitamin b12 in 2102? ### 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 = 'vitamin b12')) AND STRFTIME('%y', cost.chargetime) = '2102' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: the last month, what was the maximum lactate value for patient 005-77687? ### Response:
SELECT MAX(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 = '005-77687')) AND lab.labname = 'lactate' AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: Ratio of number of high rep users to users that have accepted answers. ### Response:
WITH UsersWITHAcceptedAnswers AS (SELECT u.Reputation FROM Posts AS p INNER JOIN Posts AS aa ON aa.Id = p.AcceptedAnswerId INNER JOIN Users AS u ON u.Id = aa.OwnerUserId WHERE p.PostTypeId = 1 AND aa.PostTypeId = 2 GROUP BY u.Id, u.Reputation) SELECT SUM(CASE WHEN Reputation > '##threshold:int?100000##' THEN 1 ELSE 0 END) / (1.0 * COUNT(*)) FROM UsersWITHAcceptedAnswers
### Instruction: No Answer, No Comment, No Duplicate, No Merge. Posts with No Answer, No Comment, No Duplicate ### Response:
SELECT p.Id AS "post_link", p.Score, p.ViewCount, p.CommentCount, p.CreationDate, p.Tags FROM Posts AS p WHERE AnswerCount = 0 AND CommentCount = 0 AND p.ClosedDate IS NULL AND p.Id NOT IN (SELECT PostId FROM PostHistory WHERE (PostHistoryTypeId = 10 AND Comment IN (1)) OR PostHistoryTypeId IN (17, 18, 35, 37, 38)) ORDER BY p.CreationDate
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of job_id and the amount of job_id , and group by attribute job_id, and sort JOB_ID in ascending order. ### Response:
SELECT JOB_ID, COUNT(JOB_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: Are there morning class offerings for EHS 500 ? ### 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 = 'EHS' AND course.number = 500 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: when did patient 017-20711 get prescribed for the last time since 80 months ago? ### 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 = '017-20711')) AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-80 month') ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: how many patients received a annuloplasty two times? ### Response:
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, COUNT(*) AS c1 FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'annuloplasty') GROUP BY admissions.subject_id) AS t1 WHERE t1.c1 = 2
### Instruction: has patient 015-15167 undergone until 3 years ago a tracheal suctioning procedure? ### Response:
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-15167')) AND treatment.treatmentname = 'tracheal suctioning' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: did patient 002-16314 go in for a vitamin b12 lab test until 11/2100? ### 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 = '002-16314')) AND lab.labname = 'vitamin b12' AND STRFTIME('%y-%m', lab.labresulttime) <= '2100-11'
### 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 salary over the job_id , and group by attribute job_id, and show y axis from high to low order. ### Response:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(SALARY) DESC
### Instruction: what's patient 6536's minimum value of atypical lymphocytes since 02/2103? ### Response:
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6536) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'atypical lymphocytes') AND STRFTIME('%y-%m', labevents.charttime) >= '2103-02'
### Instruction: what are the top five most common surgeries of patients of age 30s 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 BETWEEN 30 AND 39) AND STRFTIME('%y', treatment.treatmenttime) = '2101' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 5
### Instruction: 5 answers containing inline `code` markup. ### Response:
SELECT * FROM Posts WHERE PostTypeId = 2 AND (Body LIKE '%`_`%' OR Body LIKE '%`__`%' OR Body LIKE '%`___`%' OR Body LIKE '%`____`%' OR Body LIKE '%`_____`%') AND (LEFT(Body, 50) LIKE '%`_`%' OR LEFT(Body, 50) LIKE '%`__`%' OR LEFT(Body, 50) LIKE '%`___`%' OR LEFT(Body, 50) LIKE '%`____`%' OR LEFT(Body, 50) LIKE '%`_____`%') LIMIT 5
### Instruction: What is the smallest ANSI code for adler township when Longitude is more than -101.333926, GEO ID is less than 3806700900, and Land ( sqmi ) is more than 35.84? ### Response:
SELECT MIN("ANSI code") FROM table_64732 WHERE "Longitude" > '-101.333926' AND "GEO ID" < '3806700900' AND "Township" = 'adler' AND "Land ( sqmi )" > '35.84'
### Instruction: calculate the number of people who have had procedure-one vessel since 6 years ago. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'procedure-one vessel') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year'))
### Instruction: what was the name of the drug, which patient 54281 had been prescribed two or more times until 8 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 = 54281) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-8 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 >= 2
### Instruction: what was the last value of anion gap of patient 013-12480 on the first hospital visit? ### 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 = '013-12480' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'anion gap' ORDER BY lab.labresulttime DESC LIMIT 1
### Instruction: who is the the voice actor (englbeingh 1998 / pioneer) with voice actor (englbeingh 1997 / saban) being alec willows and voice actor (englbeingh 2006 / funimation) being andy mcavin ### Response:
SELECT "Voice Actor (English 1998 / Pioneer)" FROM table_19130 WHERE "Voice Actor (English 1997 / Saban)" = 'Alec Willows' AND "Voice Actor (English 2006 / FUNimation)" = 'Andy McAvin'
### Instruction: All questions closed as 'Not A Real Question' - Potential Clunkers. ### Response:
SELECT p.Id AS "post_link", p.CreationDate, ph.CreationDate AS ClosureDate, p.Score, p.ViewCount FROM Posts AS p LEFT JOIN PostHistory AS ph ON ph.PostId = p.Id LEFT JOIN PostHistoryTypes AS pht ON ph.PostHistoryTypeId = pht.Id WHERE ph.PostHistoryTypeId = 10 AND ph.Comment = (SELECT Id FROM CloseReasonTypes WHERE Name = 'not a real question') AND NOT p.ClosedDate IS NULL ORDER BY p.ViewCount LIMIT 1000
### Instruction: what was the name of procedure, that patient 032-4849 was first received this 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 = '032-4849')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: Time to vote CDF for answers. ### Response:
SELECT MAX(h.t) AS "time", h.pm AS "Permille of total votes (all types) on answers over time" FROM (SELECT q.t AS t, NTILE(1000) OVER (ORDER BY q.t) AS pm FROM (SELECT pf.CreationDate - p.CreationDate AS t FROM Posts AS p JOIN PostFeedback AS pf ON p.Id = pf.PostId WHERE p.PostTypeId = 2) AS q) AS h WHERE h.t <= '23:59:59' GROUP BY h.pm ORDER BY h.pm
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, could you rank bars in descending order? ### 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 DESC
### Instruction: monthly questions nodejs, angularjs, & reactjs. ### Response:
SELECT *, COUNT(*) FROM (SELECT CAST(CAST(TIME_TO_STR(CreationDate, '%Y') AS TEXT) + '-' + CAST(TIME_TO_STR(CreationDate, '%m') AS TEXT) + '-01' AS DATETIME) AS Month, t.TagName FROM Posts AS p JOIN PostTags AS pt ON pt.PostId = p.Id JOIN Tags AS t ON t.Id = pt.TagId WHERE TagName IN ('node.js', 'angularjs', 'reactjs')) AS X GROUP BY TagName, Month ORDER BY Month DESC, TagName
### Instruction: This Fall , how many upper-level 8 -credit ASIAN classes are offered ? ### 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 = 8 AND course.department = 'ASIAN' 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: be currently taking any of the following medications: systemic ( oral or injectable ) glucocorticoids; interferon _ alpha; anti _ cd20 antibody ( e.g., rituximab ) ; or anti _ ctla _ 4 antibody ( e.g., ipilimumab ) . ### Response:
SELECT * FROM table_train_133 WHERE glucocorticoids = 1 OR interferon_alpha = 1 OR anti_cd20_antibody = 1 OR rituximab = 1 OR anti_ctla_4_antibody = 1 OR ipilimumab = 1
### Instruction: User-Tag Answer Stats Over Time. ### Response:
SELECT COUNT(DISTINCT Answers.Id) AS Answers, COUNT(DISTINCT Votes.BountyAmount) AS Votes FROM Posts AS Answers INNER JOIN Posts AS Questions ON (Answers.ParentId = Questions.Id) INNER JOIN PostTags ON (Questions.Id = PostTags.PostId) INNER JOIN Tags ON (PostTags.TagId = Tags.Id) INNER JOIN Votes ON (Answers.Id = Votes.PostId) WHERE Answers.CreationDate >= @MinDate AND Answers.CreationDate <= @MaxDate AND Tags.TagName = @Tag
### 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 job_id , and group by attribute job_id, and rank in asc by the X-axis please. ### Response:
SELECT JOB_ID, AVG(MANAGER_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: count the number of times that until 122 months ago patient 48709 had been prescribed lidocaine 2%/epi 1:100,000. ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 48709) AND prescriptions.drug = 'lidocaine 2%/epi 1:100,000' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-122 month')
### 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 average of employee_id , and group by attribute job_id, and sort bar in asc order. ### Response:
SELECT JOB_ID, AVG(EMPLOYEE_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: in a month before has loperamide, phenylephrine hcl or fentanyl patch been prescribed to patient 73713? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713) AND prescriptions.drug IN ('loperamide', 'phenylephrine hcl', 'fentanyl patch') AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: when has patient 94293 received a prescription for magnesium sulfate replacement (oncology) last until 01/2105? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 94293) AND prescriptions.drug = 'magnesium sulfate replacement (oncology)' AND STRFTIME('%y-%m', prescriptions.startdate) <= '2105-01' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what was the average value of patient 027-185580's triglycerides in the first hospital visit? ### Response:
SELECT AVG(lab.labresult) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-185580' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'triglycerides'
### Instruction: how many patients whose diagnoses long title is nonspecific elevation of levels of transaminase or lactic acid dehydrogenase [ldh] and lab test category is hematology? ### 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 = "Nonspecific elevation of levels of transaminase or lactic acid dehydrogenase [LDH]" AND lab."CATEGORY" = "Hematology"
### Instruction: what is the daily average of the weight of patient 016-38131 this month? ### Response:
SELECT AVG(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-38131') AND NOT patient.admissionweight IS NULL AND DATETIME(patient.unitadmittime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY STRFTIME('%y-%m-%d', patient.unitadmittime)
### Instruction: when was the first time that patient 031-1337 received a sputum, expectorated microbiology test? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-1337')) AND microlab.culturesite = 'sputum, expectorated' ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: what is the one thing patient 006-81423 was diagnosed with until 2104 for the first time? ### Response:
SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-81423')) AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104' ORDER BY diagnosis.diagnosistime LIMIT 1
### Instruction: tell me the maximum cost of a hospital if theophylline is involved until 2 years ago? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'theophylline')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: had a microbiology test been done in 2105 on the abscess of patient 025-28600? ### Response:
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-28600')) AND microlab.culturesite = 'abscess' AND STRFTIME('%y', microlab.culturetakentime) = '2105'
### Instruction: how many patients aged below 55 had closed fracture of skull's base with subarachnoid, subdural & extradural hemorrhage, and loss of consciousness for unspecified duration? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "55" AND diagnoses.long_title = "Closed fracture of base of skull with subarachnoid, subdural, and extradural hemorrhage, with loss of consciousness of unspecified duration"
### Instruction: when was the first blood culture - neonate microbiology test done for patient 72107 until 01/2104? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72107) AND microbiologyevents.spec_type_desc = 'blood culture - neonate' AND STRFTIME('%y-%m', microbiologyevents.charttime) <= '2104-01' ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: For before noon classes , what upper level electives are offered ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course_offering.end_time <= '12:00:00' AND course.course_id = course_offering.course_id AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what is the average total cost of a hospital that includes mpv laboratory tests since 2 years ago? ### 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 = 'mpv')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: give me the number of patients whose primary disease is neoplasm of uncertain behavior of other lymphatic and hematopoietic tissues\bone marrow transplant and year of death is less than or equal to 2112? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT" AND demographic.dod_year <= "2112.0"
### Instruction: Top Frontend Developers in Warsaw, Poland. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Users.Id AS "user_link", Reputation, Badges.Name AS Badge, Badges.Class AS Class, Location FROM Users, Badges WHERE Users.Id = Badges.UserId AND Badges.TagBased = 1 AND Badges.Name IN ('angular', 'reactjs', 'frontend', 'vuejs', 'aurelia', 'ember.js', 'html', 'html5') AND LOWER(Users.Location) LIKE LOWER('%Warsaw%') ORDER BY Reputation DESC
### Instruction: when was patient 016-38131 prescribed medications through the iv push route for the last time in the current hospital encounter? ### 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 = '016-38131' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'iv push' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: what is the minimum daily number of patients who suffer from bone fracture(s) - sternum in this year? ### Response:
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'bone fracture(s) - sternum' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY STRFTIME('%y-%m-%d', diagnosis.diagnosistime)) AS t1
### Instruction: What are the ids of the problems reported before the date of any problem reported by Lysanne Turcotte? ### Response:
SELECT T1.problem_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE date_problem_reported < (SELECT MIN(date_problem_reported) FROM problems AS T3 JOIN staff AS T4 ON T3.reported_by_staff_id = T4.staff_id WHERE T4.staff_first_name = "Lysanne" AND T4.staff_last_name = "Turcotte")
### Instruction: when was patient 031-3355 first other microbiologic test on this hospital encounter? ### Response:
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355' AND patient.hospitaldischargetime IS NULL)) AND microlab.culturesite = 'other' ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: Which upper-level ASIANLAN classes are being listed for the upcoming Fall semester ? ### 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 = 'ASIANLAN' 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: Analyse Number of Users Joining SO Over Time, Per Month and Year. ### Response:
SELECT COUNT(*) AS "Number of Users", TIME_TO_STR('creationdate', '%-mONT%-H') AS "Month", TIME_TO_STR('creationdate', '%YEAR') AS "Year" FROM Users GROUP BY TIME_TO_STR('creationdate', '%YEAR'), TIME_TO_STR('creationdate', '%-mONT%-H') ORDER BY TIME_TO_STR('creationdate', '%YEAR'), TIME_TO_STR('creationdate', '%-mONT%-H')
### 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 salary over the job_id , and group by attribute job_id, and show by the y-axis in descending. ### 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) DESC
### Instruction: Is IOE 441 available as a morning class ? ### 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 = 'IOE' AND course.number = 441 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: when was the first time that patient 5828 was tested for neutrophils during this month? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'neutrophils') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 5828) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.charttime LIMIT 1
### Instruction: what is the average cost in a hospital involving a laboratory test for mcv during the previous year? ### Response:
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mcv')) AND DATETIME(cost.chargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY cost.hadm_id) AS t1
### Instruction: what was the last time of patient 70709 catheter tip-iv microbiology test since 142 months ago? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 70709) AND microbiologyevents.spec_type_desc = 'catheter tip-iv' AND DATETIME(microbiologyevents.charttime) >= DATETIME(CURRENT_TIME(), '-142 month') ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: Count of questions with kotlin tag over time. ### Response:
SELECT DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0) AS "month", COUNT(DISTINCT Posts.Id) AS Count FROM Posts INNER JOIN PostTags ON PostTags.PostId = Posts.Id INNER JOIN Tags ON PostTags.TagId = Tags.Id WHERE Tags.TagName LIKE '%pelican%' AND PostTypeId = 1 AND CreationDate > '2012-01-01' GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0) ORDER BY 'month' DESC
### Instruction: how many times patient 28443 has had blood out lab output 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 = 28443) AND icustays.outtime IS NULL) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'blood out lab' AND d_items.linksto = 'outputevents')
### Instruction: Show me a bar chart for what are all the employee ids and the names of the countries in which they work?, and I want to order by the bars from low to high. ### 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 COUNTRY_NAME
### 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, and order by the JOB_ID from low to high. ### 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 JOB_ID
### Instruction: hmm.. what was patient 97733's last mchc since 12/2105? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97733) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mchc') AND STRFTIME('%y-%m', labevents.charttime) >= '2105-12' ORDER BY labevents.charttime DESC LIMIT 1
### Instruction: what was the drug that until 11/2104 patient 88573 had been prescribed two times? ### 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 = 88573) AND STRFTIME('%y-%m', prescriptions.startdate) <= '2104-11' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: tell me the first value of reticulocyte count, automated in patient 13806 in the last hospital visit? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13806 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 = 'reticulocyte count, automated') ORDER BY labevents.charttime LIMIT 1
### Instruction: Count of users by posts. ### Response:
WITH Raw AS (SELECT PostTypeId, OwnerUserId AS UserId, COUNT(*) AS PostCount FROM Posts WHERE PostTypeId <= 2 GROUP BY PostTypeId, OwnerUserId), Raw2 AS (SELECT PostTypeId, PostCount, COUNT(*) AS UserCount FROM Raw GROUP BY PostTypeId, PostCount) SELECT Raw2.PostCount, PostTypes.Name, Raw2.UserCount FROM Raw2, PostTypes WHERE Raw2.PostTypeId = PostTypes.Id AND Raw2.PostCount < '##MaxPostCount:int?30##' ORDER BY Raw2.PostCount, Raw2.PostTypeId
### Instruction: count the number of times patient 004-34394 had cultures - surgical specimen procedures during the last hospital encounter. ### Response:
SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-34394' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND treatment.treatmentname = 'cultures - surgical specimen'
### Instruction: has since 29 months ago cepacol (menthol), azithromycin or metoprolol tartrate been prescribed to patient 43959? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 43959) AND prescriptions.drug IN ('cepacol (menthol)', 'azithromycin', 'metoprolol tartrate') AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-29 month')