instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
Question statistics for a single user.
### Response:
|
SELECT 'Questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 UNION ALL SELECT 'Questions without accepted answer', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AcceptedAnswerId IS NULL UNION ALL SELECT 'Unanswered questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AnswerCount = 0 UNION ALL SELECT 'Resolved questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AcceptedAnswerId > 0
|
### Instruction:
Unanswered Questions with 3 Close Votes.
### Response:
|
SELECT Posts.Id AS "post_link", Posts.CreationDate AS "post_date", Posts.Score AS "post_score", COUNT(Votes.Id) AS "close_votes" FROM Posts INNER JOIN Votes ON Posts.Id = Votes.PostId WHERE Votes.VoteTypeId = 6 AND Posts.ClosedDate IS NULL AND Posts.Tags LIKE '%<php>%' AND Posts.AnswerCount = 0 AND Posts.Score > 0 GROUP BY Posts.Id, Posts.CreationDate, Posts.Score HAVING COUNT(Votes.Id) > 3 ORDER BY 'post_date' DESC
|
### Instruction:
Who won men's singles when petya nedelcheva won women's singles, petya nedelcheva diana dimova won women's doubles, stilian makarski diana dimova won mixed doubles, and stilian makarski peyo boichinov won men's doubles?
### Response:
|
SELECT "Men's singles" FROM table_36707 WHERE "Women's singles" = 'petya nedelcheva' AND "Women's doubles" = 'petya nedelcheva diana dimova' AND "Mixed doubles" = 'stilian makarski diana dimova' AND "Men's doubles" = 'stilian makarski peyo boichinov'
|
### Instruction:
when was last intake time of patient 017-12240 until 1019 days ago?
### 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 = '017-12240')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1019 day') ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
|
### Instruction:
how many time did patient 82235 produce a or urine output until 11/2103?
### Response:
|
SELECT COUNT(*) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 82235)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'or urine' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m', outputevents.charttime) <= '2103-11'
|
### Instruction:
Detect posts misusing backticks for programming languages.
### Response:
|
SELECT Id AS "post_link" FROM Posts WHERE Posts.Id > '##StartID:int?1##' AND Posts.Id < '##EndID:int?1000000##' AND (Body LIKE '%<code>PHP</code>%' OR Body LIKE '%<code>javascript</code>%' OR Body LIKE '%<code>C#</code>%' OR Body LIKE '%<code>python</code>%' OR Body LIKE '%<code>java</code>%' OR Body LIKE '%<code>C</code>%' OR Body LIKE '%<code>C++</code>%' OR Body LIKE '%<code>Android</code>%') ORDER BY Id
|
### Instruction:
how many days have elapsed since patient 004-13127 last received a -monos lab test on their current hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '004-13127' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = '-monos' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
patient 028-32921 underwent a protein c test in 05/this year?
### Response:
|
SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-32921')) AND lab.labname = 'protein c' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '05'
|
### Instruction:
how many hours has it been since the last time patient 030-42006 was given a pt test on their current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '030-42006' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'pt' ORDER BY lab.labresulttime DESC LIMIT 1
|
### Instruction:
Tag wikis with old PHP links.
### Response:
|
SELECT DISTINCT Tags.Id, Tags.TagName, 'site://tags/' + Tags.TagName + '/info|Url' AS Url, LENGTH(Posts.Body) FROM Tags LEFT JOIN Posts ON Posts.Id = Tags.WikiPostId OR Posts.Id = Tags.ExcerptPostId WHERE (LOWER(Posts.Body) LIKE '%http://php.net%' OR LOWER(Posts.Body) LIKE '%http://__.php.net%' OR LOWER(Posts.Body) LIKE '%http://___.php.net%' OR LOWER(Posts.Body) LIKE '%https://secure.php.net%') ORDER BY Tags.Id
|
### Instruction:
have there been any organisms found in the first microbiological stool test of patient 031-3507 on their last 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-3507' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND microlab.culturesite = 'stool' ORDER BY microlab.culturetakentime LIMIT 1
|
### Instruction:
How many upvotes do I have for each tag? (Wiki & Non-Wiki). how long before I get tag badges?
### Response:
|
SELECT TagName, SUM(CASE WHEN Posts.CommunityOwnedDate IS NULL OR Votes.CreationDate < Posts.CommunityOwnedDate THEN 1 ELSE 0 END) AS NonWikiUpvotes, COUNT(*) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 WHERE Posts.OwnerUserId = @UserId GROUP BY TagName ORDER BY UpVotes DESC
|
### Instruction:
had any tpn d22.5 been given to patient 31854 on the current intensive care unit visit?
### Response:
|
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31854) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d22.5' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
significant organ system dysfunction ( e.g., clinically significant pulmonary or cardiovascular disease, anemia [hemoglobin < 10 g / dl], known hemoglobinopathies, and renal dysfunction [egfr < 60 ml / min] ) ;
### Response:
|
SELECT * FROM table_dev_14 WHERE organ_failure = 1 OR pulmonary_disease = 1 OR cardiovascular_disease = 1 OR anemia = 1 OR hemoglobin_a1c_hba1c < 10 OR renal_disease = 1 OR estimated_glomerular_filtration_rate_egfr < 60
|
### Instruction:
what is the average cost to the hospital which involves stricture of artery until 2104.
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT diagnoses_icd.hadm_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'stricture of artery')) AND STRFTIME('%y', cost.chargetime) <= '2104' GROUP BY cost.hadm_id) AS t1
|
### Instruction:
what is the average amount of the total hospital cost which involves viral hepatitis - hepatitis b since 2 years ago?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'viral hepatitis - hepatitis b')) AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
when was the first time patient 021-75161 had been prescribed medication through the oral route until 09/2105?
### 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 = '021-75161')) AND medication.routeadmin = 'oral' AND STRFTIME('%y-%m', medication.drugstarttime) <= '2105-09' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
Possible answers that will fetch you Sportsmanship badge.
### Response:
|
SELECT a.Id AS "post_link", a.Score, 'site://questions/' + CAST(b.Id AS TEXT) AS "other_answer_link", b.Score FROM Posts AS a INNER JOIN Posts AS b ON a.ParentId = b.ParentId AND a.Id != b.Id WHERE a.OwnerUserId = @UserId AND a.PostTypeId = 2 AND a.Score > 0 AND b.ParentId != @UserId AND b.PostTypeId = 2 AND EXISTS(SELECT 1 FROM Votes AS c WHERE c.PostId = b.Id AND c.VoteTypeId = 2) ORDER BY a.ParentId
|
### Instruction:
what is the yearly maximum cholesterol, ldl, calculated level of patient 27703 since 11/2105?
### Response:
|
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27703) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'cholesterol, ldl, calculated') AND STRFTIME('%y-%m', labevents.charttime) >= '2105-11' GROUP BY STRFTIME('%y', labevents.charttime)
|
### Instruction:
Questions neither closed nor deleted indicating embedded application.
### Response:
|
SELECT COUNT(q.Id) AS "count" FROM Posts AS q LEFT JOIN PostTags AS j ON j.PostId = q.Id INNER JOIN Tags AS t ON j.TagId = t.Id WHERE q.PostTypeId = 1 AND q.ClosedDate IS NULL AND q.DeletionDate IS NULL AND (q.Body LIKE '% embedded %' OR q.Body LIKE '% robot%' OR q.Body LIKE '%real time%' OR q.Title LIKE '% embedded %' OR q.Title LIKE '% robot%' OR q.Title LIKE '%real time%' OR t.TagName = 'real-time') AND NOT q.Body LIKE '% word embed%' AND NOT q.Title LIKE '% word embed%'
|
### Instruction:
what is patient 002-3736's first output on 02/26/2103?
### Response:
|
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-3736')) AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2103-02-26' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
did patient 12410 excreted any urine out foley on the last icu visit?
### Response:
|
SELECT COUNT(*) > 0 FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12410) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'urine out foley' AND d_items.linksto = 'outputevents')
|
### Instruction:
what was the name of the last intake that patient 739 yesterday had?
### Response:
|
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT inputevents_cv.itemid FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 739)) AND DATETIME(inputevents_cv.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY inputevents_cv.charttime DESC LIMIT 1)
|
### Instruction:
what are the fares for flights between ATLANTA and DFW provided by AA
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport, airport_service, city, fare, flight, flight_fare WHERE (airport.airport_code = 'DFW' AND city.city_code = airport_service.city_code AND city.city_name = 'ATLANTA' AND flight.from_airport = airport_service.airport_code AND flight.to_airport = airport.airport_code) AND flight_fare.fare_id = fare.fare_id AND flight.airline_code = 'AA' AND flight.flight_id = flight_fare.flight_id
|
### Instruction:
when was the last time patient 021-25705 has been diagnosed with depression since 2 years ago?
### Response:
|
SELECT diagnosis.diagnosistime FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-25705')) AND diagnosis.diagnosisname = 'depression' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY diagnosis.diagnosistime DESC LIMIT 1
|
### Instruction:
Users Answer and Question Votes. See the total up and down votes for answers and questions for a given user.
### Response:
|
SELECT (CASE WHEN p.PostTypeId = 1 THEN 'Question' WHEN p.PostTypeId = 2 THEN 'Answer' END) AS "post_type", (CASE WHEN v.VoteTypeId = 2 THEN 'Up Vote' WHEN v.VoteTypeId = 3 THEN 'Down Vote' END) AS "vote_type", COUNT(*) AS Votes FROM Votes AS v JOIN Posts AS p ON v.PostId = p.Id WHERE v.VoteTypeId IN (2, 3) AND v.UserId = @userid GROUP BY p.PostTypeId, v.VoteTypeId
|
### Instruction:
Average Score and Close count Percentage By Year, Month.
### Response:
|
SELECT AVG(CAST(Score AS FLOAT(10, 5))) AS Avg_Score, CAST(SUM(CASE WHEN NOT ClosedDate IS NULL THEN 1 ELSE 0 END) AS FLOAT(15, 5)) / CAST(COUNT(Id) AS FLOAT(15, 5)) AS CloseCountPercentage, MONTH(CreationDate) AS month, YEAR(CreationDate) AS year FROM Posts AS p WHERE PostTypeId = 1 GROUP BY MONTH(CreationDate), YEAR(CreationDate) ORDER BY YEAR(CreationDate), MONTH(CreationDate)
|
### Instruction:
When is 580 going to be offered again ?
### Response:
|
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 580 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1
|
### Instruction:
when was the last time that patient 022-78464 was prescribed a medication since 08/2100 via iv?
### 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 = '022-78464')) AND medication.routeadmin = 'iv' AND STRFTIME('%y-%m', medication.drugstarttime) >= '2100-08' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
when did patient 030-47098 for the first time since 6 years ago receive treatment of hyperphosphatemia?
### 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 = '030-47098')) AND treatment.treatmentname = 'treatment of hyperphosphatemia' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-6 year') ORDER BY treatment.treatmenttime LIMIT 1
|
### Instruction:
is the respiration of patient 006-99708 was normal until 126 days ago.
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-99708')) AND vitalperiodic.respiration BETWEEN respiration_lower AND respiration_upper AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-126 day')
|
### Instruction:
when was the first time until 11/2105 that patient 002-34744 was prescribed a drug via rectal?
### 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 = '002-34744')) AND medication.routeadmin = 'rectal' AND STRFTIME('%y-%m', medication.drugstarttime) <= '2105-11' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
what is the minimum hospital cost for a drug with a name called nacl 0.9% bolus until 2 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 medication.patientunitstayid FROM medication WHERE medication.drugname = 'nacl 0.9% bolus')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
Percentage of AngularJS question without vote in the 5 days.
### Response:
|
SELECT CASE WHEN Votes.Id IS NULL THEN 1 ELSE 0 END AS Unvoted, VoteTypes.Name, Posts.Score, Posts.Title FROM Posts LEFT JOIN Votes ON Posts.Id = Votes.PostId JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id JOIN VoteTypes ON VoteTypes.Id = Votes.VoteTypeId WHERE Posts.PostTypeId = 1 AND Posts.CreationDate > CURRENT_TIMESTAMP() - 5 AND Tags.TagName = 'angularjs' ORDER BY DAY(Posts.CreationDate)
|
### Instruction:
is it patient 013-38992's heartrate ever greater than 74.0 in 12/2105?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-38992')) AND vitalperiodic.heartrate > 74.0 AND NOT vitalperiodic.heartrate IS NULL AND STRFTIME('%y-%m', vitalperiodic.observationtime) = '2105-12'
|
### Instruction:
what was the last medication that patient 002-38474 was prescribed via iv push route since 128 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-38474')) AND medication.routeadmin = 'iv push' AND DATETIME(medication.drugstarttime) >= DATETIME(CURRENT_TIME(), '-128 month') ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
how many times patient 84042 had received a lt heart angiocardiogram procedure since 6 years ago.
### Response:
|
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'lt heart angiocardiogram') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 84042) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year')
|
### Instruction:
Tag synonyms where both tags have some questions. As far as I can tell, this happens when the tags were synonymized without merging
### Response:
|
SELECT ts.SourceTagName AS "tags", t1.Count, ts.TargetTagName AS "tags", t2.Count, ts.CreationDate, ts.OwnerUserId AS "user_link", ts.ApprovalDate, ts.ApprovedByUserId AS "user_link" FROM TagSynonyms AS ts INNER JOIN Tags AS t1 ON ts.SourceTagName = t1.TagName INNER JOIN Tags AS t2 ON ts.TargetTagName = t2.TagName WHERE (t1.Count > 0) AND (NOT ts.ApprovalDate IS NULL) ORDER BY t1.Count DESC
|
### Instruction:
what were the names of the output that patient 94229 had last since 12/07/2105?
### Response:
|
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT outputevents.itemid FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 94229)) AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2105-12-07' ORDER BY outputevents.charttime DESC LIMIT 1)
|
### Instruction:
Users by tags in DK.
### Response:
|
SELECT u.Id AS "user_link", t.TagName, u.Reputation AS rep, u.DisplayName AS UserName FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON t.Id = pt.TagId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE (u.Location = 'Copenhagen' OR u.Location = 'Denmark') AND (t.TagName = 'python' OR t.TagName = 'docker' OR t.TagName = 'amazon-web-services') AND u.Reputation >= '400' GROUP BY u.Id, u.Reputation, u.DisplayName, t.TagName
|
### Instruction:
did patient 71129 have the diagnosis of gu infection-antepartum since 2101?
### 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 = 'gu infection-antepartum') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 71129) AND STRFTIME('%y', diagnoses_icd.charttime) >= '2101'
|
### Instruction:
what are the four most common lab tests among the patients aged 20s in 2103?
### 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 labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 20 AND 29) AND STRFTIME('%y', labevents.charttime) = '2103' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
what is the top five most frequent diagnoses for patients aged 30s during the previous year?
### Response:
|
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 30 AND 39) AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
what was the drug that was prescribed to patient 002-58884 on the first hospital visit via the mucous mem route for the first time?
### 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-58884' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND medication.routeadmin = 'mucous mem' ORDER BY medication.drugstarttime LIMIT 1
|
### Instruction:
how many patients since 4 years ago had an intake of cath lab 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 = 'cath lab intake' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-4 year')))
|
### Instruction:
calculate how many times patient 26612 had a 1000n/s 20gm ca glu intake.
### Response:
|
SELECT COUNT(*) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26612)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '1000n/s 20gm ca glu' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
when has patient 031-23605 been given a microbiology test for the last time until 08/2104?
### Response:
|
SELECT microlab.culturetakentime FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23605')) AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2104-08' ORDER BY microlab.culturetakentime DESC LIMIT 1
|
### Instruction:
how many patients in 2105 had an intake of nutramigin 26 ng?
### 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 = 'nutramigin 26 ng' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y', inputevents_cv.charttime) = '2105'))
|
### Instruction:
what was the total intake of free water bolus that patient 1902 has received on the current icu visit?
### Response:
|
SELECT SUM(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1902) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'free water bolus' AND d_items.linksto = 'inputevents_cv')
|
### Instruction:
indicate the yearly minimum amount of sao2 for patient 6580.
### Response:
|
SELECT MIN(chartevents.valuenum) FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 6580)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sao2' AND d_items.linksto = 'chartevents') GROUP BY STRFTIME('%y', chartevents.charttime)
|
### Instruction:
what procedure did patient 57023 receive that last time this year?
### 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 = 57023) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY procedures_icd.charttime DESC LIMIT 1)
|
### Instruction:
Count of posts' and votes' sorted by rep.
### Response:
|
SELECT u.DisplayName, u.Reputation, u.UpVotes, u.DownVotes, q.QuestionsCount, a.AnswersCount, u.Reputation / a.AnswersCount AS RepPerAnswer FROM Users AS u JOIN (SELECT COUNT(1) AS QuestionsCount, OwnerUserId FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) AS q ON u.Id = q.OwnerUserId JOIN (SELECT COUNT(1) AS AnswersCount, OwnerUserId FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS a ON u.Id = a.OwnerUserId ORDER BY u.Reputation DESC
|
### Instruction:
until 303 days ago, was patient 030-31704's heartrate ever less than 61.0?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-31704')) AND vitalperiodic.heartrate < 61.0 AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-303 day')
|
### Instruction:
Badges, with award times, for a given user.
### Response:
|
SELECT u.Id AS "user_link", CASE WHEN b.TagBased = 1 THEN 'Tag: ''_+_b.name_+_''' ELSE b.Name END AS "badge_name", CASE WHEN b.Class = 1 THEN 'Gold' WHEN b.Class = 2 THEN 'Silver' WHEN b.Class = 3 THEN 'Bronze' ELSE '*Unkown*' END AS "class", b.Date AS "awarded" FROM Badges AS b LEFT JOIN Users AS u ON u.Id = b.UserId WHERE b.UserId = '##UserId:int##' ORDER BY u.DisplayName, 'awarded' DESC
|
### Instruction:
tell me the total amount of input that patient 017-74752 has received since 06/25/2102?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-74752')) AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2102-06-25'
|
### Instruction:
how many days is it since patient 027-120575 first received the mch lab test in the current hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '027-120575' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'mch' ORDER BY lab.labresulttime LIMIT 1
|
### Instruction:
count the number of patients whose ethnicity is hispanic/latino - puerto rican and diagnoses long title is other specified procedures as the cause of abnormal reaction of patient, or of later complication, without mention of misadventure at time of procedure?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND diagnoses.long_title = "Other specified procedures as the cause of abnormal reaction of patient, or of later complication, without mention of misadventure at time of procedure"
|
### Instruction:
Distribution of posts from a given year by time of day.
### Response:
|
WITH post AS (SELECT TIME_TO_STR(CreationDate, '%H') AS Hour, PostTypeId AS Id FROM Posts WHERE TIME_TO_STR(CreationDate, '%Y') = '##year:int##'), data AS (SELECT Hour, Id, COUNT(*) AS Num FROM post GROUP BY Id, Hour), totals AS (SELECT COUNT(*) AS Num, Id FROM post GROUP BY Id) SELECT Hour, PostTypes.Name, data.Num * 1. / totals.Num AS Activity FROM data JOIN totals ON data.Id = totals.Id JOIN PostTypes ON data.Id = PostTypes.Id ORDER BY PostTypes.Id, Hour
|
### Instruction:
When will EECS 582 be offered ?
### Response:
|
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 582 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1
|
### Instruction:
what was the last time until 01/2104 patient 035-15069 had the maximum bedside glucose.
### 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 = '035-15069')) AND lab.labname = 'bedside glucose' AND STRFTIME('%y-%m', lab.labresulttime) <= '2104-01' ORDER BY lab.labresult DESC, lab.labresulttime DESC LIMIT 1
|
### Instruction:
What are the product ids for the problems reported by Christop Berge with closure authorised by Ashley Medhurst?
### Response:
|
SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.reported_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Christop" AND T2.staff_last_name = "Berge" INTERSECT SELECT product_id FROM problems AS T1 JOIN staff AS T2 ON T1.closure_authorised_by_staff_id = T2.staff_id WHERE T2.staff_first_name = "Ashley" AND T2.staff_last_name = "Medhurst"
|
### Instruction:
Which section after 19:15 A.M. is in ANTHRBIO 334 ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '19:15' AND course.course_id = course_offering.course_id AND course.department = 'ANTHRBIO' AND course.number = 334 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
Top Android Users in Austria.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%austria%' GROUP BY u.Id) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
### Instruction:
tell me the yearly average temperature of patient 007-15837 since 4 days ago.
### Response:
|
SELECT AVG(vitalperiodic.temperature) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-15837')) AND NOT vitalperiodic.temperature IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-4 day') GROUP BY STRFTIME('%y', vitalperiodic.observationtime)
|
### Instruction:
calculate how many times patient 003-54468 received a laboratory test for tv in 06/this year.
### Response:
|
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-54468')) AND lab.labname = 'tv' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', lab.labresulttime) = '06'
|
### Instruction:
has there been any microbiological test on the sputum, expectorated of patient 031-15417 until 06/2103?
### Response:
|
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-15417')) AND microlab.culturesite = 'sputum, expectorated' AND STRFTIME('%y-%m', microlab.culturetakentime) <= '2103-06'
|
### Instruction:
did patient 022-76925's sao2 since 27 months ago be greater than 85.0?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-76925')) AND vitalperiodic.sao2 > 85.0 AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime) >= DATETIME(CURRENT_TIME(), '-27 month')
|
### Instruction:
how much clopidogrel is prescribed the first time in 06/this year to patient 72364?
### Response:
|
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 72364) AND prescriptions.drug = 'clopidogrel' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '06' ORDER BY prescriptions.startdate LIMIT 1
|
### Instruction:
Question which had the tag but no longer have it (including the editor).
### 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##>%' AND NOT (p.Tags LIKE '%<##tagName##>%') GROUP BY p.Id) SELECT PostId AS "post_link", url = 'site://posts/' + CAST(PostId AS TEXT) + '/revisions', UserId AS "user_link", UserDisplayName, CreationDate FROM PostHistory INNER JOIN firstrev_cte ON PostHistory.Id = MinId ORDER BY CreationDate DESC
|
### Instruction:
In next semester which classes are taught by Dr. Craig Ruff ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Craig Ruff%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
What will be the classes that are taught by Dr. Kelly Williams next semester ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Kelly Williams%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is the monthly minimum alkaline phosphatase value for patient 23475 since 01/2105?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23475) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'alkaline phosphatase') AND STRFTIME('%y-%m', labevents.charttime) >= '2105-01' GROUP BY STRFTIME('%y-%m', labevents.charttime)
|
### Instruction:
Rise and fall of the Close Vote Queue.
### Response:
|
WITH minmax AS (SELECT MIN(CreationDate) AS mindate, MAX(DeletionDate) AS maxdate FROM ReviewTasks WHERE ReviewTaskTypeId = 2), days AS (SELECT DISTINCT DATE(CreationDate) AS utcdate FROM Posts WHERE CreationDate BETWEEN (SELECT mindate FROM minmax) AND (SELECT maxdate FROM minmax)) SELECT utcdate, COUNT(*) AS "#_of_tasks" FROM days AS d INNER JOIN ReviewTasks AS r ON d.utcdate BETWEEN r.CreationDate AND r.DeletionDate WHERE r.ReviewTaskTypeId = 2 GROUP BY utcdate ORDER BY utcdate
|
### Instruction:
Top 100 posts with all comments upvoted. Inspired by this post: https://meta.stackexchange.com/questions/322566/say-to-the-new-contributor-that-upvoting-comments-does-almost-nothing-for-comm
### Response:
|
SELECT Posts.Id AS "post_link" FROM Posts, Comments WHERE Posts.PostTypeId = 1 AND Posts.CommentCount > 3 AND Posts.Id = Comments.PostId AND Posts.OwnerUserId != Comments.UserId GROUP BY Posts.Id HAVING MIN(Comments.Score) = 1 AND MAX(Comments.Score) = 1 LIMIT 100
|
### Instruction:
today, did patient 016-38131 have any bulb #2 output?
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-38131')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'bulb #2' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
Most popular tags in 2019 group by month - Show only the tags used in more than 100 posts.
### Response:
|
SELECT MONTH(p.CreationDate), pt.TagId, t.TagName, COUNT(pt.TagId) FROM (PostTags AS pt INNER JOIN Posts AS p ON p.Id = pt.PostId) INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE YEAR(p.CreationDate) = '2019' GROUP BY MONTH(p.CreationDate), pt.TagId, t.TagName HAVING COUNT(pt.TagId) > 100 ORDER BY MONTH(p.CreationDate), COUNT(pt.TagId) DESC
|
### Instruction:
what was patient 5828 first height in their current hospital encounter?
### Response:
|
SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 5828 AND admissions.dischtime IS NULL)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
How many courses for each teacher? Show me a stacked bar chart The x-axis is teacher's first name and group by course description, and could you show by the Y-axis in ascending?
### Response:
|
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY CRS_DESCRIPTION, EMP_FNAME ORDER BY COUNT(EMP_FNAME)
|
### Instruction:
how many times had patient 57899 since 2105 received a aortocor bypas-2 cor art?
### Response:
|
SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'aortocor bypas-2 cor art') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 57899) AND STRFTIME('%y', procedures_icd.charttime) >= '2105'
|
### Instruction:
tell me the daily average systemicdiastolic of patient 016-27397 during this hospital encounter.
### Response:
|
SELECT AVG(vitalperiodic.systemicdiastolic) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-27397' AND patient.hospitaldischargetime IS NULL)) AND NOT vitalperiodic.systemicdiastolic IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
|
### Instruction:
make a count of the number of times patient 003-48563 has received a immunosuppressive therapy - thymoglobulin during their last hospital encounter.
### Response:
|
SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-48563' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND treatment.treatmentname = 'immunosuppressive therapy - thymoglobulin'
|
### Instruction:
what is the daily minimum value of patient 010-11305's hco3 until 56 months ago?
### 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 = '010-11305')) AND lab.labname = 'hco3' AND DATETIME(lab.labresulttime) <= DATETIME(CURRENT_TIME(), '-56 month') GROUP BY STRFTIME('%y-%m-%d', lab.labresulttime)
|
### Instruction:
has ever been greater than 97.0 the sao2 of patient 022-151182 on the first intensive care unit visit?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-151182') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND vitalperiodic.sao2 > 97.0 AND NOT vitalperiodic.sao2 IS NULL
|
### Instruction:
what was the 'output' patient 033-3992 got today for the first time?
### Response:
|
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-3992')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
Tags most associated with another, by year.. Given a primary tag, and year, list the associated tags by popularity.
### Response:
|
SELECT Tags.TagName AS "tag_name", COUNT(*) AS "number_of_associated_posts" FROM PostTags INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE PostTags.PostId IN (SELECT DISTINCT PostId FROM PostTags INNER JOIN Tags ON Tags.Id = PostTags.TagId INNER JOIN Posts ON Posts.Id = PostTags.PostId WHERE Tags.TagName = '##TagName:string##' AND YEAR(Posts.CreationDate) = '##Year:int##') AND Tags.TagName != '##TagName:string##' GROUP BY Tags.TagName ORDER BY COUNT(*) DESC
|
### Instruction:
what was the first time patient 8005 had the minimum level of alanine aminotransferase (alt) when they visited the hospital last time?
### Response:
|
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8005 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'alanine aminotransferase (alt)') ORDER BY labevents.valuenum, labevents.charttime LIMIT 1
|
### Instruction:
who linked to my posts? (user construction).
### Response:
|
SELECT lnk.CreationDate AS DateLinked, PostId AS linkin, RelatedPostId AS "post_link", p2.CreationDate AS origPostDate, p2.OwnerUserId AS "user_link", PostId AS "post_link", p1.CreationDate AS destPostDate, p1.OwnerUserId AS "user_link" FROM PostLinks AS lnk LEFT JOIN Posts AS p2 ON lnk.RelatedPostId = p2.Id LEFT JOIN Posts AS p1 ON lnk.PostId = p1.Id WHERE LinkTypeId = 1 AND p2.OwnerUserId = '##UserID##'
|
### Instruction:
Next semester Dr. Stephen Tyndall will teach which classes ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Stephen Tyndall%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
had patient 027-136480 go through a insulin - subcutaneous dose of regular insulin since 1 year ago?
### 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 = '027-136480')) AND treatment.treatmentname = 'insulin - subcutaneous dose of regular insulin' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-1 year')
|
### Instruction:
Does PHYSIOL 545 offer a section after 16:30 P.M. ?
### Response:
|
SELECT DISTINCT course_offering.end_time, course_offering.section_number, course_offering.start_time FROM course, course_offering, semester WHERE course_offering.start_time > '16:30' AND course.course_id = course_offering.course_id AND course.department = 'PHYSIOL' AND course.number = 545 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
Last semester in CZECH 242 , who were the GSIs ?
### Response:
|
SELECT DISTINCT student.firstname, student.lastname FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'CZECH' AND course.number = 242 AND semester.semester = 'FA' AND semester.year = 2015
|
### Instruction:
what is the yearly minimum intake of volume (ml) dopamine that patient 006-78314 is getting?
### Response:
|
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-78314')) AND intakeoutput.celllabel = 'volume (ml) dopamine' AND intakeoutput.cellpath LIKE '%intake%' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
|
### Instruction:
i would like information on ground transportation in the city of ATLANTA from airport to downtown
### Response:
|
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city AS CITY_0, city AS CITY_1, ground_service WHERE airport.airport_code = airport_service.airport_code AND CITY_0.city_name = 'ATLANTA' AND CITY_1.city_code = airport_service.city_code AND CITY_1.city_name = 'ATLANTA' AND ground_service.airport_code = airport.airport_code AND ground_service.city_code = CITY_0.city_code
|
### Instruction:
Stat language trends over time by month.
### Response:
|
SELECT tmp.yearmon AS YEARMON, tmp.TagName AS TAGNAME, COUNT(*) AS COUNT FROM (SELECT DATE(CAST(TIME_TO_STR(CreationDate, '%Y') AS TEXT) + '-' + CAST(TIME_TO_STR(CreationDate, '%m') AS TEXT) + '-01') AS yearmon, t.TagName AS tagname FROM Posts AS p JOIN PostTags AS pt ON pt.PostId = p.Id JOIN Tags AS t ON t.Id = pt.TagId WHERE t.TagName IN ('java', 'c#', 'c++')) AS tmp GROUP BY YEARMON, TagName ORDER BY YEARMON DESC, TagName
|
### Instruction:
EECS 429 offered when next ?
### Response:
|
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 429 AND course_offering.semester = semester.semester_id AND semester.semester_id > (SELECT SEMESTERalias1.semester_id FROM semester AS SEMESTERalias1 WHERE SEMESTERalias1.semester = 'WN' AND SEMESTERalias1.year = 2016) ORDER BY semester.semester_id LIMIT 1
|
### Instruction:
adults ( male and female ) aged > 70 years, clinical dementia rating ( cdr ) = 0.5 - 1 and mini _ mental state examination ( mmse ) : 20 - 25
### Response:
|
SELECT * FROM table_train_140 WHERE age >= 18 AND (gender = 'male' OR gender = 'female') AND age > 70 AND (clinical_dementia_rating_cdr >= 0.5 AND clinical_dementia_rating_cdr <= 1) AND (mini_mental_state_examination_mmse >= 20 AND mini_mental_state_examination_mmse <= 25)
|
### Instruction:
Duplicate Questions (Title, Body) - MRA.
### Response:
|
SELECT p.Id AS postid, p.Title AS posttitle, p.Body AS posttext, p.Tags AS posttags, dupes.Id AS dupid, dupes.Title AS duptitle, dupes.Body AS duptext, dupes.Tags AS duptags FROM Posts AS p JOIN PostLinks AS links ON (p.Id = links.RelatedPostId AND LinkTypeId = 3) JOIN Posts AS dupes ON (dupes.Id = links.PostId AND dupes.PostTypeId = 1) WHERE p.CreationDate > '2016-01-01 00:00:00'
|
### Instruction:
had patient 012-40970's respiration levels been normal until 56 months ago?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-40970')) AND vitalperiodic.respiration BETWEEN respiration_lower AND respiration_upper AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime) <= DATETIME(CURRENT_TIME(), '-56 month')
|
### Instruction:
what is the average total hospital cost that involves bone fracture(s) - sternum until 3 years ago?
### Response:
|
SELECT AVG(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'bone fracture(s) - sternum')) AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY cost.patienthealthsystemstayid) AS t1
|
### Instruction:
Top C++ users in Sweden.
### Response:
|
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", COUNT(*) AS UpVotes FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Votes AS v ON v.PostId = p.Id AND VoteTypeId = 2 INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE TagName = 'c++' GROUP BY u.Id, TagName) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.