instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: Count of questions with serverless tag over time. ### Response:
SELECT DATEADD(week, DATEDIFF(day, '20000109', CreationDate) / 7, '20000109') AS "week", COUNT(DISTINCT Posts.Id) AS Posts, SUM(Posts.AnswerCount) AS Answers, SUM(Posts.CommentCount) AS Comments FROM Posts INNER JOIN PostTags ON PostTags.PostId = Posts.Id INNER JOIN Tags ON PostTags.TagId = Tags.Id WHERE Tags.TagName LIKE 'bigcommerce' AND PostTypeId = 1 AND CreationDate > '2013-01-06' GROUP BY DATEADD(week, DATEDIFF(day, '20000109', CreationDate) / 7, '20000109') ORDER BY 'week' DESC
### Instruction: what is the new medicine prescribed for patient 009-7776 today compared to the drug yesterday? ### Response:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '009-7776') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '009-7776') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: how many days has it been since last time patient 025-50213 was prescribed dextrose 50% 25 gram/50 ml syr during this hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '025-50213') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'dextrose 50% 25 gram/50 ml syr' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: how many hours has it elapsed since patient 97395's last diagnosis of trnspl status-bne marrow on this hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnoses_icd.charttime)) FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'trnspl status-bne marrow') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97395 AND admissions.dischtime IS NULL) ORDER BY diagnoses_icd.charttime DESC LIMIT 1
### Instruction: give me all the flights from MIAMI to CHICAGO on AA ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CHICAGO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MIAMI' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
### Instruction: when did patient 031-15666 first have their minimum respiration on 12/22/last year? ### 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 = '031-15666')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '12-22' ORDER BY vitalperiodic.respiration, vitalperiodic.observationtime LIMIT 1
### Instruction: fly from DENVER to PHILADELPHIA on CO ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'CO'
### Instruction: show me the direct flights from SAN FRANCISCO to BOSTON ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: Is RACKHAM 571 easier than RACKHAM 575 ? ### Response:
SELECT COUNT(*) > 0 FROM course AS COURSE_0, course AS COURSE_1, program_course AS PROGRAM_COURSE_0, program_course AS PROGRAM_COURSE_1 WHERE COURSE_0.department = 'RACKHAM' AND COURSE_0.number = 575 AND COURSE_1.department = 'RACKHAM' AND COURSE_1.number = 571 AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id AND PROGRAM_COURSE_0.workload < PROGRAM_COURSE_1.workload AND PROGRAM_COURSE_1.course_id = COURSE_1.course_id
### Instruction: since 10/11/2104 what was patient 1784's last arterial bp mean? ### 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 = 1784)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2104-10-11' ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: i want a return flight from WASHINGTON to DALLAS on AA ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DALLAS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
### Instruction: What classes are only available in the Spring-Summer ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'EECS' AND semester.semester = 'Spring-Summer' AND (SELECT COUNT(DISTINCT SEMESTERalias1.semester) FROM course AS COURSEalias1 INNER JOIN course_offering ON COURSEalias1.course_id = course_offering.course_id INNER JOIN semester AS SEMESTERalias1 ON SEMESTERalias1.semester_id = course_offering.semester WHERE course.course_id = COURSEalias1.course_id) = 1
### Instruction: show all nonstop flights from BOSTON to SAN FRANCISCO ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: what is the yearly average amount of indwelling catheter in patient 021-79544 since 04/16/2104? ### Response:
SELECT AVG(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 = '021-79544')) AND intakeoutput.celllabel = 'indwelling catheter' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-04-16' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
### Instruction: how many times did patient 005-46456 have a volume (ml)-levetiracetam (keppra) ivpb 500 mg intake during the last month? ### Response:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-46456')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'volume (ml)-levetiracetam (keppra) ivpb 500 mg' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month')
### Instruction: show me the flights from WESTCHESTER COUNTY to CINCINNATI ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'WESTCHESTER COUNTY' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CINCINNATI' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: when was the last time on 09/21/2105 that patient 006-202432 had an d51/2ns ivf intake? ### 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 = '006-202432')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'd51/2ns ivf' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2105-09-21' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: Before taking ORGSTUDY 201 , what courses must I take ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ORGSTUDY' AND COURSE_1.number = 201
### Instruction: Azure thread volume with accepted answers by month. ### Response:
SELECT COUNT(*) AS AnsweredVolume, TIME_TO_STR(P.CreationDate, '%Y') AS "year", TIME_TO_STR(P.CreationDate, '%m') AS Month FROM Posts AS P WHERE (Tags LIKE '%<azure%' OR Tags LIKE '%<windows-azure%' OR Tags LIKE '%<sql-azure>%' OR Tags LIKE '%<tfs-azure>%' OR Tags LIKE '%<servicebus>%' OR Tags LIKE '%<acs>%' OR Tags LIKE '%<accesscontrolservice>%') AND PostTypeId = 1 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL AND AcceptedAnswerId > 0 GROUP BY TIME_TO_STR(P.CreationDate, '%YEAR'), TIME_TO_STR(P.CreationDate, '%-mONT%-H') ORDER BY 'year', Month
### Instruction: what was the new drug of patient 006-10390 today compared to that yesterday? ### Response:
SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-10390') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') EXCEPT SELECT medication.drugname FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.uniquepid = '006-10390') AND DATETIME(medication.drugstarttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: Avg Q & A AVERAGE SCORES DAILY comparison LAST 12 MONTHS. ### Response:
SELECT CAST(CreationDate AS DATE) AS "date", CAST(SUM(CASE WHEN PostTypeId = 1 THEN Score ELSE 0 END) AS DECIMAL) / SUM(CASE WHEN PostTypeId = 1 THEN 1 ELSE 0 END) AS "q", CAST(SUM(CASE WHEN PostTypeId = 2 THEN Score ELSE 0 END) AS DECIMAL) / SUM(CASE WHEN PostTypeId = 2 THEN 1 ELSE 0 END) AS "a" FROM Posts WHERE CreationDate >= DATEADD(MM, -12, GETDATE()) AND ClosedDate IS NULL AND DeletionDate IS NULL AND CommunityOwnedDate IS NULL GROUP BY CAST(CreationDate AS DATE) ORDER BY CAST(CreationDate AS DATE)
### Instruction: what is the top four most frequent diagnoses for patients aged 60 or above until 3 years ago? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-3 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
### Instruction: flights from NEWARK to CLEVELAND DAILY ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEWARK' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CLEVELAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.flight_days = 'DAILY'
### Instruction: i need a flight from BOS to ATLANTA this afternoon ### Response:
SELECT DISTINCT flight.flight_id FROM airport, airport_service, city, date_day, days, flight WHERE ((city.city_code = airport_service.city_code AND city.city_name = 'ATLANTA' AND date_day.day_number = 5 AND date_day.month_number = 9 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = airport_service.airport_code) AND airport.airport_code = 'BOS' AND flight.from_airport = airport.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
### Instruction: TOP F# users in California. ### Response:
WITH USER_BY_TAG AS (SELECT ROW_NUMBER() OVER (ORDER BY COUNT(*) DESC) AS Rank, u.Id AS "user_link", u.age, 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 '%california%' OR LOWER(Location) LIKE '%, ca') AND Reputation > 1 AND TagName = 'f#' GROUP BY u.Id, TagName, u.age) SELECT * FROM USER_BY_TAG WHERE rank <= 1000 ORDER BY UpVotes DESC
### Instruction: Posts From Between X And Y Days Ago. Query written for the StackExchange Data Explorer that grabs posts from the last X and Y days ago, reputation of posting users, and the upvotes on given posts. ### Response:
SELECT Posts.Id AS PostID, Posts.PostTypeId, Posts.CreationDate, Posts.Score, Posts.ViewCount, Posts.Body, Posts.OwnerUserId, Users.Reputation, Votes.Id AS upvoteID, Votes.CreationDate AS voteDate, Votes.VoteTypeId AS voteTypeID FROM Posts LEFT JOIN Votes ON Posts.Id = Votes.PostId LEFT JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Posts.CreationDate >= CURRENT_TIMESTAMP() - @numDaysBegin AND Posts.CreationDate <= CURRENT_TIMESTAMP() - @numDaysEnd
### Instruction: Tag Wikis I might be able to provide. Takes into account your previous posts/interactions with tags to determine whether you might be able to write a wiki for it. ### Response:
SELECT DISTINCT t.TagName, (CASE WHEN t.WikiPostId IS NULL AND t.ExcerptPostId IS NULL THEN 'No Wiki/NoExcerpt' WHEN t.WikiPostId IS NULL THEN 'No Wiki' WHEN t.ExcerptPostId IS NULL THEN 'No Excerpt' ELSE '???' END) AS "what_is_missing" FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = COALESCE(p.ParentId, p.Id) INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE p.OwnerUserId = '##userid##' AND (t.ExcerptPostId IS NULL OR t.WikiPostId IS NULL)
### Instruction: what is the last value of patient 20034's arterial bp [systolic] on the first intensive care unit visit? ### 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 = 20034) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: Top users with gold js badge. ### Response:
SELECT ('http://stackoverflow.com/users/') + CAST(Users.Id AS TEXT(50)) AS "User Link", Users.WebsiteUrl AS Website, Users.DisplayName AS Name, Users.Location AS Location, Users.Reputation AS Rep FROM Users, Badges WHERE Badges.UserId = Users.Id AND (Badges.Name = 'javascript' OR Badges.Name = 'jquery' OR Badges.Name = 'node.js' OR Badges.Name = 'reactjs' OR Badges.Name = 'angularjs') AND (Badges.Class = 2 OR Badges.Class = 1) GROUP BY ('http://stackoverflow.com/users/') + CAST(Users.Id AS TEXT(50)), Users.WebsiteUrl, Users.DisplayName, Users.Location, Users.Reputation, Users.Age ORDER BY Reputation DESC
### Instruction: what was the daily maximum amount of chest tube #1: given to patient 030-10559 the last month? ### 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 = '030-10559')) AND intakeoutput.celllabel = 'chest tube #1:' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
### Instruction: hello i would like to plan a flight on AA from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
### Instruction: indicate the daily average sao2 of patient 4401 since 05/2102. ### Response:
SELECT AVG(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 = 4401)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sao2' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m', chartevents.charttime) >= '2102-05' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: Among upper level classes , which do not require 662 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, program_course WHERE NOT COURSE_1.course_id IN (SELECT course_prerequisite.pre_course_id FROM course AS COURSE_0, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.course_id) AND COURSE_1.department = 'department0' AND COURSE_1.number = 662 AND PROGRAM_COURSE_0.category LIKE '%ULCS%' AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id
### Instruction: What are the courses that I should take before POLSCI 604 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'POLSCI' AND COURSE_1.number = 604
### Instruction: Group my answers by votes for a given tag. ### Response:
SELECT UpVotes, DownVotes, COUNT(*) AS AnswersCount FROM (SELECT UpVotes, DownVotes FROM (SELECT SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN VoteTypeId = 3 THEN -1 ELSE 0 END) AS DownVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId LEFT JOIN Votes ON Votes.PostId = Posts.Id AND (VoteTypeId = 2 OR VoteTypeId = 3) WHERE Posts.OwnerUserId = @UserId AND Tags.TagName = @TagName GROUP BY Posts.Id) AS UpAndDownVotes) AS VotesCount GROUP BY UpVotes, DownVotes ORDER BY UpVotes DESC
### Instruction: Talent Search Based on Location and Tags. Useful query to find talents around a location with specified skill (via Tags). Returns Users with Age and Location, including Score (question and answer) based on Tags, ordered by Reputation. ### Response:
SELECT u.Id AS "user_link", SUM(Score) AS totalscore FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id OR pt.PostId = p.ParentId INNER JOIN Tags AS t ON t.Id = pt.TagId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE TagName = '##tag1:string##' COLLATE SQL_Latin1_General_CP1_CI_AI AND Location LIKE '%' + '##location:string##' + '%' COLLATE SQL_Latin1_General_CP1_CI_AI GROUP BY u.Id ORDER BY SUM(Score) DESC
### Instruction: Questions (total, answered, unanswered, users) by Year and Month. ### Response:
SELECT DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1) AS ym, COUNT(DISTINCT p.OwnerUserId) AS users, SUM(1) AS total, SUM(CASE WHEN COALESCE(p.AcceptedAnswerId, 0) = 0 THEN 1 ELSE 0 END) AS unanswered, SUM(CASE WHEN COALESCE(p.AcceptedAnswerId, 0) = 0 THEN 0 ELSE 1 END) AS answered FROM Posts AS p GROUP BY DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1) ORDER BY DATEFROMPARTS(YEAR(p.CreationDate), MONTH(p.CreationDate), 1)
### Instruction: tell me about flights from SALT LAKE CITY to ST. PETERSBURG ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SALT LAKE CITY' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. PETERSBURG' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: among the patients of age 60 or above in 2104, what were the top five most frequent diagnoses? ### Response:
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND STRFTIME('%y', diagnoses_icd.charttime) = '2104' GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: when was the last time that arterial bp mean was measured for patient 12927 in yesterday? ### Response:
SELECT chartevents.charttime 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 = 12927)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: Users who downvote more than upvote. With regards to http://meta.stackoverflow.com/questions/175038/users-who-have-downvoted-more-than-they-have-upvoted/ ### Response:
SELECT DownvotesMoreThanUpvotes = COUNT(CASE WHEN DownvotesMoreThanUpvotes = 1 THEN 1 ELSE NULL END), UpvotesMoreThanDownvotes = COUNT(CASE WHEN DownvotesMoreThanUpvotes = 0 THEN 1 ELSE NULL END), TotalUpvotes = SUM(UpVotes), TotalDownvotes = SUM(DownVotes) FROM (SELECT UpVotes, DownVotes, DownvotesMoreThanUpvotes = CAST(CASE WHEN UpVotes <= DownVotes THEN 1 ELSE 0 END AS BIT) FROM Users WHERE Id > 0 AND DownVotes > 0) AS Q
### Instruction: Top Answerers: order by badge, then by score descending. ### Response:
SELECT OwnerUserId AS "user_link", TopBadge, SUM(Score) AS TotalScore, COUNT(*) AS NofAnswers FROM Posts AS P INNER JOIN PostTags AS PT ON PT.PostId = P.ParentId INNER JOIN Tags AS T ON T.Id = PT.TagId INNER JOIN (SELECT UserId, MIN(Class) AS TopBadge FROM Badges AS B WHERE Name = '##TagName##' AND TagBased > 0 GROUP BY UserId) AS BB ON BB.UserId = P.OwnerUserId WHERE T.TagName = '##TagName##' AND NOT P.OwnerUserId IS NULL AND P.CommunityOwnedDate IS NULL AND P.PostTypeId = 2 GROUP BY P.OwnerUserId, TopBadge ORDER BY TopBadge, TotalScore DESC LIMIT 20
### Instruction: Responsive subscribers for a Tag. ### Response:
SELECT TagName, COUNT(Id) AS numUsers FROM (SELECT t.TagName, u.Id FROM Users AS u INNER JOIN Posts AS answer ON u.Id = answer.OwnerUserId INNER JOIN Posts AS question ON answer.ParentId = question.Id INNER JOIN PostTags AS m ON question.Id = m.PostId INNER JOIN Tags AS t ON m.TagId = t.Id WHERE question.CreationDate < '2017-08-01' AND question.CreationDate > '2017-05-01' AND CAST((JULIANDAY(CreationDate) - JULIANDAY(question.CreationDate)) * 24.0 AS INT) <= 1 AND question.AnswerCount > 0 GROUP BY t.TagName, u.Id) AS X GROUP BY TagName ORDER BY numUsers DESC
### Instruction: when was the last time patient 031-4423 had had an intake on 07/07/last year? ### 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 = '031-4423')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '07-07' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: Top tags and their top users. ### Response:
SELECT TagName, 'count', OwnerUserId AS "user_link", Score FROM (SELECT t.TagName, t.Count, a.OwnerUserId, SUM(a.Score) AS Score, RANK() OVER (PARTITION BY t.TagName ORDER BY SUM(a.Score) DESC) AS Rank FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN PostTags AS pt ON q.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE a.PostTypeId = 2 AND a.CommunityOwnedDate IS NULL AND t.Id IN (SELECT TOP(100) AS Id FROM Tags ORDER BY 'count' DESC) GROUP BY t.TagName, t.Count, a.OwnerUserId) AS temp WHERE Rank = 1 ORDER BY 'count' DESC
### Instruction: tell me the monthly average amount of ebl in patient 12410's body until 49 months ago? ### Response:
SELECT AVG(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 = 12410)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'ebl' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime) <= DATETIME(CURRENT_TIME(), '-49 month') GROUP BY STRFTIME('%y-%m', inputevents_cv.charttime)
### Instruction: how many hours have passed since patient 035-24054 had a volume (ml) nicardipine intake for the first time on the current icu visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '035-24054') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'volume (ml) nicardipine' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: how many hours have it been since patient 013-38992 got his first iohexol 350 mg iodine/ml iv soln prescription in the current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '013-38992') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'iohexol 350 mg iodine/ml iv soln' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: List players' first name and last name who received salary from team Washington Nationals in both 2005 and 2007. ### Response:
SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2005 AND T3.name = 'Washington Nationals' INTERSECT SELECT T2.name_first, T2.name_last FROM salary AS T1 JOIN player AS T2 ON T1.player_id = T2.player_id JOIN team AS T3 ON T3.team_id_br = T1.team_id WHERE T1.year = 2007 AND T3.name = 'Washington Nationals'
### Instruction: Suggested edits with review time. ### Response:
SELECT pt.Name, p.Id AS "post_link", 'site://suggested-edits/' + CAST(se.Id AS TEXT) AS "Suggested edit", ROUND(CAST((JULIANDAY(COALESCE(ApprovalDate, RejectionDate)) - JULIANDAY(se.CreationDate)) * 86400.0 AS INT) / 86400., 2) AS "Review time (days)" FROM SuggestedEdits AS se INNER JOIN Posts AS p ON se.PostId = p.Id INNER JOIN PostTypes AS pt ON p.PostTypeId = pt.Id WHERE NOT COALESCE(ApprovalDate, RejectionDate) IS NULL ORDER BY COALESCE(ApprovalDate, RejectionDate) DESC LIMIT 1000
### Instruction: when did patient 029-22492 have for the first time intake of norepinephrine v3-in until 05/04/2103? ### 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 = '029-22492')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'norepinephrine v3-in' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2103-05-04' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: Number of valuable PTIJ posts per year. ### Response:
SELECT TIME_TO_STR(p.CreationDate, '%y') AS year, p.Id, p.Score, p_a.AnswerCount FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND t.TagName = 'purim-torah-in-jest' INNER JOIN (SELECT ParentId, COUNT(p.Id) AS answercount FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id AND t.TagName = 'purim-torah-in-jest' WHERE p.PostTypeId = 2 GROUP BY p.ParentId) AS p_a ON p_a.ParentId = p.Id WHERE p.PostTypeId = 1
### Instruction: what was the maximum arterial bp [diastolic] during the previous day for patient 18866. ### Response:
SELECT MAX(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 = 18866)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day')
### Instruction: Highest scoring questions and answers in each tag. ### Response:
SELECT TagName, QuestionID AS "post_link", q_.Score AS "q_score", AnswerID AS "post_link", a_.Score AS "a_score" FROM (SELECT TagName, (SELECT q.Id FROM Posts AS q INNER JOIN PostTags AS qt ON q.Id = qt.PostId WHERE qt.TagId = t.Id ORDER BY q.Score DESC LIMIT 1) AS QuestionID, (SELECT a.Id FROM Posts AS a INNER JOIN PostTags AS at ON a.ParentId = at.PostId WHERE at.TagId = t.Id ORDER BY a.Score DESC LIMIT 1) AS AnswerID FROM Tags AS t) AS temp INNER JOIN Posts AS q_ ON temp.QuestionId = q_.Id LEFT OUTER JOIN Posts AS a_ ON temp.AnswerId = a_.Id ORDER BY q_.Score DESC
### Instruction: i want to fly from DALLAS FORT WORTH to PHILADELPHIA ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DALLAS FORT WORTH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: how many days has it elapsed since patient 97395 was last diagnosed with ac/chr syst/dia hrt fail during this hospital encounter? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnoses_icd.charttime)) FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'ac/chr syst/dia hrt fail') AND diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97395 AND admissions.dischtime IS NULL) ORDER BY diagnoses_icd.charttime DESC LIMIT 1
### Instruction: how many hours has it been since the first intake of fat emulsion 20% for patient 022-187132 on the current icu visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '022-187132') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'fat emulsion 20%' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: give me nonstop flights from NEW YORK to LAS VEGAS ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEW YORK' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'LAS VEGAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
### Instruction: Average wait time for question being answered based on hour of asking. ### Response:
SELECT TIME_TO_STR(QuestionWithT.CDate, '%-HOUR') AS AskingHour, AVG(QuestionWithT.T) AS AvgWaitTimeForFirstResponse FROM (SELECT Question.Id AS Id, MIN(Question.CreationDate) AS CDate, MIN(CAST((JULIANDAY(CreationDate) - JULIANDAY(Question.CreationDate)) * 1440.0 AS INT)) / (24.0 * 60) AS T FROM Posts AS Question, Posts AS Answer WHERE Answer.ParentId = Question.Id AND Question.PostTypeId = 1 AND Answer.PostTypeId = 2 GROUP BY Question.Id) AS QuestionWithT GROUP BY TIME_TO_STR(QuestionWithT.CDate, '%-HOUR')
### Instruction: what flights are there from NEWARK to CHICAGO on CO ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CHICAGO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEWARK' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'CO'
### Instruction: posts closed in sep, oct, or nov, with reasons. ### Response:
SELECT YEAR(Posts.ClosedDate) AS y, MONTH(Posts.ClosedDate) AS m, CAST(YEAR(Posts.ClosedDate) AS TEXT(10)) + '/' + CAST(MONTH(Posts.ClosedDate) AS TEXT(19)) AS ym, COUNT(CONCAT('http://programmers.stackexchange.com/q/', Posts.Id)) AS Questions FROM PostHistory JOIN Posts ON Posts.Id = PostHistory.PostId WHERE Posts.ClosedDate >= '2012-01-01' AND PostHistoryTypeId = 10 AND PostHistory.Comment != 1 GROUP BY YEAR(Posts.ClosedDate), MONTH(Posts.ClosedDate) ORDER BY 1 DESC, 2 DESC
### Instruction: where were the top three most frequent procedures in the patients of age 30s in 2100? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND STRFTIME('%y', procedures_icd.charttime) = '2100' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: What upper level classes is 550 not mandatory for ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, program_course WHERE NOT COURSE_1.course_id IN (SELECT course_prerequisite.pre_course_id FROM course AS COURSE_0, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.course_id) AND COURSE_1.department = 'EECS' AND COURSE_1.number = 550 AND PROGRAM_COURSE_0.category LIKE '%ULCS%' AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id
### Instruction: indicate the yearly minimum volume of chest tube output: pleural anterior that patient 016-18575 has had since 980 days ago. ### 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 = '016-18575')) AND intakeoutput.celllabel = 'chest tube output: pleural anterior' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-980 day') GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
### Instruction: Which upper level classes don 't require 353 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, program_course WHERE NOT COURSE_1.course_id IN (SELECT course_prerequisite.pre_course_id FROM course AS COURSE_0, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.course_id) AND COURSE_1.department = 'department0' AND COURSE_1.number = 353 AND PROGRAM_COURSE_0.category LIKE '%ULCS%' AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id
### Instruction: what is the name of a procedure patient 73713 undergone two times since 5 months ago? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, COUNT(procedures_icd.charttime) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-5 month') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 = 2)
### Instruction: what's the first value of the sao2 of patient 028-45936 on 05/18/this year? ### Response:
SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-45936')) AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '05-18' ORDER BY vitalperiodic.observationtime LIMIT 1
### Instruction: what was the name of the output, which patient 017-61209 had first on 06/09/last year? ### 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 = '017-61209')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '06-09' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: what are the five most frequently ordered procedures for patients in the age 30s until 2104? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND STRFTIME('%y', procedures_icd.charttime) <= '2104' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: show me all the UA flights from BOSTON to DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
### Instruction: when did patient 1784 have for the last time intake of d5/.45ns today? ### Response:
SELECT inputevents_cv.charttime FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1784)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5/.45ns' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY inputevents_cv.charttime DESC LIMIT 1
### Instruction: Prior to taking ROMLANG 250 what courses do I need to take ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ROMLANG' AND COURSE_1.number = 250
### Instruction: what was the last intake that patient 005-87465 had received on 12/30/this year? ### 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 = '005-87465')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '12-30' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: Before taking ENSCEN 171 do I need to take any courses ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'ENSCEN' AND COURSE_1.number = 171
### Instruction: what is the daily average amount of the drain out #1 jackson pratt of patient 20251 until 17 months ago? ### Response:
SELECT AVG(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20251)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'drain out #1 jackson pratt' AND d_items.linksto = 'outputevents') AND DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-17 month') GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
### Instruction: what is the last thing patient 10211 had for intake on 04/05/last year? ### 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 = 10211)) AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '04-05' ORDER BY inputevents_cv.charttime DESC LIMIT 1)
### Instruction: let's count the number of times patient 008-26792 has had a output (ml)-urethral catheter straight-tip 16 fr. output on 07/23/2103. ### Response:
SELECT COUNT(*) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-26792')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output (ml)-urethral catheter straight-tip 16 fr.' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) = '2103-07-23'
### Instruction: give me the list of flights for CO between DENVER and BOSTON ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'CO'
### Instruction: Which upper level classes do n't require 521 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, program_course WHERE NOT COURSE_1.course_id IN (SELECT course_prerequisite.pre_course_id FROM course AS COURSE_0, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.course_id) AND COURSE_1.department = 'EECS' AND COURSE_1.number = 521 AND PROGRAM_COURSE_0.category LIKE '%ULCS%' AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id
### Instruction: Which upper level classes don 't need 381 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite, program_course WHERE NOT COURSE_1.course_id IN (SELECT course_prerequisite.pre_course_id FROM course AS COURSE_0, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.course_id) AND COURSE_1.department = 'department0' AND COURSE_1.number = 381 AND PROGRAM_COURSE_0.category LIKE '%ULCS%' AND PROGRAM_COURSE_0.course_id = COURSE_0.course_id
### Instruction: Tag synonym suggestions: Tag pairs with significant overlap / redundancy / clustering. ### Response:
WITH TagsAndRanks AS (SELECT Id, TagName, Count, RANK() OVER (ORDER BY Count DESC, TagName) AS CountRank FROM Tags), TagPairs AS (SELECT A.Id AS AId, A.TagName AS ATagName, A.Count AS ACount, B.Id AS BId, B.TagName AS BTagName, B.Count AS BCount FROM TagsAndRanks AS A, TagsAndRanks AS B WHERE A.CountRank < B.CountRank), PostsWITHBothTags AS (SELECT TagId, COUNT(PostId) AS Count FROM PostTags JOIN TagPairs ON PostTags.TagId = TagPairs.AId AND PostTags.TagId = TagPairs.BId GROUP BY TagId) SELECT * FROM PostsWITHBothTags ORDER BY Count DESC
### Instruction: tell me the percentile of mcv 97.0 in patients of the same age as patient 2127 during the last hospital visit? ### Response:
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'mcv') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 2127 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1))) AS t1 WHERE t1.valuenum = 97.0
### Instruction: did patient 18866 have a respiratory rate that was greater than 12.0 in 12/2105? ### Response:
SELECT COUNT(*) > 0 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 = 18866)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'respiratory rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 12.0 AND STRFTIME('%y-%m', chartevents.charttime) = '2105-12'
### Instruction: does YX serve CLEVELAND ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE ((flight.to_airport = AIRPORT_SERVICE_0.airport_code AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CLEVELAND') OR (flight.from_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CLEVELAND')) AND flight.airline_code = 'YX'
### Instruction: how many days have passed since patient 015-23047 received enteral jevity 1.5 for the first time in the on the current icu visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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-23047') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'enteral jevity 1.5' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: i was wondering what patient 15754's average value of temperature c (calc) on 09/05/2104 was? ### Response:
SELECT AVG(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 = 15754)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) = '2104-09-05'
### Instruction: what is patient 23969's first arterial bp [systolic] on the last intensive care unit visit? ### 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 = 23969) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime LIMIT 1
### Instruction: how many hours have elapsed since patient 027-142451 first received an intake of continuous infusion meds on the current intensive care unit visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '027-142451') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'continuous infusion meds' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: Median response time by tag (for any answer) - iOS- Initial Year. ### Response:
WITH my_table AS (SELECT T.TagName, CAST((JULIANDAY(CreationDate) - JULIANDAY(P.CreationDate)) * 1440.0 AS INT) AS ResponseMinutes FROM Posts AS P INNER JOIN Posts AS A ON P.AcceptedAnswerId = A.Id INNER JOIN PostTags AS PT ON P.Id = PT.PostId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE P.PostTypeId = 1 AND (T.TagName LIKE '%windows-phone%') AND p.AnswerCount > 0) SELECT DISTINCT TagName, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ResponseMinutes) OVER (PARTITION BY TagName) AS Median FROM my_table
### Instruction: Top langs vs C, Python, JavaScript, Java & Rust average question score. ### Response:
SELECT CASE WHEN Tags LIKE '%<c>%' THEN 'C' WHEN Tags LIKE '%<python>%' THEN 'Python' WHEN Tags LIKE '%<javascript>%' THEN 'JavaScript' WHEN Tags LIKE '%<java>%' THEN 'Java' WHEN Tags LIKE '%<rust>%' THEN 'Rust' ELSE 'Anything else' END AS Language, AVG(CAST(Score AS FLOAT)) AS "average_score", COUNT(*) AS "n_questions" FROM Posts WHERE PostTypeId = 1 GROUP BY CASE WHEN Tags LIKE '%<c>%' THEN 'C' WHEN Tags LIKE '%<python>%' THEN 'Python' WHEN Tags LIKE '%<javascript>%' THEN 'JavaScript' WHEN Tags LIKE '%<java>%' THEN 'Java' WHEN Tags LIKE '%<rust>%' THEN 'Rust' ELSE 'Anything else' END
### Instruction: Can you suggest some web technology courses that are easier than AEROSP 550 ? ### Response:
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE area.area LIKE '%web technology%' AND program_course.workload < (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM course AS COURSEalias1 INNER JOIN program_course AS PROGRAM_COURSEalias1 ON PROGRAM_COURSEalias1.course_id = COURSEalias1.course_id WHERE COURSEalias1.department = 'AEROSP' AND COURSEalias1.number = 550) ORDER BY program_course.workload
### Instruction: please list the flight times from BOSTON to PITTSBURGH ### Response:
SELECT DISTINCT flight.arrival_time, flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: i mean what was the last temperature c (calc) for patient 4401 during the previous day? ### 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 = 4401)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'temperature c (calc)' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: when was the first time patient 029-23889 systemicdiastolic was measured greater than 63.0 on 07/03/2103. ### 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 = '029-23889')) AND vitalperiodic.systemicdiastolic > 63.0 AND NOT vitalperiodic.systemicdiastolic IS NULL AND STRFTIME('%y-%m-%d', vitalperiodic.observationtime) = '2103-07-03' ORDER BY vitalperiodic.observationtime LIMIT 1
### Instruction: count the number of patients who received normal saline administration procedure in the same month after having received cardiac surgery consultation procedure. ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'cardiac surgery consultation') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'normal saline administration') AS t2 WHERE t1.treatmenttime < t2.treatmenttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month')
### Instruction: what was the number of times hydromorphone 1 mg/1 ml syr was prescribed for patient 030-53416 in 06/this year? ### 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 = '030-53416')) AND medication.drugname = 'hydromorphone 1 mg/1 ml syr' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '06'
### Instruction: what were the five most frequently ordered procedures for patients of age 40s since 2103? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND STRFTIME('%y', procedures_icd.charttime) >= '2103' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: what are the four most frequently performed procedures for patients of the 40s in 2104? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND STRFTIME('%y', procedures_icd.charttime) = '2104' GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
### Instruction: What other classes must I take prior to studying MUSED 595 ? ### Response:
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT_RECORDalias0.student_id = 1) AND COURSE_1.course_id = course_prerequisite.course_id AND COURSE_1.department = 'MUSED' AND COURSE_1.number = 595
### Instruction: what was the first time patient 027-203413 has had the maximum respiration on this month/25? ### 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 = '027-203413')) AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '25' ORDER BY vitalperiodic.respiration DESC, vitalperiodic.observationtime LIMIT 1