instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
how many patients had been diagnosed with leukocytosis during the same hospital visit after the previous diagnosis of hypotension / pressor dependent?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'leukocytosis') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypotension / pressor dependent') AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
RLA-RegDiscontinuity: all users with 5 downvotes in a week.
### Response:
|
SELECT u.Id, u.DisplayName, u.Reputation, v.weekno, COUNT(v.Id) AS downvotes, MIN(v.CreationDate) AS fromdate, MAX(v.CreationDate) AS todate FROM Users AS u, Posts AS p, (SELECT Id, DATEDIFF(week, '2019-01-01', creationdate) AS weekno, CreationDate, PostId FROM Votes WHERE CreationDate >= '2019-01-01' AND VoteTypeId = 3) AS v WHERE u.Id = p.OwnerUserId AND p.Id = v.PostId AND p.OwnerUserId = 2901002 AND p.PostTypeId = 2 GROUP BY u.Id, u.DisplayName, u.Reputation, v.weekno ORDER BY u.Id, u.Reputation, v.weekno
|
### Instruction:
i want a flight from PHILADELPHIA to DALLAS that at least has 1 stop
### 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, flight_stop WHERE ((flight.flight_id = flight_stop.flight_id AND flight.stops >= 1) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Most popular unanswered StackOverflow tags since 2018.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS MayRank, ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS TotalRank, rate.Rate AS QuestionsInMay, num.Num AS QuestionsTotal FROM (SELECT COUNT(PostId) AS Rate, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate > '2018-01-01' AND Posts.AcceptedAnswerId IS NULL GROUP BY TagName) AS rate INNER JOIN (SELECT COUNT(PostId) AS Num, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId GROUP BY TagName HAVING COUNT(PostId) > 800) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
Accepted Answers by Group Members based on specified dates.
### Response:
|
SELECT Users.DisplayName, answers.Id AS "a.answerid", answers.ParentId AS "a.questionid", answers.CreationDate AS "a.cdate" FROM Posts AS questions LEFT JOIN Posts AS answers ON questions.AcceptedAnswerId = answers.Id LEFT JOIN Users AS users ON answers.OwnerUserId = Users.Id WHERE (answers.OwnerUserId = 5637321 OR answers.OwnerUserId = 5995040 OR answers.OwnerUserId = 5832311 OR answers.OwnerUserId = 5996134 OR answers.OwnerUserId = 6092067 OR answers.OwnerUserId = 6143482) AND answers.PostTypeId = 2 AND answers.CreationDate >= '09/01/2016' AND answers.CreationDate <= '10/01/2016'
|
### Instruction:
Users with reputation > 5000 and < 10 answers.
### Response:
|
SELECT Users.Id AS "user_link", Users.DisplayName, Users.Reputation, SUM(CASE WHEN Posts.PostTypeId = 1 THEN 1 ELSE 0 END) AS Questions, SUM(CASE WHEN Posts.PostTypeId = 2 THEN 1 ELSE 0 END) AS Answers, Users.UpVotes, Users.DownVotes FROM Users INNER JOIN Posts ON Users.Id = Posts.OwnerUserId AND (Posts.PostTypeId = 1 OR Posts.PostTypeId = 2) AND Users.Reputation > 5000 GROUP BY Users.Id, Users.CreationDate, Users.LastAccessDate, Users.Reputation, Users.DisplayName, Users.CreationDate, Users.Views, Users.UpVotes, Users.DownVotes HAVING SUM(CASE WHEN Posts.PostTypeId = 2 THEN 1 ELSE 0 END) < 10 ORDER BY Users.Id
|
### Instruction:
now show me the flights from DENVER to PHILADELPHIA on a SATURDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND days.day_name = 'SATURDAY' AND flight.flight_days = days.days_code 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.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what is the monthly minimum dose of d5w 10%alcohol that patient 13054 has taken since 05/23/2100?
### 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 = 13054)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5w 10%alcohol' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m-%d', inputevents_cv.charttime) >= '2100-05-23' GROUP BY STRFTIME('%y-%m', inputevents_cv.charttime)
|
### Instruction:
i want to fly from BOSTON at 838 and arrive in DENVER at 1110 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 ((flight.arrival_time = 1110 AND flight.departure_time = 838) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
is there a flight between WASHINGTON and SAN FRANCISCO on US at 800
### 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 FRANCISCO' 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 = 'WASHINGTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'US'
|
### Instruction:
Off Topic Posts By tag with minimum question count.
### Response:
|
SELECT t.TagName, COUNT(pt.PostId) AS TagQuestionCount, COUNT(ph.PostId) AS OffTopicCount, CASE COUNT(ph.PostId) WHEN 0 THEN NULL ELSE CAST(COUNT(ph.PostId) AS FLOAT) / CAST(COUNT(pt.PostId) AS FLOAT) * 100 END AS ratioClosedOffTopic FROM PostTags AS pt INNER JOIN Tags AS t ON pt.TagId = t.Id LEFT JOIN PostHistory AS ph ON ph.PostId = pt.PostId AND ph.PostHistoryTypeId = 10 AND CAST(ph.Comment AS INT) = 2 GROUP BY t.TagName HAVING COUNT(pt.PostId) > @MinQuestioncount ORDER BY CASE COUNT(ph.PostId) WHEN 0 THEN NULL ELSE CAST(COUNT(ph.PostId) AS FLOAT) / CAST(COUNT(pt.PostId) AS FLOAT) END DESC
|
### Instruction:
Answers, Posts, and Views by Date Range and DisplayName (MVP).
### Response:
|
SELECT pt.Name, Posts = COUNT(*), Views = SUM(COALESCE(p.ViewCount, parent.ViewCount)), Start = CONCAT(TIME_TO_STR(@startDate, '%B'), ' ', TIME_TO_STR(@startDate, '%Y')), Finish = CONCAT(TIME_TO_STR(@endDate, '%B'), ' ', TIME_TO_STR(@endDate, '%Y')) FROM Posts AS p LEFT JOIN Posts AS parent ON p.ParentId = parent.Id JOIN Users AS u ON p.OwnerUserId = u.Id JOIN PostTypes AS pt ON p.PostTypeId = pt.Id WHERE u.DisplayName = @user AND p.CreationDate BETWEEN @startDate AND @endDate GROUP BY pt.Name, TIME_TO_STR(P.CreationDate, '%Y'), TIME_TO_STR(P.CreationDate, '%B')
|
### Instruction:
when was the last time when patient 31325 had the minimum value of arterial bp [systolic] on 06/10/2104?
### 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 = 31325)) 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) = '2104-06-10' ORDER BY chartevents.valuenum, chartevents.charttime DESC LIMIT 1
|
### Instruction:
Suspended users of the site, ordered by estimated reputation, with hidden accounts.
### Response:
|
SELECT Users.Id AS "user_link", COUNT(*) * 10 AS "estimated_rep", 'https://stackexchange.com/users/' + CAST(MIN(Users.AccountId) AS TEXT) + '|' + MIN(Users.DisplayName) AS "network_profile", 'https://data.stackexchange.com/meta.stackexchange/query/1089480?' + 'NetworkAccountId=' + CAST(MIN(Users.AccountId) AS TEXT) + '|' + MIN(Users.DisplayName) AS "with_hidden_accounts" FROM Users, Posts, Votes WHERE Users.Reputation = 1 AND Users.DownVotes > 0 AND Posts.OwnerUserId = Users.Id AND Votes.PostId = Posts.Id AND Votes.VoteTypeId = 2 GROUP BY Users.Id ORDER BY 'estimated_rep' DESC, Users.Id
|
### Instruction:
show me the price of all flights from ATLANTA to WASHINGTON
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare 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 = 'WASHINGTON' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
how many patients were diagnosed as having transaminase elevation within 2 months after being diagnosed with hypoglycemia?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'transaminase elevation') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypoglycemia') AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
please list all flights between BOSTON and PHILADELPHIA operating on SUNDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND days.day_name = 'SUNDAY' AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Top 100 most viewed questions. Questions must have at least 1000 views to qualify
### Response:
|
SELECT Questions.Id AS "post_link", Questions.Title, Questions.AnswerCount, Questions.ViewCount, Questions.FavoriteCount, Questions.Score, Questions.LastActivityDate, Questions.Tags FROM Posts AS Answers INNER JOIN Posts AS Questions ON Questions.Id = Answers.ParentId INNER JOIN Users AS Users ON Answers.OwnerUserId = Users.Id INNER JOIN PostTags ON PostTags.PostId = Answers.ParentId INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE Questions.Tags LIKE '%java%' AND NOT Questions.Tags LIKE '%javascript%' GROUP BY Questions.Id, Questions.Title, Questions.AnswerCount, Questions.ViewCount, Questions.FavoriteCount, Questions.Score, Questions.LastActivityDate, Questions.Tags ORDER BY Questions.ViewCount DESC LIMIT 10000
|
### Instruction:
flight from SALT LAKE CITY to OAKLAND CALIFORNIA
### 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, state 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 = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND state.state_code = CITY_1.state_code AND state.state_name = 'CALIFORNIA'
|
### Instruction:
which DL flights depart from SAN FRANCISCO heading toward BOSTON after 1200
### 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 > 1200 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) AND flight.airline_code = 'DL'
|
### Instruction:
do you have a flight from SAN FRANCISCO to ATLANTA around 8am
### 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.departure_time <= 830 AND flight.departure_time >= 730) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' 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 is the next time 248 , taught by Ryan Kellogg be offered ?
### 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 = 248 AND course_offering.semester = semester.semester_id AND instructor.name LIKE '%Ryan Kellogg%' 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:
does UA have any flights from DALLAS to SAN FRANCISCO
### 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 = 'SAN FRANCISCO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DALLAS' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Questions answered by a user before they were closed.
### Response:
|
SELECT a.Id AS "post_link", a.Score, a.CreationDate, CASE WHEN a.Score < 1 THEN 'Score too low' WHEN e.CreationDate IS NULL THEN 'No edit within 12 hours' ELSE 'Question closed' END AS "Why no Illuminator" FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id AND a.CreationDate < q.ClosedDate LEFT JOIN LATERAL (SELECT CreationDate FROM PostHistory AS h WHERE h.PostId = q.Id AND h.PostHistoryTypeId IN (4, 5) AND h.CreationDate BETWEEN DATE(a.CreationDate, '-12 HOUR') AND DATE(a.CreationDate, '12 HOUR') AND h.UserId = a.OwnerUserId LIMIT 1) AS e WHERE a.OwnerUserId = '##UserId:int##' ORDER BY a.CreationDate DESC
|
### Instruction:
what flights leave PHILADELPHIA for DALLAS and depart before 1200 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.departure_time < 1200 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
How close am I to Explainer/ Refiner/ Illuminator.
### Response:
|
SELECT Users.Id AS "user_link", COUNT(Posts.Id) FROM Posts JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Posts.PostTypeId = 2 AND Posts.OwnerUserId = Users.Id AND Posts.Score > 0 AND EXISTS(SELECT Id FROM PostHistory WHERE PostHistory.PostId = Posts.ParentId AND PostHistory.UserId = Users.Id AND PostHistory.CreationDate < DATE(Posts.CreationDate, '12 hour') AND PostHistory.CreationDate > DATE(Posts.CreationDate, '-12 hour')) AND NOT EXISTS(SELECT Id FROM Votes WHERE (Votes.VoteTypeId = 6 AND Votes.PostId = Posts.ParentId) OR (Votes.VoteTypeId = 6 AND Votes.PostId = Posts.ParentId)) GROUP BY Users.Id ORDER BY COUNT(Posts.Id) DESC
|
### Instruction:
on 12/24/2105 the arterial bp [systolic] of patient 12775 had been normal?
### 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 = 12775)) 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 STRFTIME('%y-%m-%d', chartevents.charttime) = '2105-12-24'
|
### Instruction:
does YX have any flights from MONTREAL to NASHVILLE
### 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 = 'YX') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NASHVILLE' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MONTREAL' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
does AA have a flight from PITTSBURGH to ATLANTA
### 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 = 'AA') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' 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.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
okay does TW have a flight from DALLAS to SAN FRANCISCO
### 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 = 'TW') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DALLAS' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
when was the last time patient 028-43966 had vancomycin 1,000 mg iv solution : 1 each vial prescribed in 02/this 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 = '028-43966')) AND medication.drugname = 'vancomycin 1,000 mg iv solution : 1 each vial' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '02' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
had patient 030-10407 had the external ventricular drain (evd) output (ml)-icp/external ventricular drain (evd) left ventriculostomy output until 07/22/2105?
### Response:
|
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-10407')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'external ventricular drain (evd) output (ml)-icp/external ventricular drain (evd) left ventriculostomy' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-07-22'
|
### Instruction:
Gold Badge Efficiency (Gold Badges / Reputation) - users over 1 rep only.
### Response:
|
SELECT UserId AS "user_link", COUNT(*) AS "gold_badges", (SELECT usr.Reputation FROM Users AS usr WHERE usr.Id = UserId) AS Reputation, (COUNT(*) / CAST((SELECT usr.Reputation FROM Users AS usr WHERE usr.Id = UserId AND usr.Reputation > 1000) AS FLOAT(9, 2))) AS "gold_badge_efficiency" FROM Badges WHERE Name IN ('Copy Editor', 'Electorate', 'Famous Question', 'Fanatic', 'Great Answer', 'Great Question', 'Legendary', 'Marshal', 'Populist', 'Publicist', 'Reversal', 'Stellar Question', 'Steward', 'Unsung Hero') GROUP BY UserId ORDER BY 'gold_badge_efficiency' DESC LIMIT 100
|
### Instruction:
Question titles by last non-punctuation character. Experimenting around
http://meta.japanese.stackexchange.com/questions/566/question-is-inacessible-due-to-invalid-utf-8-character-in-a-title
http://meta.japanese.stackexchange.com/questions/899/redirect-problem-for-a-specific-question
http://meta.stackexchange.com/questions/233850/redirect-loop-after-editing-a-question-title-ending-with-no-break-space-questio
### Response:
|
SELECT MIN(Id) AS "post_link", LEFT(RIGHT(Title, PATINDEX('^?.', REVERSE(Title)) + 1), 1) AS "character" FROM Posts WHERE PostTypeId = 1 GROUP BY LEFT(RIGHT(Title, PATINDEX('^?.', REVERSE(Title)) + 1), 1) ORDER BY 'character'
|
### Instruction:
show me all flights from PITTSBURGH to BOSTON both direct and connecting that depart PITTSBURGH after 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 = 'BOSTON' AND flight.departure_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 = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
show me the air fare for the flights from BALTIMORE to DALLAS
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BALTIMORE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
show me the flights between ATLANTA and WASHINGTON for WEDNESDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND days.day_name = 'WEDNESDAY' AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'ATLANTA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what time patient 13536 had last had the maximum arterial bp [systolic] value until 05/09/2105?
### 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 = 13536)) 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-05-09' ORDER BY chartevents.valuenum DESC, chartevents.charttime DESC LIMIT 1
|
### Instruction:
how much is a round trip fare from NASHVILLE to SEATTLE
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NASHVILLE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SEATTLE' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
Which of my answers received more votes than the accepted answer?.
### Response:
|
WITH Utable AS (SELECT Id AS AnswerId, ParentId AS QuestionId, Score AS Uscore FROM Posts WHERE OwnerUserId = 7128934 AND Posts.PostTypeId = 2 AND Posts.ParentId IN (SELECT Posts.Id FROM Posts WHERE NOT Posts.AcceptedAnswerId IS NULL)), OTable AS (SELECT Score AS Oscore, ParentId AS Oqid, Id AS Oaid FROM Posts WHERE Posts.ParentId IN (SELECT QuestionId FROM UTable) AND Posts.Id IN (SELECT DISTINCT AcceptedAnswerId FROM Posts)) SELECT DISTINCT Id AS "post_link", OTable.OScore AS Accepted_Score, Utable.Uscore AS MyScore FROM Posts INNER JOIN Utable ON Utable.QuestionId = Posts.Id INNER JOIN Otable ON Otable.Oqid = Posts.Id WHERE AnswerId != Oaid AND Uscore > Oscore
|
### Instruction:
please give me direct morning flights from PITTSBURGH 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 = 'PITTSBURGH' 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 0 AND 1200) AND flight.connections = 0
|
### Instruction:
Good answer vs includes code.
### Response:
|
SELECT CASE WHEN a.Score > 0 OR a.Id = q.AcceptedAnswerId THEN 'yes' ELSE 'no' END AS GoodAnswer, CASE WHEN q.Body LIKE '%<code>%' THEN 'yes' ELSE 'no' END AS IncludesCode, COUNT(*) AS Count FROM Posts AS q JOIN Posts AS a ON q.Id = a.ParentId WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND q.ViewCount > 10 AND q.AnswerCount > 0 AND q.CreationDate > (SELECT MAX(CreationDate) FROM Posts) - 30 GROUP BY CASE WHEN a.Score > 0 OR a.Id = q.AcceptedAnswerId THEN 'yes' ELSE 'no' END, CASE WHEN q.Body LIKE '%<code>%' THEN 'yes' ELSE 'no' END ORDER BY CASE WHEN a.Score > 0 OR a.Id = q.AcceptedAnswerId THEN 'yes' ELSE 'no' END
|
### Instruction:
What are the most popular first 3 words in question titles?.
### Response:
|
SELECT SUBSTRING(p.Title, 1, STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ') + 1) + 1)) AS First3Words, COUNT(DISTINCT p.Id) AS Questions, AVG(p.Score) AS AvgScore FROM dbo.Posts AS p WHERE p.PostTypeId = 1 AND STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ') + 1) + 1) > 0 GROUP BY SUBSTRING(p.Title, 1, STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ', STR_POSITION(p.Title, ' ') + 1) + 1)) ORDER BY COUNT(DISTINCT p.Id) DESC LIMIT 100
|
### Instruction:
does TW have a flight from INDIANAPOLIS to HOUSTON arriving at 1100
### 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 = 'HOUSTON' AND flight.arrival_time = 1100 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'INDIANAPOLIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'TW'
|
### Instruction:
when was the first time on this month/08 patient 23070 had a .9% normal saline intake?
### 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 = 23070)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '08' ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
has the respiratory rate of patient 5849 in 07/last year ever been less than 20.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 = 5849)) 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 < 20.0 AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', chartevents.charttime) = '07'
|
### Instruction:
are there any nonstop flights from PHILADELPHIA to DENVER that arrive before 1700
### 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 <= 1700 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.stops = 0
|
### Instruction:
Most popular StackOverflow tags in October 2016.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS OctoberRank, ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS TotalRank, rate.Rate AS QuestionsInOctober, num.Num AS QuestionsTotal FROM (SELECT COUNT(PostId) AS Rate, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate < '2016-01-01' AND Posts.CreationDate > '2016-12-31' GROUP BY TagName) AS rate INNER JOIN (SELECT COUNT(PostId) AS Num, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId GROUP BY TagName) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
25 Most Downvoted Users with per-post DV ratios. Users with the most downvotes cast on their questions and answers
### Response:
|
SELECT b.OwnerUserId AS "user_link", SUM(CASE WHEN a.VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, MIN(b.CreationDate) AS OldestPost, COUNT(DISTINCT b.Id) AS NumberOfPosts, SUM(CASE WHEN a.VoteTypeId = 3 THEN 1 ELSE 0 END) * 1000 / COUNT(DISTINCT b.Id) AS DV2PostsRatio FROM Votes AS a INNER JOIN Posts AS b ON a.PostId = b.Id AND b.PostTypeId IN (1, 2) WHERE a.VoteTypeId IN (2, 3) GROUP BY b.OwnerUserId ORDER BY SUM(CASE WHEN a.VoteTypeId = 3 THEN 1 ELSE 0 END) DESC LIMIT 25
|
### Instruction:
tell me the amount of tpn d10.0 patient 31325 had received on 06/28/last year?
### 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 = 31325)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d10.0' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '06-28'
|
### Instruction:
what are the prices of the flights from DALLAS to BALTIMORE
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare 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 = 'BALTIMORE' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
when was the first time patient 9038, until 12/19/2105, had the maximum arterial bp [diastolic]?
### 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 = 9038)) 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) <= '2105-12-19' ORDER BY chartevents.valuenum DESC, chartevents.charttime LIMIT 1
|
### Instruction:
i need fare information from DENVER to PITTSBURGH
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare 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 = 'PITTSBURGH' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
when was the last time patient 15447 measured its respiratory rate greater than 13.0 since 07/13/2102?
### 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 = 15447)) 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 > 13.0 AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2102-07-13' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
show flights leaving MIAMI to CLEVELAND on US that leave after 1200
### 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 = 'CLEVELAND' AND flight.departure_time > 1200 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MIAMI' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'US'
|
### Instruction:
Percentage of first posts which get closed (per month) - between two dates.
### Response:
|
WITH firstpostids_cte AS (SELECT MIN(Id) AS MinId, OwnerUserId FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId), firstpostsclosed_cte AS (SELECT p.Id, p.CreationDate AS cre, p.ClosedDate AS clo FROM firstpostids_cte AS fp JOIN Posts AS p ON fp.MinId = p.Id) SELECT LAST_DATE_OF_MONTH(cre), ROUND((COUNT(clo)) * 100.0 / (COUNT(*)), 2) AS percentage FROM firstpostsclosed_cte WHERE cre >= '##Date1?2014-10-01##' AND cre <= '##Date2?2015-11-30##' GROUP BY LAST_DATE_OF_MONTH(cre) ORDER BY LAST_DATE_OF_MONTH(cre)
|
### Instruction:
Titles with Answers > 0.
### Response:
|
SELECT P.Title, P.AcceptedAnswerId, P.AnswerCount, YEAR(P.CreationDate) FROM Posts AS P WHERE P.Title LIKE '%appium%' AND P.AnswerCount > 0 AND ((P.Tags LIKE '%android-testing%') OR (P.Tags LIKE '%robotium%') OR (P.Tags LIKE '%androidviewclient%') OR (P.Tags LIKE '%monkeyrunner%') OR (P.Tags LIKE '%robolectric%') OR (P.Tags LIKE '%android-espresso%') OR (P.Tags LIKE '%android-emulator%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%uiautomator%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%appium%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%calabash%') OR (P.Tags LIKE '%android%' AND P.Tags LIKE '%test%'))
|
### Instruction:
does CO fly from PITTSBURGH to ATLANTA
### 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 = 'CO') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' 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.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
show me fares from SEATTLE to MINNEAPOLIS
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SEATTLE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MINNEAPOLIS' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
Get the users who bursted for both strunk and white and reviewer.
### Response:
|
SELECT UserId FROM (SELECT b.UserId, DATEDIFF(day, b.Date, CreationDate) AS days, COUNT(DATEDIFF(day, b.Date, CreationDate)) AS ph_count FROM Badges AS b INNER JOIN PostHistory AS ph ON (b.UserId IN (SELECT UserId FROM Badges WHERE Name = 'Copy Editor') AND b.Name = 'Strunk & White' AND b.UserId = ph.UserId AND DATEDIFF(day, b.Date, CreationDate) BETWEEN 0 AND 7) INNER JOIN Posts AS p ON (p.Id = ph.PostId AND p.OwnerUserId != ph.UserId AND ph.PostHistoryTypeId IN (4, 5)) GROUP BY b.UserId, DATEDIFF(day, b.Date, CreationDate)) AS innerTable GROUP BY UserId HAVING MAX(ph_count) >= 20
|
### Instruction:
Users with Tags Score excluding undesirable tag.
### Response:
|
SELECT DISTINCT u.Id AS "user_link", CONCAT('https://stackoverflow.com/users/', u.Id) AS "profile_link", u.DisplayName, 'Tag:' + t.TagName, SUM(a.Score) AS "tag_score", COUNT(*) AS "answer_count" FROM Users AS u INNER JOIN Posts AS a ON a.OwnerUserId = u.Id INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE a.CommunityOwnedDate IS NULL AND UPPER(t.TagName) = UPPER('##TagName##') AND UPPER(u.Location) LIKE UPPER('%##Location##%') GROUP BY u.Id, u.DisplayName, t.TagName HAVING SUM(a.Score) > COUNT(*) ORDER BY SUM(a.Score) DESC
|
### Instruction:
how much is a round trip fare from MEMPHIS to SEATTLE
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MEMPHIS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SEATTLE' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
price of flight from CLEVELAND to NASHVILLE
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CLEVELAND' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NASHVILLE' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
Posts with highest score from anonymous feedback.
### Response:
|
SELECT RANK() OVER (ORDER BY SUM(CASE pf.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) DESC) AS Rank, pf.PostId AS "post_link", SUM(CASE WHEN pf.VoteTypeId = 2 THEN 1 ELSE NULL END) AS UpFeedback, SUM(CASE WHEN pf.VoteTypeId = 3 THEN 1 ELSE NULL END) AS DownFeedback, SUM(CASE pf.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Score, p.OwnerUserId AS "user_link", p.Score FROM PostFeedback AS pf JOIN Posts AS p ON p.Id = pf.PostId GROUP BY pf.PostId, p.OwnerUserId, p.Score ORDER BY SUM(CASE pf.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) DESC LIMIT 500
|
### Instruction:
flights from INDIANAPOLIS to SEATTLE WASHINGTON
### 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, state WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'INDIANAPOLIS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SEATTLE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND state.state_code = CITY_1.state_code AND state.state_name = 'WASHINGTON'
|
### Instruction:
had the heart rate of patient 31854 been greater in 12/this year than 108.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 = 31854)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 108.0 AND DATETIME(chartevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', chartevents.charttime) = '12'
|
### Instruction:
Get User Info (Total answers and Accepted Answers). Returns the URL with the user's original inputted URL, the users reputation, number of answers posted, number of answers accepted.. Returns the URL with the user's original inputted URL, the users reputation, number of answers posted, number of answers accepted.
For https://www.codersclan.net/ticket/659
### Response:
|
SELECT answer.OwnerUserId AS "user_link", 'http://codegolf.stackexchange.com/users/' + CAST(answer.OwnerUserId AS TEXT(10)) AS "permalink", Users.Reputation, COUNT(answer.Id) AS "total_answers", COUNT(question.Id) AS "accepted_answers" FROM Posts AS answer LEFT OUTER JOIN Posts AS question ON question.AcceptedAnswerId = answer.Id INNER JOIN Users ON answer.OwnerUserId = Users.Id WHERE answer.OwnerUserId IN ('##UserId##') AND answer.PostTypeId = 2
|
### Instruction:
how many days have passed since patient 006-133605 received his or her first enteral tube intake: nasoduodenal nostril, r 10 intake on the current intensive care unit 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 = '006-133605') AND patient.unitdischargetime IS NULL) AND intakeoutput.celllabel = 'enteral tube intake: nasoduodenal nostril, r 10' AND intakeoutput.cellpath LIKE '%intake%' ORDER BY intakeoutput.intakeoutputtime LIMIT 1
|
### Instruction:
show me flights from DENVER to WASHINGTON on WEDNESDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND days.day_name = 'WEDNESDAY' AND flight.flight_days = days.days_code 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.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what was patient 11823's arterial bp mean average on 11/27/last year?
### 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 = 11823)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', chartevents.charttime) = '11-27'
|
### Instruction:
what is the daily average g tube output that patient 006-171217 has had in 01/last year?
### 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-171217')) AND intakeoutput.celllabel = 'g tube' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', intakeoutput.intakeoutputtime) = '01' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
### Instruction:
so what was the first arterial bp mean for patient 10624 on this month/20?
### 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 = 10624)) 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 month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '20' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
tell me the average temperature c (calc) for patient 7476's body on 11/06/last year?
### 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 = 7476)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', chartevents.charttime) = '11-06'
|
### Instruction:
what flights from BALTIMORE to SAN FRANCISCO arrive before 2000 in 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_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.arrival_time <= 2000 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:
get the total amount of .9% normal saline that patient 31510 has received on 05/31/this year.
### 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 = 31510)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = '.9% normal saline' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '05-31'
|
### Instruction:
what was the first intake time of promote w/fiber for patient 7698 on last month/04?
### 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 = 7698)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'promote w/fiber' 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) = '04' ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
i would like a connecting flight from DALLAS to SAN FRANCISCO leaving after 400 o'clock
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (((departure_time > 400 AND to_airport IN (SELECT AIRPORT_SERVICEalias1.airport_code FROM airport_service AS AIRPORT_SERVICEalias1 WHERE AIRPORT_SERVICEalias1.city_code IN (SELECT CITYalias1.city_code FROM city AS CITYalias1 WHERE CITYalias1.city_name = 'SAN FRANCISCO'))) AND from_airport IN (SELECT AIRPORT_SERVICEalias0.airport_code FROM airport_service AS AIRPORT_SERVICEalias0 WHERE AIRPORT_SERVICEalias0.city_code IN (SELECT CITYalias0.city_code FROM city AS CITYalias0 WHERE CITYalias0.city_name = 'DALLAS'))) AND connections > 0)
|
### Instruction:
does DL fly from DENVER to 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 ((flight.airline_code = 'DL') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' 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:
give me fares from ATLANTA to BALTIMORE
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare 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_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
What time is Geoffrey Bankowski next teaching 463 ?
### 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 = 463 AND course_offering.semester = semester.semester_id AND instructor.name LIKE '%Geoffrey Bankowski%' 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:
how many times has patient 015-56390 recieved a enteral tube intake: nasoduodenal nostril, r 10f intake in 12/last year?
### 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 = '015-56390')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'enteral tube intake: nasoduodenal nostril, r 10f' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', intakeoutput.intakeoutputtime) = '12'
|
### Instruction:
what's first temperature c (calc) value of patient 10855 on this month/13?
### 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 = 10855)) 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 month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '13' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
please list pm flights from BOSTON 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 ((flight.departure_time <= 2359 AND flight.departure_time >= 1200) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
does AA fly from PHILADELPHIA to DALLAS
### 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 = 'AA') AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
have heart rate's of patient 23070 been less than 61.0 on last month/30?
### 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 = 23070)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 61.0 AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', chartevents.charttime) = '30'
|
### Instruction:
in 05/this year amiodarone 200 mg tab, famotidine (pf) or metoprolol tartrate were prescribed for patient 029-27704?
### 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 = '029-27704')) AND medication.drugname IN ('amiodarone 200 mg tab', 'famotidine (pf)', 'metoprolol tartrate') AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '05'
|
### Instruction:
what flights go from SAN FRANCISCO to DENVER on MONDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND days.day_name = 'MONDAY' AND flight.flight_days = days.days_code 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:
show me round trip fares from NEW YORK to MIAMI
### Response:
|
SELECT DISTINCT fare.fare_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare 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 = 'MIAMI' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
what is the yearly average of output y (ml)-chest tube y - a #1 mid b #1 left lateral output of patient 007-2498 until 04/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 = '007-2498')) AND intakeoutput.celllabel = 'output y (ml)-chest tube y - a #1 mid b #1 left lateral' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) <= '2104-04' GROUP BY STRFTIME('%y', intakeoutput.intakeoutputtime)
|
### Instruction:
tell me the total amount of chest tubes cticu ct 1 output for patient 20801 on 04/01/last year?
### Response:
|
SELECT SUM(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 = 20801)) 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 DATETIME(outputevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', outputevents.charttime) = '04-01'
|
### Instruction:
what are my meal options from BOSTON to DENVER
### Response:
|
SELECT DISTINCT food_service.compartment, food_service.meal_code, food_service.meal_number FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight, food_service 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.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND food_service.meal_code = flight.meal_code
|
### Instruction:
what nonstop flights between BOSTON and WASHINGTON arrive after 1600 o'clock pm
### 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 = 'WASHINGTON' AND flight.arrival_time > 1600 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.stops = 0
|
### Instruction:
patients who have at least 2 of the following risk factors: hypertension; type ii diabetes mellitus ;chronic kidney disease ; prior history of myocardial infarction or angina pectoris ; prior history of cerebral infarction ; peripheral arterial disease
### Response:
|
SELECT * FROM table_test_31 WHERE (CASE WHEN hypertension = 1 THEN 1 ELSE 0 END + CASE WHEN diabetic = 'ii' THEN 1 ELSE 0 END + CASE WHEN mellitus = 1 THEN 1 ELSE 0 END + CASE WHEN kidney_disease = 1 THEN 1 ELSE 0 END + CASE WHEN myocardial_infarction = 1 OR angina = 1 THEN 1 ELSE 0 END + CASE WHEN cerebral_infarction = 1 THEN 1 ELSE 0 END + CASE WHEN peripheral_arterial_disease = 1 THEN 1 ELSE 0 END) >= 2
|
### Instruction:
Histogram of time to first answer.
### Response:
|
SELECT hours_to_first_answer, COUNT(*) AS answer_count FROM (SELECT qId, MIN(hours_to_answer) AS hours_to_first_answer FROM (SELECT questions.Id AS qId, questions.CreationDate AS qCreationDate, answers.Id AS aId, answers.CreationDate AS aCreationDate, CAST((JULIANDAY(CreationDate) - JULIANDAY(questions.CreationDate)) * 24.0 AS INT) AS hours_to_answer FROM (SELECT * FROM Posts WHERE PostTypeId = 1 AND Id IN (SELECT PostId FROM PostTags)) AS questions INNER JOIN (SELECT * FROM Posts WHERE PostTypeId = 2 AND ParentId IN (SELECT PostId FROM PostTags)) AS answers ON questions.Id = answers.ParentId) AS qa GROUP BY qId) AS latency GROUP BY hours_to_first_answer ORDER BY hours_to_first_answer
|
### Instruction:
when was first time patient 7165 was measured with a greater arterial bp [systolic] than 141.0 on the last icu visit?
### 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 = 7165) 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') AND chartevents.valuenum > 141.0 ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
show me patient 10855's total solumedrol mg/kg/min intake amount on this month/21.
### 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 = 10855)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'solumedrol mg/kg/min' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', inputevents_cv.charttime) = '21'
|
### Instruction:
Find contactable statisticians by tag, location etc..
### Response:
|
SELECT Posts.OwnerUserId, Users.AboutMe, Users.Reputation, TagName, COUNT(*) AS UpVotes FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 INNER JOIN Users ON Users.Id = Posts.OwnerUserId WHERE TagName = '##technology##' AND UPPER(Users.Location) LIKE UPPER('%##location##%') AND (Users.AboutMe LIKE '%http%' OR UPPER(Users.AboutMe) LIKE UPPER('%mail%') OR Users.AboutMe LIKE '%@%' OR UPPER(Users.AboutMe) LIKE UPPER('%at%')) GROUP BY TagName, Posts.OwnerUserId, Users.Reputation, Users.AboutMe ORDER BY UpVotes DESC LIMIT 2000
|
### Instruction:
ASP.NET MVC, Django en Laravel.
### Response:
|
SELECT DATEADD(mm, (YEAR(Posts.CreationDate) - 1900) * 12 + MONTH(Posts.CreationDate) - 1, 0) AS Month, 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 WHERE Tags.TagName IN ('agile', 'kanban', 'scrum') 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:
show me all flights from NEW YORK to MIAMI leaving on a TUESDAY
### 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, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MIAMI' AND days.day_name = 'TUESDAY' AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEW YORK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Unanswered questions sorted by answered count.
### Response:
|
SELECT p.Id AS "post_link", p.Score, p.AnswerCount, MAX(a.Score) AS BestAnswerScore, p.LastActivityDate FROM Posts AS p JOIN PostTypes AS pt ON pt.Id = p.PostTypeId JOIN Posts AS a ON a.ParentId = p.Id WHERE p.ClosedDate IS NULL AND pt.Name = 'Question' AND p.AcceptedAnswerId IS NULL AND p.Score >= 0 AND p.CommunityOwnedDate IS NULL AND p.CreationDate < DATEADD(DAY, -7, GETDATE()) GROUP BY p.Id, p.Score, p.AnswerCount, p.LastActivityDate, p.AcceptedAnswerId HAVING MAX(CASE WHEN (a.Score > 0 OR a.OwnerUserId = '##UserId##') THEN 1 ELSE 0 END) = 0 ORDER BY p.AnswerCount DESC, p.Score, p.LastActivityDate
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.