instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### 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 average of salary , and group by attribute job_id, and could you display by the y axis in ascending? ### 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)
### Instruction: how much is the minimum total cost of a hospital that involves a drug called albumin human in 2104? ### 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 = 'albumin human')) AND STRFTIME('%y', cost.chargetime) = '2104' GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: what was the name of the drug that was last prescribed to patient 022-6959 in the current hospital visit via the infiltration route? ### 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 = '022-6959' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'infiltration' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: Any morning classes for ARMENIAN 171 ? ### 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 = 'ARMENIAN' AND course.number = 171 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: when patient 031-3507 received a microbiology test for the last time on their first 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-3507' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: Number of Later Posts Per User by First Tag. ### Response:
WITH FirstQuestionTags AS (SELECT p.OwnerUserId, p.ClosedDate, pt.TagId, RANK() OVER (PARTITION BY p.OwnerUserId ORDER BY p.Id) AS "rank" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id), FirstTagMatches AS (SELECT ft.OwnerUserId, ft.ClosedDate FROM FirstQuestionTags AS ft INNER JOIN Tags AS t ON t.Id = ft.TagId WHERE ft.Rank = 1 AND t.TagName LIKE '##TagName:string##' + '%') SELECT * FROM FirstTagMatches
### Instruction: when did patient 006-172277 get prescribed a drug via transdermal for the last time on 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 = '006-172277' AND patient.hospitaldischargetime IS NULL)) AND medication.routeadmin = 'transdermal' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: [points]+ rep users posted a [reaction] received answer during [last N months]. ### Response:
SELECT CAST(Posts.CreationDate AS DATE) AS PostDate, COUNT(DISTINCT Users.Id) AS UserCount FROM Users LEFT JOIN Posts ON Users.Id = Posts.OwnerUserId WHERE Users.Reputation >= 1e4 AND Users.LastAccessDate >= DATEADD(year, -1, GETDATE()) AND Posts.CreationDate >= DATEADD(year, -1, GETDATE()) AND Posts.PostTypeId = 2 AND Posts.Score >= 0 GROUP BY CAST(Posts.CreationDate AS DATE) ORDER BY PostDate
### Instruction: what is the name of the drug patient 002-67875 was first prescribed since 168 months ago? ### 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 = '002-67875')) AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-168 month') ORDER BY medication.drugstarttime LIMIT 1
### Instruction: what's the minimum cost of a hospital that includes a cortisol lab test until 4 years ago? ### 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 = 'cortisol')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: has patient 027-136480 had in 2105 been diagnosed with diaphragmatic injury? ### Response:
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-136480')) AND diagnosis.diagnosisname = 'diaphragmatic injury' AND STRFTIME('%y', diagnosis.diagnosistime) = '2105'
### Instruction: SO - Total Posts by Database Server Per Month - MySQL. ### Response:
SELECT CONCAT(YEAR(P.CreationDate), '-', MONTH(P.CreationDate)) AS YearMonth, 'MySQL' 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 'mysql%' GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY YEAR(P.CreationDate) DESC, MONTH(P.CreationDate) DESC
### Instruction: What classes can serve as MDE next semester ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category LIKE '%MDE%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: How many papers has Noah Smith co-authored since 2009 ? ### Response:
SELECT DISTINCT COUNT(DISTINCT writes.paperid) FROM author, paper, writes WHERE author.authorname <> 'Noah Smith' AND paper.year > 2009 AND writes.authorid = author.authorid AND writes.paperid = paper.paperid AND writes.paperid IN (SELECT WRITESalias1.paperid FROM author AS AUTHORalias1, writes AS WRITESalias1 WHERE AUTHORalias1.authorname LIKE 'Noah Smith' AND WRITESalias1.authorid = AUTHORalias1.authorid)
### Instruction: what was the drug that patient 21110 had been prescribed two times a month before. ### 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 = 21110) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 = 2
### Instruction: when did patient 009-4569 last have minimum hgb until 16 months ago? ### 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 = '009-4569')) AND lab.labname = 'hgb' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-16 month') ORDER BY lab.labresult, lab.labresulttime DESC LIMIT 1
### Instruction: Number of questions with at least N answers by day. ### Response:
SELECT DATE(STR(YEAR(q.CreationDate)) + '-' + STR(MONTH(q.CreationDate)) + '-' + STR(DAY(q.CreationDate))) AS FullDate, CAST(COUNT(*) AS FLOAT) AS "#Questions" FROM Posts AS q WHERE q.PostTypeId = 1 AND q.AnswerCount >= '##minAnswers##' GROUP BY STR(YEAR(q.CreationDate)) + '-' + STR(MONTH(q.CreationDate)) + '-' + STR(DAY(q.CreationDate)) ORDER BY FullDate DESC
### Instruction: how many hours has passed since the last sodium polystyrene sulfonate prescription of patient 99647 in this 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 = 99647 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'sodium polystyrene sulfonate' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what was the first value of the pao2 lab test of patient 004-32407 on their 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 = '004-32407' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'pao2' ORDER BY lab.labresulttime LIMIT 1
### Instruction: Selecting closed opinion-based questions on SO. ### Response:
SELECT p.Id AS "post_link", p.Score FROM Posts AS p INNER JOIN PostHistory AS ph ON ph.PostId = p.Id INNER JOIN CloseReasonTypes AS crt ON crt.Id = CAST(ph.Comment AS INT) INNER JOIN PostTags ON PostTags.PostId = p.Id INNER JOIN Tags ON PostTags.TagId = Tags.Id WHERE Tags.TagName IN ('elm') AND ph.PostHistoryTypeId = 10 AND NOT p.ClosedDate IS NULL AND p.PostTypeId = 1 AND crt.Id IN (105) ORDER BY p.Score DESC
### Instruction: Number of answers per question within a certain number of days. ### Response:
SELECT DATEADD(DAY, 0, (DATEDIFF(DAY, 0, CreationDate) / @periodNDays * @periodNDays)) AS "Date", SUM(1) FROM Posts AS a INNER JOIN Posts AS q ON q.Id = a.ParentId WHERE a.PostTypeId = 2 AND q.PostTypeId = 1 AND DATEDIFF(day, q.CreationDate, CreationDate) < @maxDaysToAnswer GROUP BY (DATEDIFF(DAY, 0, CreationDate) / @periodNDays * @periodNDays) ORDER BY 'Date' DESC
### Instruction: Are there MDE or PreMajor course offered in the Spring ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.category FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category IN ('MDE', 'PreMajor') AND program_course.course_id = course.course_id AND semester.semester = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
### Instruction: until 3 years ago, patient 030-52395 underwent a suprapubic catheter? ### 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-52395')) AND treatment.treatmentname = 'suprapubic catheter' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: what was the maximum daily number of patients diagnosed with acetaminophen overdose - dosage unknown in this year? ### Response:
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'acetaminophen overdose - dosage unknown' 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: did patient 31482 receive a diagnostic for urinostomy status nec on their current hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'urinostomy status nec') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31482 AND admissions.dischtime IS NULL)
### Instruction: Downvote -> comment -> edit -> upvote. ### Response:
SELECT COUNT(DISTINCT down.PostId) FROM Votes AS down JOIN Comments ON down.PostId = Comments.PostId AND Comments.CreationDate > down.CreationDate JOIN PostHistory ON down.PostId = PostHistory.PostId AND PostHistory.CreationDate > Comments.CreationDate JOIN Votes AS up ON up.PostId = down.PostId AND up.CreationDate > PostHistory.CreationDate WHERE up.VoteTypeId = 2 AND down.VoteTypeId = 3 AND PostHistory.PostHistoryTypeId IN (4, 5, 6)
### Instruction: return me the authors who have cooperated with ' H. V. Jagadish ' or ' Divesh Srivastava ' . ### Response:
SELECT AUTHOR_0.name FROM author AS AUTHOR_0, author AS AUTHOR_1, organization AS ORGANIZATION_0, organization AS ORGANIZATION_1 WHERE (AUTHOR_1.name = 'H. V. Jagadish' OR AUTHOR_1.name = 'Divesh Srivastava') AND ORGANIZATION_0.oid = AUTHOR_0.oid AND ORGANIZATION_0.oid = AUTHOR_1.oid
### Instruction: Max score by post type. ### Response:
SELECT x.Id, x.DisplayName, x.PostTypeId, x.Score FROM (SELECT u.Id, u.DisplayName, p.PostTypeId, MAX(CAST(Score AS FLOAT)) AS score, ROW_NUMBER() OVER (PARTITION BY u.Id, p.PostTypeId ORDER BY MAX(CAST(Score AS FLOAT)) DESC) AS rn FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id GROUP BY u.Id, u.DisplayName, p.PostTypeId) AS x WHERE x.rn = 1 ORDER BY x.Score DESC
### Instruction: WordPress Related Questions - 8 Months. ### Response:
SELECT DISTINCT p.Id AS "ID", p.CreationDate AS "Date", p.Tags AS "Tags" FROM Posts AS p WHERE p.CreationDate BETWEEN '2019-01-01' AND '2019-08-28' AND (p.Tags LIKE '%wordpress%' OR p.Tags LIKE 'yoast%' OR p.Tags LIKE '%woocommerce%' OR p.Tags LIKE 'buddypress%' OR p.Tags LIKE 'bbpress%' OR p.Tags LIKE 'contact-form-7%') ORDER BY p.CreationDate DESC
### Instruction: what was the name of the organism found in the last test of sputum, expectorated of patient 031-15417? ### 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-15417')) AND microlab.culturesite = 'sputum, expectorated' ORDER BY microlab.culturetakentime DESC LIMIT 1
### 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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: 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
### Instruction: How many 300 -level classes are being offered in Fall and Winter term ? ### 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 = 'EECS' AND course.number BETWEEN 300 AND 300 + 100 AND semester.semester IN ('FA', 'WN') AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what are the top four most common lab tests for patients aged 60 or above, in this year? ### Response:
SELECT t1.labname FROM (SELECT lab.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age >= 60) AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY lab.labname) AS t1 WHERE t1.c1 <= 4
### Instruction: what was patient 007-8066 diagnosed with the last time until 1 year ago? ### 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 = '007-8066')) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY diagnosis.diagnosistime DESC LIMIT 1
### Instruction: Can I take 611 and 539 as I need to leave for work at 5:00 everyday ? ### Response:
SELECT COUNT(*) = 0 FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE (course.number = 611 OR course.number = 539) AND course_offering.end_time > '17:00:00' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: In order to fulfill the PreMajor requirement which is the easiest class to take ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%PreMajor%' AND program_course.course_id = course.course_id AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 WHERE PROGRAM_COURSEalias1.category LIKE '%PreMajor%')
### Instruction: Can I leave at 5:00 P.M. every day if I take 370 and 489 ? ### Response:
SELECT COUNT(*) = 0 FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE (course.number = 370 OR course.number = 489) AND course_offering.end_time > '17:00:00' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: count the number of times that patient 70206 had received a alanine aminotransferase (alt) test in 2103? ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'alanine aminotransferase (alt)') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 70206) AND STRFTIME('%y', labevents.charttime) = '2103'
### Instruction: does respiration of patient 032-21820 be normal on the current hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-21820' AND patient.hospitaldischargetime IS NULL)) AND vitalperiodic.respiration BETWEEN respiration_lower AND respiration_upper AND NOT vitalperiodic.respiration IS NULL
### Instruction: give me patient 74523's yearly maximum pt until 4 years ago. ### Response:
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 74523) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'pt') AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY STRFTIME('%y', labevents.charttime)
### Instruction: has any famotidine been prescribed to patient 002-17195 in their first hospital encounter? ### 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-17195' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND medication.drugname = 'famotidine'
### Instruction: Longest gaps between answer posting and acceptance. ### Response:
SELECT V.PostId AS "post_link", V.CreationDate AS "accept_date", A.CreationDate AS "question_date", CAST((JULIANDAY(V.CreationDate) - JULIANDAY(A.CreationDate)) * 86400.0 AS INT) AS "difference" FROM Votes AS V INNER JOIN Posts AS A ON (V.PostId = A.Id AND A.PostTypeId = 2) WHERE V.VoteTypeId = 1 ORDER BY 'difference' DESC LIMIT 100
### Instruction: what dose of cyclosporine (neoral) modified was last prescribed to patient 16271 since 80 months ago? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16271) AND prescriptions.drug = 'cyclosporine (neoral) modified' AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-80 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what was the name of the lab test which patient 012-4131 last received the last month? ### Response:
SELECT lab.labname FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-4131')) AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresulttime DESC LIMIT 1