instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: calculate the number of patients who had received the reticulocyte count, manual laboratory test during this year. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'reticulocyte count, manual') AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year'))
### Instruction: tell me the number of times patient 13054 had received a ck-mb index lab test since 81 months ago. ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ck-mb index') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13054) AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-81 month')
### Instruction: What hardware courses in the Winter or Fall of 2002 are offered ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE area.area LIKE '%hardware%' AND semester.semester IN ('WN', 'FA') AND semester.year = 2002
### Instruction: how much does the average hospital bill include lipase, ascites until 2102? ### 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 = 'lipase, ascites')) AND STRFTIME('%y', cost.chargetime) <= '2102' GROUP BY cost.hadm_id) AS t1
### Instruction: when was patient 57023 last prescribed a medication via the po/ng route the previous month? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 57023) AND prescriptions.route = 'po/ng' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: how much does the cost of a cholelith w ac cholecyst diagnosis cost? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_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 = 'cholelith w ac cholecyst'))
### Instruction: What are the software courses that are offered for Fall or Winter 2012 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE area.area LIKE '%software%' AND semester.semester IN ('WN', 'FA') AND semester.year = 2012
### Instruction: Count questions not answered per tag count. ### Response:
SELECT x.total, COUNT(x.Id), CAST(COUNT(x.Id) AS FLOAT) / (SELECT COUNT(Q.Id) FROM Posts AS Q WHERE Q.AnswerCount = 0 AND Q.PostTypeId = 1) FROM (SELECT Q.Id, COUNT(PT.TagId) AS total FROM Posts AS Q INNER JOIN PostTags AS PT ON Q.Id = PT.PostId WHERE Q.AnswerCount = 0 AND Q.PostTypeId = 1 GROUP BY Q.Id) AS x GROUP BY x.total
### Instruction: Which courses besides 218 are available with Prof. Jorge Martinez ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.number <> 218 AND instructor.name LIKE '%Jorge Martinez%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: how many hours have it been since the last time that patient 17667 stayed in careunit micu during their current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17667 AND admissions.dischtime IS NULL) AND transfers.careunit = 'micu' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: Next semester , will there be an ORALBIOL 995 section not on Monday ? ### Response:
SELECT DISTINCT course_offering.section_number FROM course, course_offering, semester WHERE course_offering.monday = 'N' AND course.course_id = course_offering.course_id AND course.department = 'ORALBIOL' AND course.number = 995 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: Answers by User for given period. ### Response:
SELECT OwnerUserId, Users.DisplayName, Users.CreationDate, Users.LastAccessDate, COUNT(*) AS Answers FROM Posts INNER JOIN Users ON Posts.OwnerUserId = Users.Id WHERE PostTypeId = 2 AND Posts.CreationDate BETWEEN '2013-01-23' AND '2013-01-30' GROUP BY OwnerUserId, OwnerDisplayName, Users.Id, Users.DisplayName, Users.CreationDate, Users.LastAccessDate ORDER BY Answers DESC
### Instruction: Question count by the number of answers per question. ### Response:
SELECT q.Cnt AS AnswerCount, COUNT(*) AS QuestionCount, COUNT(*) * 100.0 / MIN(TotalQuestions) AS "Percent" FROM (SELECT (SELECT COUNT(*) FROM Posts AS a WHERE a.PostTypeId = 1) AS TotalQuestions, (SELECT COUNT(*) FROM Posts AS a WHERE a.ParentId = q.Id AND a.PostTypeId = 2) AS Cnt FROM Posts AS q WHERE q.PostTypeId = 1) AS q GROUP BY q.Cnt ORDER BY q.Cnt
### Instruction: what procedure did patient 017-30318 get for the first time since 2105? ### 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-30318')) AND STRFTIME('%y', treatment.treatmenttime) >= '2105' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what are the top three frequent input events the last year? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT inputevents_cv.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM inputevents_cv WHERE DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 3)
### Instruction: tell me the name of the last lab test that patient 31482 got since 04/2105? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31482) AND STRFTIME('%y-%m', labevents.charttime) >= '2105-04' ORDER BY labevents.charttime DESC LIMIT 1)
### Instruction: what is the names of the medications which patient 004-7984 was allergic to until 36 months ago? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-7984')) AND DATETIME(allergy.allergytime) <= DATETIME(CURRENT_TIME(), '-36 month')
### Instruction: patient 21074 has undergone a endo rem bronch devc/sub procedure? ### Response:
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'endo rem bronch devc/sub') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 21074)
### Instruction: Rank users by number of questions and give average vote N>10. ### Response:
SELECT * FROM (SELECT u.DisplayName AS UserName, COUNT(*) AS Nquestions, SUM(q.Score) AS TotalVotes, ROUND(SUM(q.Score) / (1.0 * COUNT(*)), 2) AS AverageVotes FROM Posts AS q INNER JOIN Users AS u ON q.OwnerUserId = u.Id WHERE q.PostTypeId = 1 GROUP BY u.DisplayName) AS a WHERE a.Nquestions > 10 ORDER BY a.AverageVotes DESC, a.Nquestions DESC
### Instruction: What classes are available to easily fulfill the ULCS requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%ULCS%' 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 '%ULCS%')
### Instruction: Question Closures by Vote Counts. ### Response:
SELECT ph.PostId AS "post_link", u.DisplayName AS CloseUser, COUNT(v.value) AS VoterCount FROM PostHistory AS ph JOIN Posts AS p ON p.Id = ph.PostId JOIN Users AS u ON u.Id = ph.UserId JOIN LATERAL OPENJSON(ph.Text, '$.Voters') AS v WHERE PostHistoryTypeId = 10 AND p.PostTypeId = 1 GROUP BY ph.PostId, ph.Text, ph.Comment, u.DisplayName LIMIT 10
### Instruction: Are there any HJCS 400 -level courses that are 9 credits ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE program_course.category LIKE '%ULCS%' AND semester.semester = 'FA' AND semester.year = 2016
### Instruction: Who from my location am I better than?. ### Response:
SELECT DENSE_RANK() OVER (ORDER BY U2.Reputation DESC) AS "Rank", U2.DisplayName AS "Display Name", U2.Reputation AS "Reputation", U2.Location AS "Location", U2.Age AS "Age" FROM Users AS U1 JOIN Users AS U2 ON U1.Location = U2.Location WHERE U1.DisplayName = 'Vijaykumar Hadalgi' AND U1.Reputation >= U2.Reputation ORDER BY U2.Reputation DESC, U2.Age
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the amount of hire_date bin hire_date by time in a bar chart, could you rank y axis from low to high order? ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COUNT(HIRE_DATE)
### Instruction: has patient 027-23129 been having any allergy a year before? ### Response:
SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-23129')) AND DATETIME(allergy.allergytime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, visualize a line chart about the change of employee_id over hire_date , display in desc by the x-axis. ### Response:
SELECT HIRE_DATE, EMPLOYEE_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY HIRE_DATE DESC
### Instruction: what was the name of the last test that patient 22983 recieved since 173 months ago? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22983) AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-173 month') ORDER BY labevents.charttime DESC LIMIT 1)
### Instruction: My score and number of non-CW answers per tag. ### Response:
SELECT t.TagName, SUM(a.Score) AS "total_score", COUNT(a.Id) AS "answer_count" FROM Posts AS a INNER JOIN Posts AS q ON q.Id = a.ParentId INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id WHERE (a.OwnerUserId = '##userid##') AND (a.CommunityOwnedDate IS NULL) GROUP BY t.TagName ORDER BY SUM(a.Score) DESC
### Instruction: what are the names of the medicines patient 005-76770 is allergic to during their last hospital visit? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-76770' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1))
### Instruction: Users with zero accept rate. Does not count self-answers. Shows users with at least @MinAnswers answers. ### Response:
SELECT u.Id AS "user_link", COUNT(*) AS NumQuestions, SUM(CASE WHEN NOT q.AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS NumAccepted, MIN(u.Reputation) AS Reputation FROM Posts AS q INNER JOIN Users AS u ON u.Id = q.OwnerUserId WHERE q.PostTypeId = 1 GROUP BY u.Id ORDER BY NumAccepted, NumQuestions DESC LIMIT 1000
### Instruction: Find answers with more score than the accepted answer. ### Response:
SELECT answer.Id AS "post_link", answer.Score AS "Score", acceptedAnswer.Score AS "Score Accepted" FROM Posts AS answer JOIN Posts AS question ON question.Id = answer.ParentId JOIN Posts AS acceptedAnswer ON acceptedAnswer.Id = question.AcceptedAnswerId WHERE NOT question.AcceptedAnswerId IS NULL AND answer.PostTypeId = 2 AND answer.OwnerUserId = '##UserId:int##' AND answer.Id != acceptedAnswer.Id AND answer.Score > acceptedAnswer.Score ORDER BY answer.Score DESC
### Instruction: how many patients are admitted before 2121 and diagnosed for personal history of transient ischemic attack (tia) and cerebral infarction without residual deficits? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2121" AND diagnoses.long_title = "Personal history of transient ischemic attack (TIA), and cerebral infarction without residual deficits"
### Instruction: when did patient 86786 last receive until 8 months ago a prescription for hydrochlorothiazide? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 86786) AND prescriptions.drug = 'hydrochlorothiazide' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-8 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: Is LHC 510 section 688 available in the Winter 2000 semester ? ### 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_offering.section_number = 688 AND course.department = 'LHC' AND course.number = 510 AND semester.semester = 'Winter' AND semester.year = 2000
### Instruction: what was the organism that was found in the last microbiology test of patient 24894's blood culture (post-mortem)? ### Response:
SELECT microbiologyevents.org_name FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 24894) AND microbiologyevents.spec_type_desc = 'blood culture (post-mortem)' AND NOT microbiologyevents.org_name IS NULL ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: Year-to-year ratio of single-word-requests questions. ### Response:
SELECT YEAR(p.CreationDate), SUM(CASE WHEN NOT t.Id IS NULL THEN 1 ELSE 0 END) / CAST(COUNT(p.Id) AS FLOAT) AS "ratio of id requests" FROM Posts AS p JOIN PostTags AS pt ON pt.PostId = p.Id LEFT OUTER JOIN Tags AS t ON t.Id = pt.TagId AND t.TagName = 'single-word-requests' WHERE p.PostTypeId = 1 GROUP BY YEAR(p.CreationDate)
### Instruction: Users with largest number of 'trackable' badges. ### Response:
SELECT u.Id AS "user_link", COUNT(DISTINCT b.Name) AS BadgeCount FROM Users AS u INNER JOIN Badges AS b ON b.UserId = u.Id WHERE b.Name IN ('Altruist', 'Benefactor', 'Curious', 'Inquisitive', 'Socratic', 'Investor', 'Explainer', 'Promoter', 'Scholar', 'Student', 'Explainer') GROUP BY u.Id ORDER BY COUNT(DISTINCT b.Name) DESC LIMIT 100
### Instruction: Are there any classes available next semester as MDE ? ### 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 program_course.category LIKE '%MDE%' AND program_course.course_id = course.course_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
### Instruction: Most answers in one day. ### Response:
SELECT u.Id, u.DisplayName, u.Location, u.Reputation, DATE(p.CreationDate) AS PostDate, COUNT(p.Id) AS Posts FROM Posts AS p, Users AS u WHERE p.OwnerUserId = u.Id AND p.PostTypeId = 2 GROUP BY DATE(p.CreationDate), u.Id, u.DisplayName, u.Location, u.Reputation HAVING COUNT(p.Id) > 20 ORDER BY COUNT(p.Id) DESC, u.Id LIMIT 500
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the sum of manager_id bin hire_date by time in a bar chart, and order by the y axis in ascending. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(MANAGER_ID)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find hire_date and the sum of department_id bin hire_date by weekday, and visualize them by a bar chart, and show Y in descending order. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(DEPARTMENT_ID) DESC
### Instruction: calculate the number of patients who had received the enteral feeds procedure two times since 4 years ago. ### 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 = 'enteral feeds' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-4 year')) GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 = 2
### Instruction: how many patients were prescribed the drug 2 ml vial : midazolam hcl 2 mg/2ml ij soln until 2102? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT medication.patientunitstayid FROM medication WHERE medication.drugname = '2 ml vial : midazolam hcl 2 mg/2ml ij soln' AND STRFTIME('%y', medication.drugstarttime) <= '2102')
### Instruction: tell me the last procedure patient 029-30149 had in 2105? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '029-30149')) AND STRFTIME('%y', treatment.treatmenttime) = '2105' ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: when patient 006-140729 first received a procedure in 2105? ### 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 = '006-140729')) AND STRFTIME('%y', treatment.treatmenttime) = '2105' ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: how many days has it been since the last time patient 72909 stayed during their current hospital visit in the careunit ccu? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72909 AND admissions.dischtime IS NULL) AND transfers.careunit = 'ccu' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: In next Winter season what are the MDE classes that are offered ? ### 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_offering.course_id WHERE program_course.category LIKE '%MDE%' AND semester.semester = 'Winter' AND semester.year = 2017
### Instruction: Is there a level 400 , 12 -credit SEAS course ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE program_course.category LIKE '%ULCS%' AND semester.semester = 'FA' AND semester.year = 2016
### Instruction: when did patient 003-83 first have a laboratory test until 04/2105? ### Response:
SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-83')) AND STRFTIME('%y-%m', lab.labresulttime) <= '2105-04' ORDER BY lab.labresulttime LIMIT 1
### Instruction: what are the lab tests that are the five most frequently given the previous year? ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 5)
### Instruction: How many accepts have I gotten in a day?. ### Response:
SELECT 'user_link', MAX(accepts) AS Highest_accepts_in_a_day FROM (SELECT Users.Id AS "user_link", Votes.CreationDate, COUNT(Votes.Id) AS accepts FROM Users INNER JOIN Posts ON Posts.OwnerUserId = Users.Id INNER JOIN Votes ON Posts.Id = Votes.PostId AND Votes.VoteTypeId = 1 GROUP BY Users.Id, Votes.CreationDate) AS sq GROUP BY 'user_link' ORDER BY 2 DESC
### Instruction: Of all the courses , has John Nanos ever taught CHE 485 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'CHE' AND course.number = 485 AND instructor.name LIKE '%John Nanos%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: how much is the cost of the cholelith w ac cholecyst diagnosing? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_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 = 'cholelith w ac cholecyst'))
### Instruction: how many days has elapsed since patient 12775 stayed in careunit micu for the first time in the on this hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775 AND admissions.dischtime IS NULL) AND transfers.careunit = 'micu' ORDER BY transfers.intime LIMIT 1
### Instruction: count the number of patients who have been on or colloid intake. ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT icustays.hadm_id FROM icustays WHERE icustays.icustay_id IN (SELECT inputevents_cv.icustay_id FROM inputevents_cv WHERE inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'or colloid' AND d_items.linksto = 'inputevents_cv')))
### Instruction: How many patients with acute myocardial infarction of inferolateral wall initial episode of care diagnoses had a hematology lab test category? ### 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 = "Acute myocardial infarction of inferolateral wall, initial episode of care" AND lab."CATEGORY" = "Hematology"
### Instruction: how many times does patient 99883 get a lactate test in this month. ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'lactate') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99883) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: Provide the number of patients diagnosed with osteoarthrosis where it was unspecified whether it was generalized or localized at the site who had abnormal lab test status. ### 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 = "Osteoarthrosis, unspecified whether generalized or localized, site unspecified" AND lab.flag = "abnormal"
### Instruction: a medication has been prescribed to patient 006-47576 in 12/2105? ### Response:
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-47576')) AND STRFTIME('%y-%m', medication.drugstarttime) = '2105-12'
### Instruction: what would be patient 032-32248's monthly minimum weight in 2105? ### Response:
SELECT MIN(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-32248') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y', patient.unitadmittime) = '2105' GROUP BY STRFTIME('%y-%m', patient.unitadmittime)
### Instruction: what test was given to patient 74624 for the first time this month. ### Response:
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 74624) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY labevents.charttime LIMIT 1)
### Instruction: how much is the maximum hospital bill that involves a lactate lab test since 2105? ### Response:
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'lactate')) AND STRFTIME('%y', cost.chargetime) >= '2105' GROUP BY cost.hadm_id) AS t1
### Instruction: Who instructs courses that satisfy a ULCS program necessity ? ### Response:
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN program_course ON program_course.course_id = course_offering.course_id INNER JOIN program ON program.program_id = program_course.program_id WHERE program.name LIKE '%ULCS%'
### Instruction: has there been any record of a microbiology test for patient 20603's sputum during this year? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20603) AND microbiologyevents.spec_type_desc = 'sputum' AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: During Spring semester what BA upper level classes are there ? ### 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 = 'BA' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Spring' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: what was the maximum monthly number of patients who were diagnosed with arrhythmia during this year? ### Response:
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'arrhythmia' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY STRFTIME('%y-%m', diagnosis.diagnosistime)) AS t1
### Instruction: what is the maximum number of yearly diagnosed cases of valve replacement >= 7 days - mitral since 6 years ago? ### Response:
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'valve replacement >= 7 days - mitral' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY STRFTIME('%y', diagnosis.diagnosistime)) AS t1
### Instruction: To whom do I answer on average?. ### Response:
SELECT COUNT(1) AS nbe_answers, Questions.OwnerUserId AS "user_link", AVG(Answers.Score) AS A_score, AVG(Questions.Score) AS Q_score FROM Posts AS Questions, Posts AS Answers WHERE Questions.PostTypeId = 1 AND Answers.PostTypeId = 2 AND Answers.ParentId = Questions.Id AND Answers.OwnerUserId = '##UserId1##' GROUP BY Questions.OwnerUserId ORDER BY nbe_answers DESC
### Instruction: how many times does patient 017-7283 get a mchc test during the last hospital visit? ### Response:
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-7283' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'mchc'
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the sum of manager_id over the job_id , and group by attribute job_id by a bar chart. ### Response:
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID
### Instruction: give me the number of patients who had excision or destruction of other lesion or tissue of heart, open approach procedure along with cerebrospinal fluid lab test. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE procedures.long_title = "Excision or destruction of other lesion or tissue of heart, open approach" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: what's the name of the drug that patient 7698 was last prescribed via po route during a month before? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7698) AND prescriptions.route = 'po' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, visualize a line chart about the change of employee_id over hire_date , rank by the X-axis in ascending. ### Response:
SELECT HIRE_DATE, EMPLOYEE_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY HIRE_DATE
### Instruction: whats the minimum sao2 on the current icu visit for patient 035-24054. ### Response:
SELECT MIN(vitalperiodic.sao2) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-24054') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.sao2 IS NULL
### Instruction: how many hours have passed since patient 15447 stayed in careunit tsicu for the first time on this hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15447 AND admissions.dischtime IS NULL) AND transfers.careunit = 'tsicu' ORDER BY transfers.intime LIMIT 1
### Instruction: how many days have it been since the last time that patient 73713 stayed on this hospital encounter in careunit sicu? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713 AND admissions.dischtime IS NULL) AND transfers.careunit = 'sicu' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: how many days have passed since the last time that patient 83182 stayed on their current hospital visit in the careunit csru? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83182 AND admissions.dischtime IS NULL) AND transfers.careunit = 'csru' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: Select titkes with Like and Not Like. ### Response:
SELECT P.Title FROM Posts AS P WHERE P.Tags LIKE '%android%' AND P.Tags LIKE '%uiautomator%' AND NOT P.Tags LIKE '%test%' AND NOT P.Tags LIKE '%android-testing%' AND NOT P.Tags LIKE '%robotium%' AND NOT P.Tags LIKE '%appium%' AND NOT P.Tags LIKE '%android-espresso%' AND NOT P.Tags LIKE '%android-emulator%' AND NOT P.Tags LIKE '%monkeyrunner%' AND NOT P.Tags LIKE '%androidviewclient%' ORDER BY P.Score DESC
### Instruction: provide the number of patients whose insurance is government and procedure long title is local excision of lesion or tissue of bone, scapula, clavicle, and thorax [ribs and sternum]? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Government" AND procedures.long_title = "Local excision of lesion or tissue of bone, scapula, clavicle, and thorax [ribs and sternum]"
### Instruction: Which class is the easiest to get the ULCS requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%ULCS%' 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 '%ULCS%')
### Instruction: did patient 40435 receive any white blood cells lab tests this month? ### Response:
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'white blood cells') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 40435) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: What's the ARWU ranking that has the int' student review of 144, a median rank of less than 10, and 2000 Singapore Asiaweek of none? ### Response:
SELECT "2010 ARWU Rankings" FROM table_50749 WHERE "2000 Singapore \u201cAsiaweek\u201d Rankings" = 'none' AND "Median ranks" < '10' AND "2009 QS Asian Rankings: Int\u2019l student review" = '144'
### Instruction: what would be patient 003-54468's daily maximum weight since 2102? ### Response:
SELECT MAX(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-54468') AND NOT patient.admissionweight IS NULL AND STRFTIME('%y', patient.unitadmittime) >= '2102' GROUP BY STRFTIME('%y-%m-%d', patient.unitadmittime)
### Instruction: Month history of completed review tasks by type. ### Response:
WITH Raw AS (SELECT ReviewTasks.Id, DATEFROMPARTS(TIME_TO_STR(ReviewTasks.CreationDate, '%Y'), TIME_TO_STR(ReviewTasks.CreationDate, '%M'), 1) AS Month, ReviewTaskTypes.Name AS ReviewType FROM ReviewTasks, ReviewTaskTypes WHERE ReviewTasks.ReviewTaskTypeId = ReviewTaskTypes.Id AND ReviewTasks.ReviewTaskStateId = 2) SELECT Month, ReviewType, COUNT(*) AS Count FROM Raw GROUP BY Month, ReviewType ORDER BY Month, ReviewType
### Instruction: what medical procedure did patient 025-39356 last receive in 2104? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-39356')) AND STRFTIME('%y', treatment.treatmenttime) = '2104' ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: What are the first names of all students who live in the dorm with the most amenities? ### Response:
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY COUNT(*) DESC LIMIT 1)
### Instruction: Time between first comment and question closure. ### Response:
SELECT Posts.Id AS "post_link", Users.Reputation, CAST((JULIANDAY(ClosedDate) - JULIANDAY(first_comment)) AS INT) AS time_between_comment_and_close_vote FROM Posts INNER JOIN (SELECT PostId, MIN(CreationDate) AS first_comment FROM Comments GROUP BY PostId) AS comment ON comment.PostId = Posts.Id INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE NOT Posts.ClosedDate IS NULL ORDER BY Reputation
### Instruction: fasting blood glucose 100 _ 125 mg / dl, or 2 _ hour post _ challenge capillary glucose 140 _ 199 mg / dl ### Response:
SELECT * FROM table_dev_32 WHERE fasting_blood_glucose_fbg >= 100 AND fasting_blood_glucose_fbg <= 125 OR (post_challenge_capillary_glucose >= 140 AND post_challenge_capillary_glucose <= 199)
### Instruction: count the number of patients on po/ng route of drug administration who have been diagnosed with methicillin susceptible pneumonia due to staphylococcus aureus. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Meth sus pneum d/t Staph" AND prescriptions.route = "PO/NG"
### Instruction: Has LACS 400 ever been taught by Serena Ng ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'LACS' AND course.number = 400 AND instructor.name LIKE '%Serena Ng%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: how many times do patient 378 get a anticardiolipin antibody igg test in the first hospital visit? ### Response:
SELECT COUNT(*) FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'anticardiolipin antibody igg') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 378 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1)
### Instruction: What is the easiest class I can take to get the Core requirement ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload, program_course.workload FROM course, program_course WHERE program_course.category LIKE '%Core%' 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 '%Core%')
### Instruction: tell me the name of the allergy patient 006-42293 has since 51 months ago? ### Response:
SELECT allergy.allergyname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-42293')) AND DATETIME(allergy.allergytime) >= DATETIME(CURRENT_TIME(), '-51 month')
### Instruction: how many days have passed since patient 20898 stayed in careunit csru for the last time during the current hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20898 AND admissions.dischtime IS NULL) AND transfers.careunit = 'csru' ORDER BY transfers.intime DESC LIMIT 1
### Instruction: In the Winter classes offered , what are ULCS classes ? ### 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_offering.course_id WHERE program_course.category LIKE '%ULCS%' AND semester.semester = 'Winter' AND semester.year = 2017
### Instruction: How much 0 100km/h, s has a Fuel of diesel, and a Torque of n m (lb ft) @1900 rpm, and an Engine ID code(s) of agr/alh? ### Response:
SELECT COUNT("0\u2013100km/h,s") FROM table_60126 WHERE "Fuel" = 'diesel' AND "Torque" = 'n·m (lb·ft) @1900 rpm' AND "Engine ID code(s)" = 'agr/alh'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of hire_date and the average of salary bin hire_date by time, I want to rank by the y-axis from low to high. ### Response:
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY AVG(SALARY)
### 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 average of employee_id bin hire_date by weekday in a bar chart. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: has patient 12797 received a diagnosis of congenital hydrocele? ### 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 = 'congenital hydrocele') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12797)
### Instruction: when was the first time, patient 62977 was prescribed 1/2 ns until 02/2105? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 62977) AND prescriptions.drug = '1/2 ns' AND STRFTIME('%y-%m', prescriptions.startdate) <= '2105-02' ORDER BY prescriptions.startdate LIMIT 1