instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### 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, find job_id and the average of department_id , and group by attribute job_id, and visualize them by a bar chart, could you rank in ascending by the names?
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID
|
### Instruction:
Suggested Edit Votes for a user on a day.
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY sev.Id) AS rn, UserId, CreationDate, SuggestedEditId, 'http://stackoverflow.com/suggested-edits/' + CAST(SuggestedEditId AS TEXT) AS "edit_link", vt.Name FROM SuggestedEditVotes AS sev INNER JOIN VoteTypes AS vt ON sev.VoteTypeId = vt.Id WHERE UserId = '##TheUserid:int##' AND DATE(CreationDate) = '##editday:string##' ORDER BY sev.Id
|
### Instruction:
SO - Total Posts by Could Service Providers Per Month - Azure.
### Response:
|
SELECT CONCAT(YEAR(P.CreationDate), '-', MONTH(P.CreationDate)) AS YearMonth, 'Azure' 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 '%azure%' GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY YEAR(P.CreationDate) DESC, MONTH(P.CreationDate) DESC
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, give me the comparison about the average of department_id over the job_id , and group by attribute job_id, and I want to sort in asc by the JOB_ID.
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY JOB_ID
|
### Instruction:
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:
show me the three most frequently prescribed drugs for patients 40s until 4 years ago?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 3
|
### 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:
Which instructors usually teach ASIANLAN 227 ?
### 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 = 'ASIANLAN' AND course.number = 227 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:
In the Winter semester , how many upper level UC class offerings will be 5 -credit classes ?
### Response:
|
SELECT COUNT(DISTINCT course.course_id) FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.credits = 5 AND course.department = 'UC' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
Can you tell me what the course prerequisites are for BIOMEDE 523 ?
### Response:
|
SELECT DISTINCT COURSE_1.department, COURSE_1.name, COURSE_1.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.pre_course_id WHERE COURSE_0.department = 'BIOMEDE' AND COURSE_0.number = 523
|
### 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:
find the top five most commonly prescribed drugs for patients 30s since 6 years ago?
### Response:
|
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
how many papers did nicola dell and Brian DeRenzi write together
### Response:
|
SELECT DISTINCT COUNT(1) FROM author AS AUTHOR_0, author AS AUTHOR_1, writes AS WRITES_0, writes AS WRITES_1 WHERE AUTHOR_0.authorname = 'nicola dell' AND AUTHOR_1.authorname = 'Brian DeRenzi' AND WRITES_0.authorid = AUTHOR_0.authorid AND WRITES_1.authorid = AUTHOR_1.authorid AND WRITES_1.paperid = WRITES_0.paperid
|
### Instruction:
what specimen tests did patient 031-16123 receive on the last hospital encounter for the first time?
### Response:
|
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-16123' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) ORDER BY microlab.culturetakentime 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:
what is the daily minimum value of patient 1902's phosphate since 2104?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1902) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') AND STRFTIME('%y', labevents.charttime) >= '2104' GROUP BY STRFTIME('%y-%m-%d', labevents.charttime)
|
### 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:
has any organism since 1 year ago been found in the last blood culture microbiology test of patient 83499?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83499) AND microbiologyevents.spec_type_desc = 'blood culture' AND NOT microbiologyevents.org_name IS NULL AND DATETIME(microbiologyevents.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY microbiologyevents.charttime 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, show me about the distribution of hire_date and the average of department_id bin hire_date by time in a bar chart, and rank in ascending by the Y.
### Response:
|
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(DEPARTMENT_ID)
|
### Instruction:
What is Industrial Use (m 3 /p/yr)(in %), when Total Freshwater Withdrawal (km 3/yr) is less than 82.75, and when Agricultural Use (m 3 /p/yr)(in %) is 1363(92%)?
### Response:
|
SELECT "Industrial Use (m 3 /p/yr)(in %)" FROM table_76025 WHERE "Total Freshwater Withdrawal (km 3 /yr)" < '82.75' AND "Agricultural Use (m 3 /p/yr)(in %)" = '1363(92%)'
|
### Instruction:
how many days has passed since patient 006-2586 had the last procedure in this hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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-2586' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
what was the name of the laboratory test that patient 025-53538 has received for the last time 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 = '025-53538')) AND DATETIME(lab.labresulttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
Typically who is the BUDDHST 512 teacher ?
### 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 = 'BUDDHST' AND course.number = 512 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:
what was the maximum daily number of patients diagnosed with hypotension / pressor dependent - r/o adrenal insufficiency since 2104?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'hypotension / pressor dependent - r/o adrenal insufficiency' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2104' GROUP BY STRFTIME('%y-%m-%d', diagnosis.diagnosistime)) AS t1
|
### Instruction:
What PreMajor or MDE courses are available in the Fall ?
### 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 ('PreMajor', 'MDE') AND program_course.course_id = course.course_id AND semester.semester = 'Fall' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
|
### Instruction:
Goulbourne teaches what upper level courses ?
### 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 offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE instructor.name LIKE '%Goulbourne%' AND program_course.category LIKE 'ULCS'
|
### Instruction:
Users from a given place ranked by Rep.
### Response:
|
SELECT U.Id AS "user_link", U.Location, U.Age, U.Reputation, SUM(U.Reputation) / P."number_of_posts" AS "average_reputation_per_post" FROM Users AS U JOIN (SELECT OwnerUserId, COUNT(*) AS "number_of_posts" FROM Posts GROUP BY OwnerUserId) AS P ON U.Id = P.OwnerUserId WHERE U.Location LIKE '%##Location##' GROUP BY U.Id, U.Location, U.Age, U.Reputation, P."number_of_posts" ORDER BY U.Reputation DESC
|
### Instruction:
when did patient 015-96048 first take his/her enteral novosource renal?
### Response:
|
SELECT intakeoutput.intakeoutputtime FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-96048')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral novosource renal' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
List of all moderator election nominations, network-wide.
### Response:
|
WITH Raw AS (SELECT LAG(CreationDate) OVER (ORDER BY CreationDate) AS PrevCrDate, Id, CreationDate FROM Posts WHERE PostTypeId = 6) SELECT SUM(CASE WHEN PrevCrDate IS NULL OR DATEDIFF(day, PrevCrDate, CreationDate) > 30 THEN 1 ELSE 0 END) OVER (ORDER BY CreationDate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS ElectionId, Raw.Id AS PostId, CreationDate FROM Raw ORDER BY CreationDate
|
### Instruction:
what is the name of the diagnostic that patient 005-40894 first was received 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 = '005-40894')) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY diagnosis.diagnosistime LIMIT 1
|
### Instruction:
increased risk of bleeding ( platelet count < 80000 ; inr > 1.5 ) , other chronic hemostasis disorders, or treatment with chronic anticoagulant therapy ( i.e., heparin or warfarin ) .
### Response:
|
SELECT * FROM table_dev_18 WHERE bleeding = 1 OR (platelet_count < 80000 OR inr > 1.5) OR chronic_hemostasis_disorders = 1 OR chronic_anticoagulant_therapy = 1 OR (heparin = 1 OR chronic_warfarin_therapy = 1)
|
### Instruction:
what was the last procedure time patient 035-14278 has had during a year before?
### 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 = '035-14278')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY treatment.treatmenttime DESC LIMIT 1
|
### Instruction:
what is the three most common procedures for patients who are 20s since 5 years ago?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 20 AND 29) AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-5 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
i was wondering what patient 031-23724's maximum value of systemicmean on the first icu visit was?
### Response:
|
SELECT MAX(vitalperiodic.systemicmean) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23724') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND NOT vitalperiodic.systemicmean IS NULL
|
### Instruction:
tell me the first time patient 13528 took a microbiology test in 12/last year?
### Response:
|
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13528) AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '12' ORDER BY microbiologyevents.charttime LIMIT 1
|
### Instruction:
what is the minimum value of ionized calcium of patient 006-251537 in 06/2104?
### 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 = '006-251537')) AND lab.labname = 'ionized calcium' AND STRFTIME('%y-%m', lab.labresulttime) = '2104-06'
|
### Instruction:
Percentage of unanswered questions by tag.
### Response:
|
SELECT t.TagName, COUNT(*) AS "total_posts", SUM(CASE WHEN AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS "unanswered_posts", SUM(CASE WHEN AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) * 1.0 / COUNT(*) AS "%_unanswered" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE p.ClosedDate IS NULL AND p.PostTypeId = 1 GROUP BY t.TagName ORDER BY 2 DESC, 3 DESC
|
### Instruction:
Test for Language Percentages over Time.
### Response:
|
SELECT Name, YEAR(p.CreationDate) AS Year, MONTH(p.CreationDate) AS Month, COUNT(*) AS Posts, p.CommentCount AS CommentCount, p.Id AS ID FROM Posts AS p CROSS JOIN (VALUES ('C')) AS Language(Name) WHERE (SUBSTRING(p.Body, 0, STR_POSITION(p.Body, CHAR(10))) LIKE '%_>,\_' + name + ',_:\%') GROUP BY Name, YEAR(p.CreationDate), MONTH(p.CreationDate), p.CommentCount, p.Id
|
### Instruction:
flights from SAN FRANCISCO 8 1
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service, city, date_day, days, flight WHERE city.city_code = airport_service.city_code AND city.city_name = 'SAN FRANCISCO' AND date_day.day_number = 1 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.from_airport = airport_service.airport_code
|
### Instruction:
Does the Winter term offer any PreMajor or MDE courses ?
### 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 ('PreMajor', 'MDE') AND program_course.course_id = course.course_id AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2016 GROUP BY course.department, course.number
|
### Instruction:
in 08/last year what was patient 26849's last microbiology test time?
### Response:
|
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26849) AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', microbiologyevents.charttime) = '08' ORDER BY microbiologyevents.charttime 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, find hire_date and the sum of manager_id bin hire_date by time, and visualize them by a bar chart, order in descending by the y-axis.
### Response:
|
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY SUM(MANAGER_ID) DESC
|
### Instruction:
how many times was the valium prescribed this month for patient 022-199074?
### Response:
|
SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-199074')) AND medication.drugname = 'valium' AND DATETIME(medication.drugstarttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### Instruction:
first time, what drug was prescribed for patient 006-167444 until 03/2102?
### Response:
|
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-167444')) AND STRFTIME('%y-%m', medication.drugstarttime) <= '2102-03' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
High-Scoring Questions with Accepted Answers, Parameterized (Tutorial).
### Response:
|
SELECT p.Title, p.Id, p.Score, a.Score AS "Accepted Score", u.DisplayName AS "Asker", au.DisplayName AS "Answerer" FROM Posts AS p JOIN Posts AS a ON p.AcceptedAnswerId = a.Id JOIN Users AS u ON p.OwnerUserId = u.Id JOIN Users AS au ON a.OwnerUserId = au.Id WHERE p.PostTypeId = 1 AND p.Score >= '##MinScore:int##' AND NOT p.AcceptedAnswerId IS NULL ORDER BY p.Score DESC
|
### Instruction:
What is the average increase in literacy for the states that had a rate higher than 73.2% in 2011, less than 68.81% in 2001, and an estimate of 76.8% for 2013?
### Response:
|
SELECT "% Increase" FROM table_75614 WHERE "Literacy Rate (%) - 2011 Census" > '73.2' AND "Literacy Rate (%) - 2001 Census" < '68.81' AND "Literacy Rate (%) - [2013 Estimate]" = '76.8'
|
### Instruction:
did patient 67418 ever have dpt administration since 2101?
### 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 = 'dpt administration') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 67418) AND STRFTIME('%y', procedures_icd.charttime) >= '2101'
|
### Instruction:
how many patients are diagnosed with primary disease neoplasm of uncertain behaviour of other lymphatic and hematopoietic tissues/bone marrow transplant with drug route sl?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "NEOPLASM OF UNCERTAIN BEHAVIOR OF OTHER LYMPHATIC AND HEMATOPOIETIC TISSUES\BONE MARROW TRANSPLANT" AND prescriptions.route = "SL"
|
### Instruction:
what is the name of the diagnosis patient 028-70851 last was received until 4 years 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 = '028-70851')) AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY diagnosis.diagnosistime 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, draw a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, and sort total number in asc order.
### Response:
|
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY SUM(DEPARTMENT_ID)
|
### Instruction:
had patient 031-1337 received since 2103 a diagnosis of cholangiocarcinoma?
### 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 = '031-1337')) AND diagnosis.diagnosisname = 'cholangiocarcinoma' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2103'
|
### Instruction:
what procedure did patient 99082 receive the first time in their first hospital visit.
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99082 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY procedures_icd.charttime LIMIT 1)
|
### 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:
Average question score/views by hour.
### Response:
|
SELECT TIME_TO_STR(CreationDate, '%M') AS Month, TIME_TO_STR(CreationDate, '%Y') AS Year, ROUND(AVG(CAST(Score AS FLOAT)), 2) AS AvgScore, AVG(ViewCount) AS AvgViews FROM Posts WHERE PostTypeId = 1 GROUP BY TIME_TO_STR(CreationDate, '%M'), TIME_TO_STR(CreationDate, '%Y') ORDER BY TIME_TO_STR(CreationDate, '%Y'), TIME_TO_STR(CreationDate, '%M')
|
### 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:
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 bar chart about the distribution of job_id and the sum of manager_id , and group by attribute job_id, order by the names from high to low.
### 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 ORDER BY JOB_ID DESC
|
### Instruction:
Are there any morning sessions for MENAS 334 ?
### 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 = 'MENAS' AND course.number = 334 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### 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:
Are morning classes conducted in PERSIAN 101 ?
### 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 = 'PERSIAN' AND course.number = 101 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
when in 09/2102 patient 19059 received the triglycerides test for the last time?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'triglycerides') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19059) AND STRFTIME('%y-%m', labevents.charttime) = '2102-09' ORDER BY labevents.charttime 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 bar chart about the distribution of hire_date and the amount of hire_date bin hire_date by weekday, could you order in asc by the Y-axis?
### Response:
|
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY COUNT(HIRE_DATE)
|
### Instruction:
Is RCARTS 285 required for RCARTS 289 ?
### Response:
|
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND COURSE_0.department = 'RCARTS' AND COURSE_0.number = 285 AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'RCARTS' AND COURSE_1.number = 289
|
### Instruction:
give me the drug that patient 011-59493 has been first prescribed in 06/2105.
### 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 = '011-59493')) AND STRFTIME('%y-%m', medication.drugstarttime) = '2105-06' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
what procedure was last taken to patient 25796 on their first hospital visit?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25796 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1)
|
### Instruction:
were docusate sodium, potassium chloride or spironolactone prescribed to patient 61527 the previous year?
### Response:
|
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 61527) AND prescriptions.drug IN ('docusate sodium', 'potassium chloride', 'spironolactone') AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
Number of tag additions by per user.
### Response:
|
WITH firstrev_cte AS (SELECT MIN(ph.Id) AS MinId, p.Id FROM Posts AS p JOIN PostHistory AS ph ON ph.PostId = p.Id WHERE ph.Text LIKE '%<##tagName##>%' GROUP BY p.Id), users_cte AS (SELECT PostId AS pid, UserId AS uid, UserDisplayName AS udn FROM PostHistory INNER JOIN firstrev_cte ON PostHistory.Id = MinId) SELECT COUNT(pid), uid AS "user_link", udn FROM users_cte GROUP BY uid, udn ORDER BY COUNT(pid) DESC
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, visualize a bar chart about the distribution of job_id and the average of salary , and group by attribute job_id, order from high to low by the x-axis.
### 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 JOB_ID DESC
|
### Instruction:
had patient 030-64961 received a active warming treatment in the previous year?
### 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-64961')) AND treatment.treatmentname = 'active warming' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
was there any organism found during the first other microbiology test of patient 031-3355 during the current hospital visit?
### Response:
|
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355' AND patient.hospitaldischargetime IS NULL)) AND microlab.culturesite = 'other' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
what was the minimum daily number of patients diagnosed with bipol i currnt manic nos?
### Response:
|
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnoses_icd.hadm_id) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'bipol i currnt manic nos') GROUP BY STRFTIME('%y-%m-%d', diagnoses_icd.charttime)) AS t1
|
### Instruction:
had patient 030-53717 been diagnosed since 2 years ago with sedated - responsive?
### 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 = '030-53717')) AND diagnosis.diagnosisname = 'sedated - responsive' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-2 year')
|
### Instruction:
For End of Fiscal Year(s) with a Debt Held By Public ($Billions) larger than 236.8, and as % of GDP Low-High of 33.4 what is the sum of the number of Gross Debt in $Billions undeflated Treas.?
### Response:
|
SELECT COUNT(gross_debt_in_) AS $billions_undeflated_treas FROM table_name_11 WHERE debt_held_by_public__$billions_ > 236.8 AND as__percentage_of_gdp_low_high = "33.4"
|
### Instruction:
what is the yearly maximum amount of po that patient 002-39247 took?
### Response:
|
SELECT MAX(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-39247')) AND intakeoutput.celllabel = 'po' AND intakeoutput.cellpath LIKE '%intake%' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
|
### Instruction:
Edits to your answers or their questions.
### Response:
|
SELECT a.Id AS "post_link", a.LastEditDate, 'Your answer' FROM Posts AS a WHERE a.OwnerUserId = '##UserId:int##' AND a.PostTypeId = 2 AND a.LastEditDate != a.CreationDate UNION ALL SELECT q.Id AS "post_link", q.LastEditDate, 'Question you''ve answered' FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id WHERE a.OwnerUserId = '##UserId:int##' AND q.LastEditDate != q.CreationDate ORDER BY 2 DESC
|
### Instruction:
count the number of patients who had undergone anticoagulant administration - conventional heparin therapy two or more times since 2105.
### 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 = 'anticoagulant administration - conventional heparin therapy' AND STRFTIME('%y', treatment.treatmenttime) >= '2105') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 >= 2
|
### Instruction:
what is the number of patients who had a delayed clos abd wound procedure in 2103?
### Response:
|
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'delayed clos abd wound') AND STRFTIME('%y', procedures_icd.charttime) = '2103')
|
### Instruction:
users with lots of downvotes per day.
### Response:
|
WITH ratios AS (SELECT Id AS "user_link", ROUND(CAST(DownVotes AS DECIMAL) / DATEDIFF('day', CreationDate, 2016 - 04 - 13), 2) AS ratio, DATEDIFF('day', CreationDate, 2016 - 04 - 13) AS age, Reputation FROM Users WHERE UpVotes + DownVotes > '##minvotes##') SELECT 'user_link', ratio, age, Reputation FROM ratios WHERE ratio > '##minratio##' ORDER BY ratio DESC
|
### Instruction:
Review queue items invalidated on the same day a bounty started.
### Response:
|
SELECT p.Id AS "post_link", p.CreationDate, p.Score, v.CreationDate AS "Bounty start" FROM ReviewTasks AS rt INNER JOIN Posts AS p ON rt.PostId = p.Id INNER JOIN Votes AS v ON rt.PostId = v.PostId AND v.VoteTypeId = 8 AND rt.DeletionDate = DATE(v.CreationDate) WHERE rt.ReviewTaskTypeId = '##ReviewTaskTypeId:int##' ORDER BY v.CreationDate DESC LIMIT 100
|
### 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, I want to display bar from high to low order please.
### 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 JOB_ID DESC
|
### Instruction:
what is patient 007-2001's maximum heartrate, since 811 days ago?
### Response:
|
SELECT MAX(vitalperiodic.heartrate) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-2001')) AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-811 day')
|
### Instruction:
Number of Closed Questions with a Minecraft Tag.
### Response:
|
SELECT (SELECT COUNT(Id) AS ClosedCount FROM Posts AS P INNER JOIN PostTags AS PT ON PT.PostId = P.Id WHERE NOT P.ClosedDate IS NULL AND PT.TagId IN (SELECT T.Id FROM Tags AS T WHERE T.TagName LIKE '%minecraft%')) / (SELECT COUNT(Id) AS TotalCount FROM Posts AS P INNER JOIN PostTags AS PT ON PT.PostId = P.Id WHERE PT.TagId IN (SELECT T.Id FROM Tags AS T WHERE T.TagName LIKE '%minecraft%')) * 100 AS ClosedPercent
|
### Instruction:
what is the name of the drug that was prescribed two times to patient 018-41654?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '018-41654')) GROUP BY medication.drugname) AS t1 WHERE t1.c1 = 2
|
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of hire_date and the average of salary bin hire_date by weekday, I want to display from low to high by the mean salary.
### Response:
|
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY AVG(SALARY)
|
### Instruction:
what was the first time that the sao2 of patient 017-9785 was, , greater than 88.0?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-9785')) AND vitalperiodic.sao2 > 88.0 AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.