instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: Bad' questions from new users in 2013-2014. ### Response:
SELECT DATEADD(month, DATEDIFF(month, @epoch, CreationDate), @epoch) AS Month, IIF(q.DeletionDate IS NULL AND q.ClosedDate IS NULL, 'good', 'bad') AS quality, COUNT(*) AS questions FROM Users AS u JOIN Posts AS q ON OwnerUserId = u.Id AND DATEDIFF(month, @epoch, CreationDate) < DATEDIFF(month, @epoch, CreationDate) + 2 AND PostTypeId = 1 WHERE u.CreationDate BETWEEN 'January 1, 2013' AND 'January 1, 2015' GROUP BY DATEDIFF(month, @epoch, CreationDate), IIF(q.DeletionDate IS NULL AND q.ClosedDate IS NULL, 'good', 'bad') ORDER BY Month, quality DESC
### Instruction: list all flights arriving in DENVER between 2000 and 2100 ### 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.arrival_time <= 2100 AND flight.arrival_time >= 2000) OR flight.arrival_time = arrival_time2) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: Language trends (# of Question Views per Month). ### Response:
SELECT DATEADD(mm, (YEAR(Posts.CreationDate) - 1900) * 12 + MONTH(Posts.CreationDate) - 1, 0) AS Month, Tags.TagName, SUM(Posts.ViewCount) AS Views FROM Tags LEFT JOIN PostTags ON PostTags.TagId = Tags.Id LEFT JOIN Posts ON Posts.Id = PostTags.PostId LEFT JOIN PostTypes ON PostTypes.Id = Posts.PostTypeId WHERE Tags.TagName IN ('ruby') AND PostTypes.Name = 'Question' AND Posts.CreationDate < DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0) GROUP BY YEAR(Posts.CreationDate), MONTH(Posts.CreationDate), Tags.TagName ORDER BY YEAR(Posts.CreationDate), MONTH(Posts.CreationDate), Tags.TagName
### Instruction: When post my question to maximize the answers?. ### Response:
WITH AnswersPerQuestion(IdQuestion, NbAnswers, DayInWeek) AS (SELECT p1.Id AS IdQuestion, COUNT(p2.Id) AS NbAnswers, TIME_TO_STR(p1.CreationDate, 'WEEKDA%Y') AS DayInWeek FROM Posts AS p1 JOIN Posts AS p2 ON p1.Id = p2.ParentId WHERE p1.PostTypeId = 1 AND p2.PostTypeId = 2 GROUP BY p1.Id, TIME_TO_STR(p1.CreationDate, 'WEEKDA%Y'), TIME_TO_STR(p1.CreationDate, 'WEEKDA%Y')) SELECT DayInWeek, AVG(CAST(NbAnswers AS FLOAT)) AS avgAnswers FROM AnswersPerQuestion AS a GROUP BY DayInWeek ORDER BY avgAnswers DESC
### Instruction: When does Stephen Rassi teach 841 again ? ### Response:
SELECT DISTINCT semester.semester, semester.year FROM course, course_offering, instructor, offering_instructor, semester WHERE course.course_id = course_offering.course_id AND course.number = 841 AND course_offering.semester = semester.semester_id AND instructor.name LIKE '%Stephen Rassi%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_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: Reputation Gained until a Certain Date. ### Response:
SELECT SUM((CASE WHEN (p.PostTypeId = 1 AND v.VoteTypeId = 2 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN 5 WHEN (p.PostTypeId = 2 AND v.VoteTypeId = 2 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN 10 WHEN (v.VoteTypeId = 3 AND (p.CommunityOwnedDate > v.CreationDate OR p.CommunityOwnedDate IS NULL)) THEN -2 ELSE 0 END)) AS ReputationFromVotes, v.CreationDate AS VoteDate FROM Posts AS p INNER JOIN Votes AS v ON v.PostId = p.Id WHERE p.OwnerUserId = '##UserId##' GROUP BY v.CreationDate
### Instruction: indicate the daily maximum arterial bp [systolic] of patient 17667 in this month. ### 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 = 17667)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: when was the last time on 06/22/last year that patient 006-50368's respiration was measured greater than 17.0? ### Response:
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-50368')) AND vitalperiodic.respiration > 17.0 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) = '06-22' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
### Instruction: afternoon flights from BOSTON to SAN FRANCISCO please that leave in the afternoon ### 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.departure_time BETWEEN 1200 AND 1800
### Instruction: when did patient 030-47098 get the volume (ml)-potassium chloride 10 meq in 100 ml ivpb first time until 1235 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 = '030-47098')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'volume (ml)-potassium chloride 10 meq in 100 ml ivpb' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1235 day') ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: have acetaminophen, 50 ml vial : dextrose 50 % iv soln, or acetaminophen (tylenol) tablet 650 mg been prescribed for patient 022-89058 in their first hospital visit? ### Response:
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-89058' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND medication.drugname IN ('acetaminophen', '50 ml vial : dextrose 50 % iv soln', 'acetaminophen (tylenol) tablet 650 mg')
### Instruction: (EXAMPLE #2) Time to First Answer (Link to Q using [Post Link]). ### Response:
SELECT q.Id AS "qid", q.Id AS "post_link", q.CreationDate AS "question_date", MIN(a.CreationDate) AS "1st_answer_date", DATEDIFF(n, q.CreationDate, MIN(a.CreationDate)) AS "min_to_1st_answer" FROM Posts AS q LEFT OUTER JOIN Posts AS a ON q.Id = a.ParentId WHERE q.PostTypeId = 1 AND (a.PostTypeId = 2 OR a.PostTypeId IS NULL) AND q.DeletionDate IS NULL AND a.DeletionDate IS NULL AND q.ClosedDate IS NULL AND a.ClosedDate IS NULL AND q.CreationDate >= DATEADD(d, 30, GETDATE()) GROUP BY q.Id, q.CreationDate ORDER BY q.CreationDate
### Instruction: show morning flights from SAN FRANCISCO to PITTSBURGH ### 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 = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
### Instruction: Are posts better/more popular if they have a tag in their title?. ### Response:
SELECT COUNT(*) AS Number, AVG(p.ViewCount) AS Views, ROUND(AVG(CAST(p.Score AS FLOAT)), 3) AS Score, ROUND(AVG(CAST(p.AnswerCount AS FLOAT)), 3) AS AnswerCount, CAST(AVG(CAST(p.CreationDate AS FLOAT)) AS DATETIME) AS AvgDate, CASE WHEN LOWER(p.Title) LIKE '%##TagName##%' THEN 'yes' ELSE 'no' END AS TagInTitle FROM Posts AS p 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 = '##TagName##' GROUP BY CASE WHEN LOWER(p.Title) LIKE '%##TagName##%' THEN 'yes' ELSE 'no' END
### Instruction: does arterial bp [systolic] of patient 17667 be normal during this month? ### 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 = 17667)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN systolic_bp_lower AND systolic_bp_upper AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
### Instruction: provide the monthly average amount of enteral/gastric tube intake #1 that patient 006-188114 has received until 12/15/2105. ### 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 = '006-188114')) AND intakeoutput.celllabel = 'enteral/gastric tube intake #1' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-12-15' GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
### Instruction: does UA fly from DENVER to BALTIMORE ### Response:
SELECT DISTINCT airline.airline_code FROM airline, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE ((flight.airline_code = 'UA') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: what flights leaving PITTSBURGH arrive in DENVER and leave after say 1800 o'clock at night ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.departure_time > 1800 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: when was the first time in which patient 19412 had the maximum arterial bp [diastolic] today? ### 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 = 19412)) 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', '-0 day') ORDER BY chartevents.valuenum DESC, chartevents.charttime LIMIT 1
### Instruction: Get quarterly breakdown of answered/unanswered questions for a tag. ### Response:
SELECT DATEADD(quarter, DATEDIFF(quarter, 0, CreationDate), 0) AS quart, COUNT(p.Id) AS total_posts, SUM(CASE WHEN p.PostTypeId = 1 THEN 1 ELSE 0 END) AS questions, SUM(CASE WHEN p.PostTypeId = 2 THEN 1 ELSE 0 END) AS answers, SUM(CASE WHEN p.PostTypeId = 1 AND NOT p.AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS answered, SUM(CASE WHEN p.PostTypeId = 1 AND p.AcceptedAnswerId IS NULL THEN 1 ELSE 0 END) AS unanswered FROM Posts AS p INNER JOIN PostTags AS pt ON pt.TagId = @TagId WHERE pt.PostId = p.Id GROUP BY DATEADD(quarter, DATEDIFF(quarter, 0, CreationDate), 0)
### Instruction: what airlines from WASHINGTON DC to COLUMBUS ### Response:
SELECT DISTINCT airline.airline_code FROM airline, 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 = 'WASHINGTON' AND CITY_0.state_code = 'DC' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'COLUMBUS' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Upvote/Downvote ratio for the users over a rep limit. ### Response:
WITH Raw AS (SELECT Posts.OwnerUserId AS UserId, MIN(Users.Reputation) AS Reputation, COUNT(CASE WHEN Votes.VoteTypeId = 2 THEN 1 ELSE NULL END) AS UpVotes, COUNT(*) AS AllVotes FROM Users, Posts, Votes WHERE Users.Reputation >= '##MinRep:int?3000##' AND Votes.PostId = Posts.Id AND Posts.PostTypeId = 2 AND Posts.OwnerUserId = Users.Id AND Votes.VoteTypeId IN (2, 3) GROUP BY Posts.OwnerUserId) SELECT UserId AS "user_link", UserId, Reputation, UpVotes, AllVotes - UpVotes AS DownVotes, 100.0 * UpVotes / AllVotes AS UpVotePct FROM Raw ORDER BY UpVotePct DESC, UserId
### Instruction: indicate the yearly maximum amount of arterial bp [systolic] for patient 462 until 08/01/2105. ### 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 = 462)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) <= '2105-08-01' GROUP BY STRFTIME('%y', chartevents.charttime)
### Instruction: how many patients were prescribed with percocet 5/325 tab in the same hospital encounter after the procedure of sedative agent? ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'sedative agent') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'percocet 5/325 tab') AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
### Instruction: list nonstop flights from BURBANK to DENVER arriving by 1800 ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.arrival_time <= 1800 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BURBANK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.stops = 0
### Instruction: users whose first question was closed but still had multiple posts. ### Response:
SELECT sq.count, COUNT(DISTINCT sq.user) FROM (SELECT sq.user, CASE WHEN COUNT(DISTINCT Posts.Id) = 1 THEN '1' ELSE '>1' END AS count FROM (SELECT sq.user FROM (SELECT Users.Id AS "user", Posts.Id AS first_post, Posts.ClosedDate, ROW_NUMBER() OVER (PARTITION BY Users.Id ORDER BY Posts.CreationDate) AS rn FROM Users INNER JOIN Posts ON Posts.OwnerUserId = Users.Id WHERE Posts.PostTypeId = 1) AS sq INNER JOIN PostHistory ON sq.first_post = PostHistory.PostId WHERE PostHistory.PostHistoryTypeId = 10 AND sq.rn = 1) AS sq INNER JOIN Posts ON Posts.OwnerUserId = sq.user GROUP BY sq.user) AS sq GROUP BY sq.count ORDER BY sq.count
### Instruction: Table of population as a function of number of votes on the post. https://chat.stackexchange.com/transcript/message/49612762#49612762 ### Response:
SELECT A.Count AS "Votes", COUNT(*) AS "Count", ROUND(COUNT(*) / (CAST(B.Total AS FLOAT)) * 100, 5) AS "%age" FROM (SELECT COUNT(*) AS "Count" FROM Posts JOIN Votes ON Votes.PostId = Posts.Id WHERE Votes.VoteTypeId = 2 OR Votes.VoteTypeId = 3 GROUP BY Posts.Id) AS A JOIN (SELECT COUNT(*) AS "Total" FROM Posts WHERE Posts.PostTypeId = 1 OR Posts.PostTypeId = 2 OR Posts.PostTypeId = 3) AS B ON 1 = 1 GROUP BY A.Count, B.Total ORDER BY '%age' DESC, 'Votes' DESC
### Instruction: Which of my answers have helped the Internet?. Shows you questions that you've answered that have significant view counts. ### Response:
SELECT q.ViewCount AS "views", ROUND(q.ViewCount / q.AnswerCount, 2) AS "views_per_answer", q.AnswerCount AS "answer_count", q.Id AS "post_link", a.Score AS "answer_score", (CASE WHEN q.AcceptedAnswerId = a.Id THEN 'Yes' ELSE NULL END) AS "accepted", FLOOR((TIME_TO_STR(q.CreationDate, '%-HOUR') * 60 + TIME_TO_STR(q.CreationDate, '%-mINUTE')) / 15) / 4.0 AS QD FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId WHERE a.OwnerUserId = '##UserId:int##' ORDER BY 'views_per_answer' DESC LIMIT 100
### Instruction: hi i need to get a flight from MEMPHIS to SALT LAKE CITY departing before 1000 ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' AND flight.departure_time < 1000 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MEMPHIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: what afternoon flights are available from ATLANTA 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 = 'ATLANTA' 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.departure_time BETWEEN 1200 AND 1800
### Instruction: find f# with two other tags. ### Response:
SELECT DISTINCT p.Id AS "post_link", p.CreationDate AS "date" FROM Posts AS p INNER JOIN Posts AS q ON q.Id = COALESCE(p.ParentId, p.Id) INNER JOIN PostTypes AS pt ON pt.Id = p.PostTypeId INNER JOIN PostTags AS pta ON pta.PostId = q.Id INNER JOIN Tags AS ta ON ta.Id = pta.TagId INNER JOIN PostTags AS pto ON pto.PostId = q.Id INNER JOIN Tags AS tor ON tor.Id = pto.TagId WHERE ta.TagName = 'ribbon' AND tor.TagName IN ('spring', 'spring-cloud', 'spring-boot', 'netflix-zuul', 'eureka', 'netflix-eureka', 'netflix', 'cloud', 'hystrix') AND p.PostTypeId = 1 ORDER BY p.CreationDate DESC
### Instruction: which airlines have flights between PHILADELPHIA and PITTSBURGH ### Response:
SELECT DISTINCT airline.airline_code FROM airline, 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 = 'PITTSBURGH' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
### Instruction: Top ColdFusion users in Colorado. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY tuser.TagScore DESC) AS "#", Id AS "user_link", Reputation, tuser.TagScore AS "tag_score" FROM Users JOIN (SELECT Answers.OwnerUserId AS UserId, SUM(Answers.Score) AS TagScore FROM Tags JOIN PostTags ON Tags.Id = PostTags.TagId JOIN Posts ON Posts.Id = PostTags.PostId JOIN Posts AS Answers ON Answers.ParentId = Posts.Id WHERE LOWER(Tags.TagName) LIKE '%cold%' GROUP BY Answers.OwnerUserId) AS tuser ON tuser.UserId = Users.Id WHERE (Location LIKE '%CO%' OR Location LIKE '%,co%' OR Location LIKE '%,Co%' OR AboutMe LIKE '%Colorado%' OR Location LIKE '%, co%' OR Location LIKE '%, Co%') AND NOT Location LIKE '%Columbia%' ORDER BY tuser.TagScore DESC
### Instruction: show me the evening flights from PHILADELPHIA to ATLANTA ### 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 = 'ATLANTA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
### Instruction: what was patient 11362's last time of taking tpn on last month/24? ### 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 = 11362)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', inputevents_cv.charttime) = '24' ORDER BY inputevents_cv.charttime DESC LIMIT 1
### Instruction: Top users on tag within a location. ### Response:
WITH tagscores AS (SELECT p.OwnerUserId AS UserId, t.TagName, COUNT(p.Id) AS NumAnswers, SUM(p.Score) AS TotalScore FROM Posts AS p INNER JOIN PostTags AS pt ON p.ParentId = pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id INNER JOIN PostTypes AS py ON p.PostTypeId = py.Id WHERE t.TagName LIKE '%##TagName##%' AND py.Name = 'Answer' AND p.CommunityOwnedDate IS NULL GROUP BY t.TagName, p.OwnerUserId) SELECT Users.Id AS "user_link", Users.Location, Users.Reputation, tagscores.TagName, tagscores.NumAnswers, tagscores.TotalScore FROM Users INNER JOIN tagscores ON Users.Id = tagscores.UserID WHERE Users.Location LIKE '%##Location##%' ORDER BY tagscores.TotalScore DESC
### Instruction: what was the last height of patient 13622 in 08/last year. ### 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 = 13622)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', chartevents.charttime) = '08' ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: What day of the week are most bounties offered?. You probably won't be surprised by the result! ### Response:
SELECT SUM(Score) AS upvotes, COUNT(*) AS totalQuestions, (CAST(SUM((Score * 1.0) / (ViewCount * 1.0)) AS FLOAT) / CAST(COUNT(*) AS FLOAT)) AS average, CASE (TIME_TO_STR(CreationDate, '%W') + @@DATEFIRST) % 7 WHEN 1 THEN 'Sunday' WHEN 2 THEN 'Monday' WHEN 3 THEN 'Tuesday' WHEN 4 THEN 'Wednesday' WHEN 5 THEN 'Thursday' WHEN 6 THEN 'Friday' WHEN 0 THEN 'Saturday' END AS Weekday FROM Posts WHERE PostTypeId = 1 AND CreationDate > '01-01-2014' GROUP BY TIME_TO_STR(CreationDate, '%W')
### Instruction: Avance to Explainer / Refiner / Illuminator Badge. Avance to Explainer / Refiner / Illuminator Badge ### Response:
SELECT a.OwnerUserId AS "user_link", COUNT(PostId) AS "answer_edits" FROM Posts AS q JOIN PostHistory AS e ON PostId = q.Id JOIN Posts AS a ON a.ParentId = q.Id AND COALESCE(q.OwnerUserId, -1) != a.OwnerUserId AND UserId = a.OwnerUserId AND ABS(CAST((JULIANDAY(CreationDate) - JULIANDAY(a.CreationDate)) * 24.0 AS INT)) < 12 WHERE PostHistoryTypeId IN (4, 5) AND q.PostTypeId = 1 AND a.PostTypeId = 2 AND a.Score >= 1 AND a.OwnerUserId = '##userid##' GROUP BY a.OwnerUserId
### Instruction: what was the last height of patient 14671 in 12/this year. ### 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 = 14671)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', chartevents.charttime) = '12' ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: for the patients with age 20s what are the top three most frequent diagnoses in this year? ### 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 BETWEEN 20 AND 29) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
### Instruction: H-index (based on answer scores) ranking. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY MAX(H.Score) DESC) AS "#", H.OwnerUserId AS "user_link", MAX(H.Score) AS HIndex FROM (SELECT S.OwnerUserId, S.Score, SUM(S.NumAnswers) OVER (PARTITION BY S.OwnerUserId ORDER BY S.Score DESC rows BETWEEN unbounded preceding AND CURRENT ROW) AS NumAnswersCumul FROM (SELECT P.OwnerUserId, P.Score, COUNT(*) AS NumAnswers FROM Posts AS P WHERE P.PostTypeId = 2 AND P.Score >= 4 AND NOT P.OwnerUserId IS NULL GROUP BY P.OwnerUserId, P.Score) AS S) AS H WHERE H.NumAnswersCumul >= H.Score AND H.Score = 4 GROUP BY H.OwnerUserId ORDER BY 'user_link' DESC
### Instruction: How close am I to the Sportsmanship Badge. Posts that allow you to get the sportsmanship badge by voting on them. This gives you an idea if you can even get this badge. It is not possible to show your progress toward the badge because the data is cleansed of any upvote information tied to a userId. This gives you a list of answers you can upvote (if you like them). If there is not 100 items in this list, you can't get the badge. ### Response:
WITH CandidatePosts AS (SELECT ParentId AS postId FROM Posts AS p WHERE p.OwnerUserId = '##UserId##' AND p.PostTypeId = 2 AND p.Score > 0) SELECT DISTINCT p1.ParentId AS "post_link" FROM Posts AS p1 JOIN CandidatePosts AS cp ON cp.postId = p1.ParentId WHERE p1.OwnerUserId != '##UserId##'
### Instruction: when did patient 025-19271 receive a urine, catheter specimen microbiology test last in 09/this year? ### 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 = '025-19271')) AND microlab.culturesite = 'urine, catheter specimen' AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', microlab.culturetakentime) = '09' ORDER BY microlab.culturetakentime DESC LIMIT 1
### Instruction: Questions kept alive by your comments. These questions would be automatically deleted by the RemoveAbandonedQuestions job, if they didn't have at least two comments. Some of these comments were written by you (or by the user whose user ID you've entered below, if not your own). If the feature request at http://meta.stackoverflow.com/q/333477 passes, these questions will be deleted. Would you like to convert any of your comments into answers before that happens? ### Response:
SELECT Posts.Id AS "post_link", Posts.Score AS PostScore, Posts.ViewCount AS PostViews, Posts.CreationDate AS PostDate, Posts.CommentCount AS PostComments FROM Posts WHERE Posts.PostTypeId = 1 AND Posts.Score = 1 AND Posts.AnswerCount = 0 AND Posts.CommentCount > '##commentCount:int##' AND Posts.Tags LIKE '%<' + '##tag:string##' + '>%'
### Instruction: tell me the top five most frequent diagnoses for patients of age 40s in the previous year? ### 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 BETWEEN 40 AND 49) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: on a flight from SAN FRANCISCO to ATLANTA that leaves before 800 is there such a flight ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND flight.departure_time < 800 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: when was the first time that patient 004-2373 has a nutrition total intake on 07/02/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 = '004-2373')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'nutrition total' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '07-02' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
### Instruction: what is the monthly average dose of enteral formula volume/bolus amt (ml) that patient 025-44842 takes since 12/30/2105? ### 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 = '025-44842')) AND intakeoutput.celllabel = 'enteral formula volume/bolus amt (ml)' AND intakeoutput.cellpath LIKE '%intake%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2105-12-30' GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
### Instruction: Gold badges by people who have less than a given amount of reputation. Lists all the gold badges that have been earned by people with less than a given amount of reputation (default: 1k), and displays the number of times each has been awarded to the aforementioned users. ### Response:
SELECT b.Name AS "badge_name", COUNT(*) AS "count" FROM Badges AS b INNER JOIN Users AS u ON b.UserId = u.Id WHERE u.Reputation < '##rep:int?1000##' AND b.Name IN ('Socratic', 'Stellar Question', 'Great Question', 'Famous Question', 'Illuminator', 'Great Answer', 'Populist', 'Reversal', 'Unsung Hero', 'Fanatic', 'Legendary', 'Marshal', 'Constable', 'Sheriff', 'Steward', 'Copy Editor', 'Electorate', 'Publicist') GROUP BY b.Name ORDER BY COUNT(*) DESC
### Instruction: what was the last height of patient 26817 in 10/this year? ### 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 = 26817)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit ht' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', chartevents.charttime) = '10' ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: when was the first time patient 006-159173 was measured heartrate less than 90.0 on 09/05/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 = '006-159173')) AND vitalperiodic.heartrate < 90.0 AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '09-05' ORDER BY vitalperiodic.observationtime LIMIT 1
### Instruction: show me flights from BALTIMORE to PHILADELPHIA arriving after 2100 ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.arrival_time > 2100 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: what are the four most common diagnosis of patients with age 40s during a year before? ### 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 BETWEEN 40 AND 49) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
### Instruction: flights from WESTCHESTER COUNTY to SAN FRANCISCO 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 = 'WESTCHESTER COUNTY' 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.flight_days = 'DAILY'
### Instruction: provide the daily minimum amount of enfamiladdedrice po that patient 15794 has received since 06/20/2104. ### Response:
SELECT MIN(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 = 15794)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'enfamiladdedrice po' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) >= '2104-06-20' GROUP BY STRFTIME('%y-%m-%d', inputevents_cv.charttime)
### Instruction: calculate the total amount of per iv flush: antecubital l 20 gauge consumed on last month/15 for patient 002-41152. ### 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 = '002-41152')) AND intakeoutput.celllabel = 'per iv flush: antecubital l 20 gauge' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '15'
### Instruction: what was the difference in weight of patient 006-123134 second measured on the current hospital visit compared to the first value measured on the current hospital visit? ### Response:
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-123134' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1 OFFSET 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-123134' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
### Instruction: what flights go from SAN FRANCISCO to BOSTON and leave after 1300 o'clock ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.departure_time > 1300 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: when was the last time patient 17667 respiratory rate was measured greater than 16.0 since 2123 days ago. ### 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 = 17667)) 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 > 16.0 AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-2123 day') ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: indicate the yearly minimum dose of ns 1/2cc:1cc replace that patient 28443 has received since 06/2104. ### Response:
SELECT MIN(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 = 28443)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'ns 1/2cc:1cc replace' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m', inputevents_cv.charttime) >= '2104-06' GROUP BY STRFTIME('%y', inputevents_cv.charttime)
### Instruction: on 07/21/this year, when patient 032-32248 got p.o. for the last time? ### 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 = '032-32248')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'p.o.' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '07-21' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: diagnosis of type ii diabetes by a physician as defined by the american diabetes association standard criteria: 1 ) fasting plasma glucose at or above 126 mg / dl 2 ) a two _ hour value in an oral glucose tolerance test at or above 200 mg / dl, or 3 ) a random plasma glucose concentration 200 mg / dl in the presence of symptoms, or 4 ) glycosylated hemoglobin greater than or equal to 6.5 % . ### Response:
SELECT * FROM table_dev_31 WHERE diabetic = 'ii' OR (fasting_plasma_glucose > 126 OR oral_glucose_tolerance_test > 200 OR random_plasma_glucose_concentration = 200 OR glycosylated_hemoglobin >= 6.5)
### Instruction: what is the daily minimum amount of the chest tubes cticu ct 1 of patient 51497 since 01/01/2105? ### Response:
SELECT MIN(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 = 51497)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'chest tubes cticu ct 1' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m-%d', outputevents.charttime) >= '2105-01-01' GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
### Instruction: what are the top five most common diagnoses for the patient aged 50s the previous year? ### 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 BETWEEN 50 AND 59) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: when was the first time the respiratory rate of patient 3125 was measured today at greater than 14.0? ### 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 = 3125)) 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 > 14.0 AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY chartevents.charttime LIMIT 1
### Instruction: what is the daily minimum cerebral drain l ventricular drain output that patient 49036 has had until 10/02/2105? ### Response:
SELECT MIN(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 = 49036)) AND outputevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'cerebral drain l ventricular drain' AND d_items.linksto = 'outputevents') AND STRFTIME('%y-%m-%d', outputevents.charttime) <= '2105-10-02' GROUP BY STRFTIME('%y-%m-%d', outputevents.charttime)
### Instruction: how many hours have passed since patient 021-100763 first has been prescribed famotidine (pepcid) (2 mg/ml) inj dilution 20 mg on their current hospital encounter? ### 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 = '021-100763') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'famotidine (pepcid) (2 mg/ml) inj dilution 20 mg' ORDER BY medication.drugstarttime LIMIT 1
### Instruction: Best of Minimal: Votes / Length (non-wiki). Top 1000 (non-wiki) 'quality' posts as defined by (votes * post length). Idea taken from: http://data.stackexchange.com/stackoverflow/query/36092/ ### Response:
SELECT (CASE p.PostTypeId WHEN 1 THEN 'Q' WHEN 2 THEN 'A' END) AS "t", p.Id AS "post_link", p.OwnerUserId AS "user_link", p.Score AS "score", LENGTH(p.Body) AS "post_length", (CAST((p.Score) AS FLOAT)) / (CAST(LENGTH(p.Body) AS FLOAT)) AS "weighted_score" FROM Posts AS p WHERE (p.PostTypeId = 1 OR p.PostTypeId = 2) AND CommunityOwnedDate IS NULL ORDER BY 'weighted_score' DESC LIMIT 1000
### Instruction: what was the total number of d5/.45ns doses that patient 14054 received on last month/01? ### 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 = 14054)) 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 month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', inputevents_cv.charttime) = '01'
### Instruction: upvote/downvote ratio: 2015 through 2020. Look at the Graph, to see the evolution of the upvote/downvote ratio. ### Response:
SELECT DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS YearMonth, (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS FLOAT), 0)) AS Ratio FROM Votes WHERE CreationDate > '01-01-2015' AND CreationDate < '12-31-2020' GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) ORDER BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
### Instruction: since 1409 days ago, has patient 25814's arterial bp [systolic] been ever greater than 113.0? ### 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 = 25814)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [systolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 113.0 AND DATETIME(chartevents.charttime) >= DATETIME(CURRENT_TIME(), '-1409 day')
### Instruction: What question has the most cycles of Close/Reopen?. https://meta.stackexchange.com/questions/277175/what-question-has-the-most-cycles-of-close-reopen ### Response:
SELECT PostId, Title, 'closed', 're-opened', 'closed' + 're-opened' AS "cycles", CASE WHEN 'closed' > 're-opened' THEN 'closed' ELSE 'open' END AS "current" FROM (SELECT PostId, p.Title, SUM(CASE WHEN PostHistoryTypeId = 10 THEN 1 ELSE 0 END) AS "closed", SUM(CASE WHEN PostHistoryTypeId = 11 THEN 1 ELSE 0 END) AS "re-opened" FROM PostHistory INNER JOIN Posts AS p ON p.Id = PostId WHERE PostHistoryTypeId IN (10, 11) GROUP BY PostId, Title) AS data ORDER BY 'closed' + 're-opened' DESC
### Instruction: indicate the monthly maximum amount of d5/.45ns patient 19627 has received until 03/10/2104. ### Response:
SELECT MAX(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 = 19627)) 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 STRFTIME('%y-%m-%d', inputevents_cv.charttime) <= '2104-03-10' GROUP BY STRFTIME('%y-%m', inputevents_cv.charttime)
### Instruction: on the first intensive care unit visit, when was the last time that patient 021-198501 had a output y (ml)-chest tube y - a #1 right lateral b #4 left lateral output? ### 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 = '021-198501') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'output y (ml)-chest tube y - a #1 right lateral b #4 left lateral' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: How Unsung am I? (Search by Display Name). ### Response:
SELECT COUNT(a.Id) AS "accepted_answers", SUM(CASE WHEN a.Score = 0 THEN 0 ELSE 1 END) AS "scored_answers", SUM(CASE WHEN a.Score = 0 THEN 1 ELSE 0 END) AS "unscored_answers", SUM(CASE WHEN a.Score = 0 THEN 1 ELSE 0 END) * 1000 / COUNT(a.Id) / 10.0 AS "percentage_unscored" FROM Posts AS q INNER JOIN Posts AS a ON a.Id = q.AcceptedAnswerId INNER JOIN Users AS u ON u.Id = a.OwnerUserId WHERE a.CommunityOwnedDate IS NULL AND a.OwnerUserId = u.Id AND q.OwnerUserId != u.Id AND a.PostTypeId = 2 AND u.DisplayName = '##DisplayName##'
### Instruction: information on afternoon flights from PHILADELPHIA 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 = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
### Instruction: Weekly trend for python (last 100 weeks). ### Response:
SELECT 'Week ' + CAST(TIME_TO_STR(Posts.CreationDate, '%W') AS TEXT(2)) AS Week, YEAR(Posts.CreationDate) AS year, Tags.TagName, COUNT(*) AS Questions FROM Tags LEFT JOIN PostTags ON PostTags.TagId = Tags.Id LEFT JOIN Posts ON Posts.Id = PostTags.PostId LEFT JOIN PostTypes ON PostTypes.Id = Posts.PostTypeId LEFT JOIN Users ON Users.Id = Posts.OwnerUserId WHERE Tags.TagName IN ('python') AND PostTypes.Name = 'Question' GROUP BY YEAR(Posts.CreationDate), TIME_TO_STR(Posts.CreationDate, '%W'), Tags.TagName ORDER BY YEAR(Posts.CreationDate) DESC, TIME_TO_STR(Posts.CreationDate, '%W') DESC LIMIT 100
### Instruction: when was the last measurement of patient 22973's arterial bp [diastolic] since 06/10/2101? ### 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 = 22973)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2101-06-10' ORDER BY chartevents.charttime DESC LIMIT 1
### Instruction: when did patient 030-10559 take his volume (ml) propofol for the last time on last month/11? ### 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 = '030-10559')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'volume (ml) propofol' AND DATETIME(intakeoutput.intakeoutputtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', intakeoutput.intakeoutputtime) = '11' ORDER BY intakeoutput.intakeoutputtime DESC LIMIT 1
### Instruction: please list the afternoon flights from CHARLOTTE to MINNEAPOLIS ### 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 = 'CHARLOTTE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MINNEAPOLIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
### Instruction: Comments with Links by Month. ### Response:
WITH periodcomments AS (SELECT CAST(TIME_TO_STR(c.CreationDate, '%Y%m%d') AS TEXT(6)) AS period, c.Id, CASE WHEN c.Text LIKE '%http://%' THEN 1 ELSE 0 END AS link FROM Comments AS c), bands AS (SELECT p.*, DENSE_RANK() OVER (ORDER BY p.period) AS banding FROM periodcomments AS p), rollups AS (SELECT b.period, b.banding, COUNT(b.Id) AS total, SUM(b.link) AS linknum FROM bands AS b GROUP BY b.period, b.banding) SELECT r.period, r.total, r.linknum, ROUND((CAST(r.linknum AS FLOAT) * 100) / CAST(r.total AS FLOAT), 1) AS percentage FROM rollups AS r ORDER BY r.period
### Instruction: show me all flights from PITTSBURGH to OAKLAND that arrive after 1000 ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'OAKLAND' AND flight.arrival_time > 1000 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: Top Average Answer Scores - Mathematica Tags. ### Response:
WITH scores AS (SELECT DISTINCT u.Id AS UserId, a.Title, a.Id AS "Post Link", a.Score FROM Posts AS q INNER JOIN PostTags AS xqt ON xqt.PostId = q.Id INNER JOIN Tags AS t ON t.Id = xqt.TagId AND t.TagName LIKE '%mathematica%' INNER JOIN Posts AS a ON a.ParentId = q.Id INNER JOIN PostTypes AS pt ON pt.Id = a.PostTypeId AND pt.Name = 'Answer' INNER JOIN Users AS u ON u.Id = a.OwnerUserId), totals AS (SELECT UserId AS "User Link", SUM(Score) AS Score, COUNT(*) AS Posts, 1.0 * SUM(Score) / COUNT(*) AS AvgScore FROM scores GROUP BY UserId HAVING COUNT(*) > 20) SELECT * FROM totals ORDER BY AvgScore DESC LIMIT 50
### Instruction: indicate the daily minimum arterial bp mean of patient 28447 since 11/30/2101. ### 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 = 28447)) 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) >= '2101-11-30' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
### Instruction: # of users with rep > amount, active recently. ### Response:
SELECT SUM(IIF(DATEDIFF(DAY, u.LastAccessDate, GETDATE()) <= 7, 1, 0)) AS Days7, SUM(IIF(DATEDIFF(DAY, u.LastAccessDate, GETDATE()) <= 14, 1, 0)) AS Days14, SUM(IIF(DATEDIFF(DAY, u.LastAccessDate, GETDATE()) <= 30, 1, 0)) AS Days30, SUM(IIF(DATEDIFF(DAY, u.LastAccessDate, GETDATE()) <= 90, 1, 0)) AS Days90, SUM(IIF(DATEDIFF(DAY, u.LastAccessDate, GETDATE()) <= 180, 1, 0)) AS Days180, COUNT(*) AS Total FROM Users AS u WHERE u.Reputation >= '##Reputation?500##'
### Instruction: what is the weight difference of patient 006-14121 from the second value measured on the current hospital visit compared to the first value measured on the current hospital visit? ### Response:
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-14121' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1 OFFSET 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-14121' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
### Instruction: tell me the maximum heart rate for patient 6705's body on 09/19/last year? ### 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 = 6705)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', chartevents.charttime) = '09-19'
### Instruction: list DAILY flights from OAKLAND to BOSTON using TW ### 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 = 'OAKLAND' 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.airline_code = 'TW') AND flight.flight_days = 'DAILY'
### Instruction: what are the evening flights from ATLANTA to BALTIMORE ### 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 = 'ATLANTA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
### Instruction: i need a ticket from LOS ANGELES to CHARLOTTE that leaves early in the morning ### 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 = 'LOS ANGELES' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CHARLOTTE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 800
### Instruction: show me all flights from MINNEAPOLIS to SAN DIEGO that arrive before 1900 ### 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN DIEGO' AND flight.arrival_time <= 1900 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MINNEAPOLIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
### Instruction: Users with the highest reputation per answers and questions count ratio. To find your own ratio, go here: https://data.stackexchange.com/stackoverflow/query/384546/users-reputation-per-answers-and-questions-count-ratio ### Response:
SELECT u.Id AS "user_link", u.DisplayName, u.Reputation, COUNT(p.Id) AS "posts_count", (CAST(u.Reputation AS FLOAT) / CAST(COUNT(p.Id) AS FLOAT)) AS "ratio" FROM Users AS u LEFT JOIN Posts AS p ON u.Id = p.OwnerUserId WHERE p.PostTypeId = 1 OR p.PostTypeId = 2 GROUP BY u.Id, u.DisplayName, u.Reputation HAVING COUNT(p.Id) > '##MinimalPostsCount:int?500##' ORDER BY Ratio DESC LIMIT 500
### Instruction: what are the afternoon flights from ATLANTA to BALTIMORE ### 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 = 'ATLANTA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
### Instruction: list DAILY flights from OAKLAND to BOSTON using DL ### 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 = 'OAKLAND' 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.airline_code = 'DL') AND flight.flight_days = 'DAILY'
### Instruction: Questions Per Tag (Top Five) (By Month). ### Response:
SELECT t.TagName FROM Tags AS t /* *, COUNT(*) AS Count FROM ( SELECT CAST( CAST(DATEPART(YYYY, CreationDate) AS varchar) + '-' + CAST(DATEPART(MM, CreationDate) AS varchar) + '-01' AS DATETIME) 'month', t.TagName FROM Posts p JOIN PostTags pt ON pt.PostId = p.Id JOIN Tags t ON t.Id = pt.TagId WHERE TagId IN ( SELECT TOP 5 Id FROM Tags ORDER BY Count DESC ) ) AS X WHERE 'month' >= CAST('2012-04-01' as datetime) AND 'month' < CAST('2012-07-01' as datetime) GROUP BY TagName, 'month' ORDER BY 'month' ASC, TagName ASC */ WHERE t.Id IN (SELECT Id FROM Tags ORDER BY Count DESC LIMIT 5)
### Instruction: show afternoon flights from DALLAS 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 = 'DALLAS' 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.departure_time BETWEEN 1200 AND 1800
### Instruction: tell me the time when patient 022-78423's sao2 was greater than 93.0 for the first time on this month/31? ### 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 = '022-78423')) AND vitalperiodic.sao2 > 93.0 AND NOT vitalperiodic.sao2 IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '31' ORDER BY vitalperiodic.observationtime LIMIT 1
### Instruction: the last time patient 017-74343 was prescribed sodium chloride 0.9% syringe sso in 02/last year? ### 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 = '017-74343')) AND medication.drugname = 'sodium chloride 0.9% syringe sso' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', medication.drugstarttime) = '02' ORDER BY medication.drugstarttime DESC LIMIT 1
### Instruction: Find questions titles that are not phrased as questions. Find question titles that do not contain the Five Ws (Who, What, When, Where and why), interrogative words, and question marks. This query MAY be useful for identifying titles that aren't phrased as a question or low quality questions. Special thanks: s.tk/users/398665 ### Response:
SELECT Id AS "post_link" FROM Posts WHERE NOT Title LIKE '%Who%' AND NOT Title LIKE '%What%' AND NOT Title LIKE '%When%' AND NOT Title LIKE '%Where%' AND NOT Title LIKE '%Why%' AND NOT Title LIKE '%How%' AND NOT Title LIKE '%Can%' AND NOT Title LIKE '%Is%' AND NOT Title LIKE '%Which%' AND NOT Title LIKE '%Was%' AND NOT Title LIKE '%Are%' AND NOT Title LIKE '%Has%' AND NOT Title LIKE '%Will%' AND NOT Title LIKE '%Do%' AND NOT Title LIKE '%?%' AND ClosedDate IS NULL ORDER BY CreationDate DESC