instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
Tag edits which do not change tags.
### Response:
|
WITH tagedits_cte AS (SELECT Ph1.PostId AS pid, Ph1.Id AS phid, MIN(ph2.Id) AS MinId FROM PostHistory AS ph1 INNER JOIN PostHistory AS ph2 ON ph2.PostId = ph1.PostId WHERE (ph2.Id > ph1.Id) AND (ph1.PostHistoryTypeId IN (3, 6, 9)) AND (ph2.PostHistoryTypeId IN (3, 6, 9)) GROUP BY ph1.PostId, Ph1.Id) SELECT t.pid AS "post_link", 'site://posts/' + CAST(t.pid AS TEXT) + '/revisions' AS "revision_history", ph1.Text AS Tags, ph2.CreationDate, ph2.Comment FROM tagedits_cte AS t INNER JOIN PostHistory AS ph1 ON t.phid = ph1.Id INNER JOIN PostHistory AS ph2 ON t.minid = ph2.Id WHERE ph1.Text = ph2.Text ORDER BY pid
|
### Instruction:
does flight UA 281 from BOSTON to DENVER leave on 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 (((days.day_name = 'TUESDAY' AND flight.flight_days = days.days_code AND flight.flight_number = 281) 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) AND flight.airline_code = 'UA'
|
### Instruction:
how much difference there is among patient 71558's potassium change second measured on the current hospital visit compared to the value first measured on the current hospital visit?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 71558 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium') ORDER BY labevents.charttime LIMIT 1 OFFSET 1) - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 71558 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium') ORDER BY labevents.charttime LIMIT 1)
|
### Instruction:
Closed posts by votes on answers. This is used to see how many closed questions have up, down and neutral voted answers. A single post can be in all three categories if there is an answer which is positive, negative and neutral.
### Response:
|
WITH ClosedPostsVotes AS (SELECT p.Id AS "Post Link", SUM(CASE WHEN a.Score > 0 THEN 1 ELSE 0 END) AS Up, SUM(CASE WHEN a.Score < 0 THEN 1 ELSE 0 END) AS Down, SUM(CASE WHEN a.Score = 0 THEN 1 ELSE 0 END) AS Neutral FROM Posts AS p INNER JOIN Posts AS a ON a.ParentId = p.Id WHERE NOT p.ClosedDate IS NULL GROUP BY p.Id) SELECT COUNT(*) AS Questions, SUM(CASE WHEN v.Up > 0 THEN 1 ELSE 0 END) AS Up, SUM(CASE WHEN v.Down > 0 THEN 1 ELSE 0 END) AS Down, SUM(CASE WHEN v.Neutral > 0 THEN 1 ELSE 0 END) AS Neutral FROM ClosedPostsVotes AS v
|
### Instruction:
What percentage of all posts are answers (for top users - including deleted users).
### Response:
|
SELECT p.OwnerUserId AS "user_link", p.OwnerDisplayName, ROUND((SUM(CASE WHEN p.PostTypeId = 2 THEN 1 ELSE 0 END)) * 100.0 / (COUNT(p.Id)), 2) AS "percentage_answers", SUM(p.Score) AS "total_score", COUNT(p.Id) AS "total_posts", SUM(CASE WHEN p.PostTypeId = 1 THEN 1 ELSE 0 END) AS "total_questions", SUM(CASE WHEN p.PostTypeId = 2 THEN 1 ELSE 0 END) AS "total_answers", SUM(CASE WHEN p.PostTypeId = 1 THEN p.Score ELSE 0 END) AS "score_questions", SUM(CASE WHEN p.PostTypeId = 1 THEN p.Score ELSE 0 END) AS "score_answers" FROM Posts AS p GROUP BY p.OwnerUserId, p.OwnerDisplayName ORDER BY SUM(p.Score) DESC LIMIT 500
|
### Instruction:
now i'd like flights from PHILADELPHIA to PITTSBURGH leaving between 1630 and 1730
### 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 <= 1730 AND flight.departure_time >= 1630) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' 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:
i would like a morning flight from MILWAUKEE to DENVER COLORADO please
### 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 = 'MILWAUKEE' 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 state.state_code = CITY_1.state_code AND state.state_name = 'COLORADO') AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
Most popular StackOverflow tags in Jan 2015 to May 2016.
### 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 < '2016-05-01' AND Posts.CreationDate > '2015-01-01' 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) > 10000) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
what stops does DL 838 make from SAN FRANCISCO to ATLANTA
### Response:
|
SELECT DISTINCT flight_stop.stop_airport 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 ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND flight.flight_number = 838 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' AND flight.flight_id = flight_stop.flight_id
|
### Instruction:
i want a flight from CINCINNATI to BURBANK on AA and 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 (((flight.departure_time <= 1200 AND flight.departure_time >= 1800) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CINCINNATI' 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.airline_code = 'AA'
|
### Instruction:
Questions which attract controversial answers. Search for posts which have attracted significantly more controversial answers than good ones
### Response:
|
SELECT p.Id AS "post_link", p.Score FROM (SELECT p.ParentId, COUNT(*) AS ContACnt FROM (SELECT PostId, up = SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END), down = SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) FROM Votes AS v JOIN Posts AS p ON p.Id = v.PostId WHERE VoteTypeId IN (2, 3) AND PostTypeId = 2 GROUP BY PostId) AS ContA JOIN Posts AS p ON ContA.PostId = p.Id WHERE down > (up / '##UVDVRatio:int##') AND (down + up) > '##MinVotes:int##' AND p.Score > 0 GROUP BY p.ParentId) AS ContQ JOIN Posts AS p ON ContQ.ParentId = p.Id WHERE ContQ.ContACnt > (p.AnswerCount / 2) ORDER BY Score DESC
|
### Instruction:
show me the one way flights from ATLANTA 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND fare.round_trip_required = 'NO' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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 are the four most commonly given lab tests for patients who have previously received amputation during the same hospital encounter?
### Response:
|
SELECT t3.labname FROM (SELECT t2.labname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'amputation') AS t1 JOIN (SELECT patient.uniquepid, lab.labname, lab.labresulttime, patient.patienthealthsystemstayid FROM lab JOIN patient ON lab.patientunitstayid = patient.patientunitstayid) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.labresulttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.labname) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
What area do I get B 's in the most ?
### Response:
|
SELECT DISTINCT DERIVED_TABLEalias0.DERIVED_FIELDalias1 FROM (SELECT AREAalias0.area, COUNT(*) INNER JOIN student_record ON student_record.course_id = AREAalias0.course_id WHERE student_record.grade LIKE 'B' AND student_record.student_id = 1 GROUP BY AREAalias0.area) AS DERIVED_TABLEalias0 WHERE DERIVED_TABLEalias0.DERIVED_FIELDalias1 = (SELECT COUNT(*) AS DERIVED_FIELDalias2 FROM area AS AREAalias1, student_record AS STUDENT_RECORDalias1 WHERE STUDENT_RECORDalias1.course_id = AREAalias1.course_id AND STUDENT_RECORDalias1.grade LIKE 'B' AND STUDENT_RECORDalias1.student_id = 1 GROUP BY AREAalias1.area ORDER BY DERIVED_FIELDalias2 DESC LIMIT 1)
|
### Instruction:
\\ bug query on markdown. with bits stolen from http://data.stackexchange.com/stackoverflow/query/494264/longest-answers-by-markdown
### Response:
|
SELECT p.Id AS "post_link", 'site://posts/' + CAST(p.Id AS TEXT) + '/edit|' + 'Edit' AS "edit_link", p.OwnerUserId AS "user_link", p.CreationDate FROM Posts AS p, PostHistory AS ph WHERE ph.PostId = p.Id AND ph.PostHistoryTypeId IN (2, 5, 8) AND NOT EXISTS(SELECT * FROM PostHistory AS phtwo WHERE phtwo.PostId = p.Id AND phtwo.PostHistoryTypeId IN (2, 5, 8) AND phtwo.CreationDate > ph.CreationDate) AND YEAR(p.CreationDate) < 2014 AND (REPLACE(REPLACE(ph.Text, '\\', ''), ' ', 'X') LIKE '%\XXXX%') ORDER BY p.OwnerUserId DESC
|
### Instruction:
is the arterial bp [systolic] of patient 18517 normal in 06/last year?
### 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 = 18517)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', chartevents.charttime) = '06'
|
### Instruction:
For classes with labs , who are the professors not teaching them ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor, course, course_offering, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course_offering.offering_id = offering_instructor.offering_id AND instructor.instructor_id = offering_instructor.instructor_id AND NOT instructor.instructor_id IN (SELECT DISTINCT offering_instructor.instructor_id FROM course AS COURSEalias0, course_offering AS COURSE_OFFERINGalias0, offering_instructor AS OFFERING_INSTRUCTOR WHERE COURSEalias0.course_id = COURSE_OFFERINGalias0.course_id AND COURSEalias0.has_lab = 'Y' AND COURSE_OFFERINGalias0.offering_id = offering_instructor.offering_id)
|
### Instruction:
on 09/08/last year, what was the last value of arterial bp [diastolic] for patient 15754?
### 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 = 15754)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', chartevents.charttime) = '09-08' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
i would like to book a round trip flight from KANSAS CITY to CHICAGO
### 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CHICAGO' AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'KANSAS CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
when was the first time on this month/31 that patient 19412 had the minimum arterial bp [diastolic] for?
### 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 month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '31' ORDER BY chartevents.valuenum, chartevents.charttime LIMIT 1
|
### Instruction:
median response time by tag (for any answer).
### Response:
|
WITH my_table AS (SELECT T.TagName, CAST((JULIANDAY(CreationDate) - JULIANDAY(P.CreationDate)) * 1440.0 AS INT) AS ResponseMinutes FROM Posts AS P INNER JOIN Posts AS A ON P.AcceptedAnswerId = A.Id INNER JOIN PostTags AS PT ON P.Id = PT.PostId INNER JOIN Tags AS T ON T.Id = PT.TagId WHERE P.PostTypeId = 1 AND (T.TagName = 'xamarin') AND p.AnswerCount > 0 AND P.CreationDate > '2016-12-01 00:00:00' AND p.CreationDate < '2017-01-01 00:00:00') SELECT DISTINCT TagName, PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY ResponseMinutes) OVER (PARTITION BY TagName) AS Median FROM my_table
|
### Instruction:
what are the changes in calculated total co2 of patient 27172 last measured on the current hospital visit compared to the first value measured on the current hospital visit?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27172 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'calculated total co2') ORDER BY labevents.charttime DESC LIMIT 1) - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27172 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'calculated total co2') ORDER BY labevents.charttime LIMIT 1)
|
### Instruction:
what is the fare from ATLANTA to BOSTON on COACH one way
### 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, fare_basis 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 = 'BOSTON' AND fare.from_airport = AIRPORT_SERVICE_0.airport_code AND fare.to_airport = AIRPORT_SERVICE_1.airport_code) AND fare.round_trip_required = 'NO') AND fare_basis.class_type = 'COACH' AND fare.fare_basis_code = fare_basis.fare_basis_code
|
### Instruction:
Cumulative, voteid-scaled up/down history of a single post.
### Response:
|
SELECT RANK() OVER (ORDER BY Id) AS No, SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) OVER (ORDER BY Id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS Ups, SUM(CASE WHEN VoteTypeId = 3 THEN -1 ELSE 0 END) OVER (ORDER BY Id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS Downs, SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE -1 END) OVER (ORDER BY Id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS Score FROM Votes WHERE PostId = '##PostId:int##' AND VoteTypeId BETWEEN 2 AND 3 UNION ALL SELECT 0 AS No, 0 AS Ups, 0 AS Downs, 0 AS Score ORDER BY No
|
### Instruction:
what's the weight difference of patient 021-49416's body second measured on the last hospital visit compared to the value first measured on the last hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-49416' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) 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 = '021-49416' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
did the platelet count value of patient 15986 last measured on the current hospital visit be less than second to last measured on the current hospital visit?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15986 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'platelet count') ORDER BY labevents.charttime DESC LIMIT 1) < (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15986 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'platelet count') ORDER BY labevents.charttime DESC LIMIT 1 OFFSET 1)
|
### Instruction:
find travel arrangements for a round trip flight from DALLAS 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
2 or more systemic inflammatory response syndrome ( sirs ) criteria: white blood cell count less than 4000 per mm3, greater than 12000 per mm3, or differential with greater than 10 % immature forms; heart rate greater than 90 beats per minute; respiratory rate greater than 20 breaths per minute or paco2 less than 32 mmhg; temperature less than 36 c or greater than 38 c
### Response:
|
SELECT * FROM table_train_8 WHERE (CASE WHEN white_blood_cell_count_wbc < 4000 OR white_blood_cell_count_wbc > 12000 OR immature_form > 10 THEN 1 ELSE 0 END + CASE WHEN heart_rate > 90 THEN 1 ELSE 0 END + CASE WHEN respiratory_rate > 20 OR paco2 < 32 THEN 1 ELSE 0 END + CASE WHEN temperature > 38 OR temperature < 36 THEN 1 ELSE 0 END) >= 2
|
### Instruction:
what is the earliest flight between BOS and BWI
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport AS AIRPORT_0, airport AS AIRPORT_1, flight WHERE (AIRPORT_0.airport_code = 'BOS' AND AIRPORT_1.airport_code = 'BWI' AND flight.from_airport = AIRPORT_0.airport_code AND flight.to_airport = AIRPORT_1.airport_code) AND flight.departure_time = (SELECT MIN(FLIGHTalias1.departure_time) FROM airport AS AIRPORTalias2, airport AS AIRPORTalias3, flight AS FLIGHTalias1 WHERE AIRPORTalias2.airport_code = 'BOS' AND AIRPORTalias3.airport_code = 'BWI' AND FLIGHTalias1.from_airport = AIRPORTalias2.airport_code AND FLIGHTalias1.to_airport = AIRPORTalias3.airport_code)
|
### Instruction:
please list the MONDAY morning flights from KANSAS CITY 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, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' 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 = 'KANSAS CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
Posts that are one upvote away from earning you 'Necromancer'. Returns a list of questions for a given user that have 4 upvotes and are at least 60 days old, meaning the next upvote on any of the posts will earn the user a Necromancer badge.
### Response:
|
SELECT p.ParentId AS "post_link", DATEDIFF(day, parent.CreationDate, CreationDate) AS "days_after_ask_for_answer", COUNT(*) AS voteCount FROM Posts AS p INNER JOIN Votes AS v ON v.PostId = p.Id AND v.VoteTypeId = 2 INNER JOIN Posts AS parent ON parent.Id = p.ParentId WHERE p.OwnerUserId = @userId AND DATEDIFF(day, parent.CreationDate, CreationDate) >= 60 GROUP BY p.ParentId, p.Id, DATEDIFF(day, parent.CreationDate, CreationDate) HAVING COUNT(*) >= 5 ORDER BY voteCount DESC, DATEDIFF(day, parent.CreationDate, CreationDate) DESC
|
### Instruction:
Users with many answers with a high VLQ survival ratio.
### Response:
|
SELECT OwnerUserId AS "user_link", OwnerUserId AS Id, DENSE_RANK() OVER (ORDER BY VLQAnswerCount DESC) AS VLQRank, DENSE_RANK() OVER (ORDER BY AnswerCount DESC) AS AnswerRank FROM (SELECT Posts.OwnerUserId, MIN(Users.Reputation) AS Reputation, MIN(AnswerStat.AnswerCount) AS AnswerCount, COUNT(*) AS VLQAnswerCount FROM ReviewTasks, Posts, Users LEFT JOIN (SELECT OwnerUserId, COUNT(*) AS AnswerCount FROM Posts WHERE PostTypeId = 2 GROUP BY OwnerUserId) AS AnswerStat ON Users.Id = AnswerStat.OwnerUserId WHERE ReviewTasks.ReviewTaskTypeId = 3 AND Posts.Id = ReviewTasks.PostId AND Posts.OwnerUserId = Users.Id AND Posts.PostTypeId = 2 GROUP BY Posts.OwnerUserId) AS Raw ORDER BY VLQAnswerCount DESC, OwnerUserId
|
### Instruction:
when was the last time the respiratory rate of patient 4401 was measured on this month/29 at greater than 23.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 = 4401)) 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 > 23.0 AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '29' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
list all flights arriving or leaving DENVER between 2000 and 2100
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (((arrival_time <= 2100 AND arrival_time >= 2000) AND to_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 = 'DENVER'))) OR ((departure_time <= 2100 AND departure_time >= 2000) AND from_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 = 'DENVER'))))
|
### Instruction:
Most popular StackOverflow tags until May 2014.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS "2014Rank", ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS TotalRank, rate.Rate AS QuestionsIn2014, 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 < '2015-01-01' AND Posts.CreationDate > '2014-01-01' 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:
For the 400 / 500 -level SCAND courses , which have the lightest workload ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN program_course WHERE ((course.number < 400 + 100 AND course.number >= 400) OR (course.number < 500 + 100 AND course.number >= 500)) AND course.department = 'SCAND' AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM course AS COURSEalias1 INNER JOIN program_course AS PROGRAM_COURSEalias1 WHERE ((COURSEalias1.number < 400 + 100 AND COURSEalias1.number >= 400) OR (COURSEalias1.number < 500 + 100 AND COURSEalias1.number >= 500)) AND COURSEalias1.department = 'SCAND')
|
### Instruction:
what are the nonstop flights between SAN JOSE and HOUSTON TEXAS
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE ((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 = 'SAN JOSE')) 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 = 'HOUSTON' AND CITYalias1.state_code IN (SELECT STATEalias0.state_code FROM state AS STATEalias0 WHERE STATEalias0.state_name = 'TEXAS'))))) AND stops = 0)
|
### Instruction:
show me the fares for DL flights from DALLAS to SAN FRANCISCO
### 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 = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight_fare.fare_id = fare.fare_id AND flight.airline_code = 'DL' AND flight.flight_id = flight_fare.flight_id
|
### Instruction:
For the least difficult Core classes , which one has the most students ?
### Response:
|
SELECT DISTINCT department, name, number FROM course WHERE course_id IN (SELECT PROGRAM_COURSE_ID FROM program_course AS PROGRAM_COURSE WHERE PROGRAM_WORKLOAD = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM program_course AS PROGRAM_COURSEalias1 WHERE PROGRAM_COURSEalias1.category LIKE '%Core%')) AND num_enrolled = (SELECT MAX(COURSEalias1.num_enrolled) FROM course AS COURSEalias1 WHERE COURSEalias1.course_id IN (SELECT PROGRAM_COURSEalias2.course_id FROM program_course AS PROGRAM_COURSEalias2 WHERE PROGRAM_COURSEalias2.workload = (SELECT MIN(PROGRAM_COURSEalias3.workload) FROM program_course AS PROGRAM_COURSEalias3 WHERE PROGRAM_COURSEalias3.category = 'Core')))
|
### Instruction:
what was the last arterial bp [diastolic] value for patient 15107 on 11/21/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 = 15107)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', chartevents.charttime) = '11-21' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
Active Users -- Posted Questions Each Day of a Week.
### Response:
|
SELECT UserId, UserName, PostYear, PostWeek, COUNT(*) AS ActiveDaysPerWeek FROM (SELECT u.Id AS UserId, u.DisplayName AS UserName, TIME_TO_STR(p.CreationDate, '%Y') AS PostYear, TIME_TO_STR(p.CreationDate, '%W') AS PostWeek, TIME_TO_STR(p.CreationDate, '%W') AS PostWeekday, COUNT(*) AS PostsPerDay FROM Users AS u INNER JOIN Posts AS p ON (u.Id = p.OwnerUserId) WHERE p.PostTypeId = 1 GROUP BY u.Id, u.DisplayName, TIME_TO_STR(p.CreationDate, '%Y'), TIME_TO_STR(p.CreationDate, '%W'), TIME_TO_STR(p.CreationDate, '%W')) AS rv GROUP BY UserId, UserName, PostYear, PostWeek HAVING COUNT(*) = 7 ORDER BY UserId, PostYear, PostWeek
|
### Instruction:
indicate the daily maximum arterial bp [diastolic] of patient 5544 in 04/this 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 = 5544)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', chartevents.charttime) = '04' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
|
### Instruction:
show me all flights and fares from DENVER to SAN FRANCISCO
### Response:
|
SELECT DISTINCT fare.fare_id, flight.airline_code, flight.flight_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 = 'SAN FRANCISCO' 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:
For IOE courses in the 400 / 500 level , which have the least workload ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number, program_course.workload FROM course INNER JOIN program_course WHERE ((course.number < 400 + 100 AND course.number >= 400) OR (course.number < 500 + 100 AND course.number >= 500)) AND course.department = 'IOE' AND program_course.workload = (SELECT MIN(PROGRAM_COURSEalias1.workload) FROM course AS COURSEalias1 INNER JOIN program_course AS PROGRAM_COURSEalias1 WHERE ((COURSEalias1.number < 400 + 100 AND COURSEalias1.number >= 400) OR (COURSEalias1.number < 500 + 100 AND COURSEalias1.number >= 500)) AND COURSEalias1.department = 'IOE')
|
### Instruction:
show me fares from DALLAS to BALTIMORE that cost less than 300 dollars
### 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 fare.one_direction_cost < 300 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:
Users by Popular Question ratio. (only users with at least 10 Popular Questions)
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS SeptemberRank, 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 < '2019-09-01' AND Posts.CreationDate > '2019-08-01' 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:
Reinvention base units - with.
### Response:
|
SELECT reinvented.TagName AS reinvented, 'with' AS presence, '##Invented:string##' AS invented, answerer.Id AS answerer_userid, answers.Id AS answer_id, answers.Score, answerer.Reputation AS answerer_reputation FROM Tags AS reinvented, Users AS answerer, Posts AS questions, Posts AS answers, PostTags AS ptri WHERE questions.PostTypeId = 1 AND questions.Id = ptri.PostId AND ptri.TagId = reinvented.Id AND questions.Id = answers.ParentId AND answers.PostTypeId = 2 AND answers.OwnerUserId = answerer.Id AND answerer.Reputation BETWEEN 2 AND 100000 AND reinvented.TagName = '##Reinvented:string##' AND '##Invented:string##' IN (SELECT TagName FROM Tags AS invented, PostTags AS pti WHERE invented.Id = pti.TagId AND pti.PostId = questions.Id)
|
### Instruction:
when was first time patient 11362 was measured with a respiratory rate less than 26.0 on last month/24?
### 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 = 11362)) 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 < 26.0 AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', chartevents.charttime) = '24' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
Average answer length (and min and max).
### Response:
|
SELECT (TIME_TO_STR(p.CreationDate, '%y') + (TIME_TO_STR(p.CreationDate, '%W') - 1) / 52.0) AS YR_WK, MIN(LENGTH(p.Body)) AS "min", AVG(LENGTH(p.Body)) AS "average", MAX(LENGTH(p.Body)) AS "max" FROM Users AS u, Posts AS p WHERE p.PostTypeId = 2 AND p.Score > 0 AND p.CreationDate >= '2015-01-01 00:00' GROUP BY (TIME_TO_STR(p.CreationDate, '%y') + (TIME_TO_STR(p.CreationDate, '%W') - 1) / 52.0) ORDER BY (TIME_TO_STR(p.CreationDate, '%y') + (TIME_TO_STR(p.CreationDate, '%W') - 1) / 52.0)
|
### Instruction:
Up / Down Vote ratio on Posts, by month.
### Response:
|
SELECT gVt.zMonth AS "month", (gVt.upVt * 1.0 / gVt.dwnVt) * (1750000 / 25) AS "up/down_vote_ratio,_on_posts_(q+a)_-scaled", gVt.upVt AS "upvote_%", gVt.dwnVt AS "downvote_%" FROM (SELECT zMonth = DATEADD(month, DATEDIFF(month, 0, CreationDate), 0), upVt = SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END), dwnVt = SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) FROM Votes AS v GROUP BY DATEADD(month, DATEDIFF(month, 0, CreationDate), 0)) AS gVt WHERE gVt.dwnVt != 0 ORDER BY gVt.zMonth
|
### Instruction:
Language Trends (# Questions per Tag per Month).
### 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 ('java', 'python', 'r', 'sas', 'jmp', 'stata', 'spss', 'matlab') 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:
how much does patient 016-5834's weight change from the value second measured on the last hospital visit compared to the first value measured on the last hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-5834' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) 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 = '016-5834' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
all one way flights between BOSTON and PHILADELPHIA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND fare.round_trip_required = 'NO' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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:
Number of Questions per week for 3 given tags, over a specified period. The query also avoids including the latest week since the resulting graph is so ugly, which probably depends on which day of week the query is made. I don't understand the query well enough to be extra sure.
See http://meta.stackoverflow.com/a/260571
### Response:
|
SELECT DATEADD(week, DATEDIFF(week, 0, CreationDate), 0) AS week, TagName, COUNT(*) FROM PostTags AS pt JOIN Posts AS q ON q.Id = pt.PostId JOIN Tags AS t ON t.Id = pt.TagId WHERE TagName IN (@tag0, @tag1, @tag2) AND q.CreationDate BETWEEN DATEADD(ww, -@weeks, GETDATE()) AND DATEADD(ww, -1, GETDATE()) GROUP BY DATEADD(week, DATEDIFF(week, 0, CreationDate), 0), TagName ORDER BY DATEADD(week, DATEDIFF(week, 0, CreationDate), 0)
|
### Instruction:
Questions Using Popular Tags In January 2019. Questions Using Popular Tags In January 2019
Tags with rate of use over 4 times on this site.
### Response:
|
SELECT Id AS "post_link", Id, CreationDate, AnswerCount, CommentCount, rate.TagId FROM Posts, PostTags, (SELECT COUNT(PostId) AS Rate, TagId FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate < '2019-03-01' AND Posts.CreationDate > '2019-01-01' GROUP BY TagId, TagName HAVING COUNT(PostId) > 4) AS rate WHERE rate.TagId = PostTags.TagId AND Posts.Id = PostId AND CreationDate > '2019-01-01' AND CreationDate < '2019-01-03' AND DeletionDate IS NULL AND AnswerCount > 0 AND CommentCount > 0
|
### Instruction:
how many patients were prescribed with acetaminophen 650 mg re supp within 2 months after the diagnosis of hepatorenal syndrome,?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hepatorenal syndrome') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'acetaminophen 650 mg re supp') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
qpd for different sites before and after. with credits to glorfindel for a decent chunk of the code https://data.stackexchange.com/stackoverflow/revision/520226/657753/#graph
an attempt to compare questions per day (and therefore general site activity) before and after the recent meta uproar
### Response:
|
SELECT DATEADD(day, DATEDIFF(day, 0, creationdate), 0), COUNT(*) FROM Posts WHERE PostTypeId = 2 AND CreationDate BETWEEN @StartDate AND @EndDate GROUP BY DATEADD(day, DATEDIFF(day, 0, creationdate), 0) UNION SELECT DATEADD(day, DATEDIFF(day, 0, creationdate), 0), COUNT(*) FROM Posts WHERE PostTypeId = 2 AND CreationDate BETWEEN @StartDate2 AND @EndDate2 GROUP BY DATEADD(day, DATEDIFF(day, 0, creationdate), 0) ORDER BY DATEADD(day, DATEDIFF(day, 0, creationdate), 0)
|
### Instruction:
Number of Compile-to-JS askers by Month.
### Response:
|
SELECT Tag, STR(Year) + '-' + REPLACE(STR(Month, 2), SPACE(1), '0') AS Month, COUNT(DISTINCT OwnerUserId) AS Askers FROM (SELECT ViewCount, OwnerUserId, MONTH(CreationDate) AS Month, YEAR(CreationDate) AS Year, CASE WHEN Tags LIKE '%<flowtype>%' THEN 'FlowType' ELSE CASE WHEN Tags LIKE '%<typescript>%' THEN 'TypeScript' ELSE CASE WHEN Tags LIKE '%<google-closure-compiler>%' THEN 'Closure' ELSE CASE WHEN Tags LIKE '%<coffeescript>%' THEN 'CoffeeScript' ELSE 'Other' END END END END AS Tag FROM Posts WHERE PostTypeId = 1 AND (Tags LIKE '%<typescript>%' OR Tags LIKE '%<coffeescript>%' OR Tags LIKE '%<flowtype>%' OR Tags LIKE '%<google-closure-compiler>%')) AS SubQry GROUP BY Month, Year, Tag ORDER BY Month DESC, Tag
|
### Instruction:
round trip HOUSTON to LAS VEGAS nonstop
### 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 = 'HOUSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'LAS VEGAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.stops = 0
|
### Instruction:
show me all the TW flights from INDIANAPOLIS to HOUSTON that arrive around 11am
### 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 <= 1130 AND flight.arrival_time >= 1030) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'HOUSTON' 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:
what are the seating capacities of planes between PITTSBURGH and BALTIMORE
### Response:
|
SELECT DISTINCT aircraft.aircraft_code FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, equipment_sequence, 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 = 'BALTIMORE' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
Most popular StackOverflow tags in date range.
### 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 < '2012-09-01' AND Posts.CreationDate > '2012-08-01' 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 AND Tags.TagName = 'dart' GROUP BY TagName HAVING COUNT(PostId) > 800) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
flights between MILWAUKEE and ORLANDO one way
### 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO' AND fare.round_trip_required = 'NO' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MILWAUKEE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
i'm interested in round trip flights from BOSTON to 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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:
Name the classes that will be offered in the next 6 semesters .
### Response:
|
SELECT DISTINCT course.name, course.number, semester.semester, semester.year FROM course, course_offering, semester WHERE ((semester.semester = 'FA' AND semester.year = 2016) OR (semester.semester = 'FA' AND semester.year = 2017) OR (semester.semester = 'FA' AND semester.year = 2018) OR (semester.semester = 'WN' AND semester.year = 2017) OR (semester.semester = 'WN' AND semester.year = 2018) OR (semester.semester = 'WN' AND semester.year = 2019)) AND course.course_id = course_offering.course_id AND course.department = 'EECS' AND semester.semester_id = course_offering.semester ORDER BY semester.year, semester.semester
|
### Instruction:
Most popular StackOverflow tags in <year>.
### Response:
|
SELECT PostId, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate >= '2012-01-01' AND Posts.CreationDate < '2012-02-01' AND TagName IN ('javascript', 'java', 'php', 'c#', 'html', 'python', 'css', 'c++', 'mysql', 'sql', 'objective-c', 'asp.net', 'c', 'json', 'r', 'ruby', '.net', 'xml', 'html5', 'vb.net', 'swift', 'bash', 'matlab', 'vba', 'css3', 'python-2.7', 'scala', 'excel-vba', 'shell', 'perl', 'jsp', 'xaml', 'powershell', 'batch-file', 'c++11', 'python-3.x', 'tsql', 'haskell', 'delphi', 'actionscript-3')
|
### Instruction:
Getting city wise reputation and total reputation in that city.. Just change cityname per your need.
### Response:
|
WITH test1 AS (SELECT DISTINCT u.Id, DisplayName, Reputation, Location, COUNT(p.Id) OVER (PARTITION BY u.Id) AS "questions_answered" FROM Users AS u LEFT JOIN Posts AS p ON u.Id = p.OwnerUserId WHERE LOWER(Location) LIKE '%visak%') /* Select row_number() over(order by 'questions_answered' desc) as rownum,*,sum(reputation) over() as 'total_stackoverflow_reputation_in_your_city' from test1 order by 'questions_answered' desc */ SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY 'questions_answered' DESC) AS "your_position", *, SUM(Reputation) OVER () AS "total_stackoverflow_reputation_in_your_city" FROM test1) AS t1 WHERE LOWER(t1.DisplayName) LIKE '%pavan kumar aryasomayajulu%'
|
### Instruction:
how much weight is patient 006-118236's change last measured on the last hospital visit compared to the first value measured on the last hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-118236' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-118236' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
how many fares are there one way from TACOMA to MONTREAL
### Response:
|
SELECT COUNT(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 = 'TACOMA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MONTREAL' AND fare.round_trip_required = 'NO' 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 much is patient 11826's chloride difference of last measured on the current hospital visit compared to the first value measured on the current hospital visit?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11826 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'chloride') ORDER BY labevents.charttime DESC LIMIT 1) - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11826 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'chloride') ORDER BY labevents.charttime LIMIT 1)
|
### Instruction:
what is patient 017-101426's weight change from the last value measured on the first hospital visit compared to the first value measured on the first hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-101426' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) - (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-101426' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
How many of my edits have been rolled back?. Lists all of your posts where someone else performed a rollback after your edit.
There could be some false positives here, where someone edited after you and the rollback just reverted their changes (and not yours).
### Response:
|
SELECT DISTINCT edits.PostId AS "post_link", edits.Comment AS "edit_comment", edits.CreationDate AS "edit_date", rollbacks.Comment AS "rollback_comment", rollbacks.CreationDate AS "rollback_date" FROM PostHistory AS edits INNER JOIN PostHistory AS rollbacks ON edits.PostId = rollbacks.PostId AND rollbacks.CreationDate > edits.CreationDate WHERE edits.PostHistoryTypeId IN (4, 5, 6) AND rollbacks.PostHistoryTypeId IN (7, 8, 9) AND edits.UserId = '##UserId?117549##' AND rollbacks.UserId != '##UserId?117549##'
|
### Instruction:
Posts with Specific Text and a Minimum Number of Favorites.
### Response:
|
SELECT P.Id AS "post_link", P.FavoriteCount FROM Votes AS V, Posts AS P, PostTypes AS Pt, VoteTypes AS Vt WHERE P.Id = V.PostId AND P.PostTypeId = Pt.Id AND V.VoteTypeId = Vt.Id AND Pt.Id = 1 AND Vt.Id = 5 AND P.Score > 0 AND P.DeletionDate IS NULL AND P.CommunityOwnedDate IS NULL AND NOT P.OwnerUserId IS NULL AND NOT P.AnswerCount IS NULL AND P.ClosedDate IS NULL AND NOT P.CommentCount IS NULL AND P.FavoriteCount >= '##min##' AND P.Body LIKE '%##text##%' AND (SELECT COUNT(V2.PostId) FROM Votes AS V2 WHERE V.VoteTypeId = 5 AND V2.PostId = P.Id) >= '##min##' GROUP BY P.Id, P.FavoriteCount
|
### Instruction:
list flights from ONTARIO CALIFORNIA to ORLANDO
### Response:
|
SELECT DISTINCT flight_id FROM flight WHERE (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 = 'ONTARIO' AND CITYalias0.state_code IN (SELECT STATEalias0.state_code FROM state AS STATEalias0 WHERE STATEalias0.state_name = 'CALIFORNIA')))) 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 = 'ORLANDO')))
|
### Instruction:
what was the first value of arterial bp [systolic] patient 2514 had on 07/08/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 = 2514)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', chartevents.charttime) = '07-08' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
what are the afternoon flights leaving from DALLAS to SAN FRANCISCO 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 (((flight.departure_time <= 1200 AND flight.departure_time >= 1800) 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 = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
Most Popular Tags Till Date This Year 2017.
### 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 QuestionsIn2107, 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 < '2017-08-01' AND Posts.CreationDate > '2017-01-01' 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:
when is patient 4758's arterial bp [systolic] last measured on 07/30/this year?
### 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 = 4758)) 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 year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', chartevents.charttime) = '07-30' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
Stackoverflow tag popularity - Year 2013.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS YearRank, ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS TotalRank, rate.Rate AS QuestionsIn2013, 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 < '2015-01-01' AND Posts.CreationDate > '2014-01-01' 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:
Interesting Ubuntu trends (# of Questions per Month).
### 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 ('server', 'windows', 'upgrade', 'application-development', 'package-management', 'juju', 'eclipse') 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:
is there a flight between PHILADELPHIA and DENVER that leaves PHILADELPHIA around 2 o'clock 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 ((flight.departure_time <= 1430 AND flight.departure_time >= 1330) 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 = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
all flights from BALTIMORE to ATLANTA between 1300 o'clock and 1500 o'clock 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 ((flight.departure_time <= 1500 AND flight.departure_time >= 1300) 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 = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
show me round trip flights from BURBANK to SEATTLE
### 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SEATTLE' AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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
|
### Instruction:
show all WEDNESDAY morning flights from DENVER to BOSTON
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' 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) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
which airlines fly from BWI to DALLAS FORT WORTH
### Response:
|
SELECT DISTINCT airline.airline_code FROM airline, airport, 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 = 'FORT WORTH' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND airport.airport_code = 'BWI' AND flight.airline_code = airline.airline_code AND flight.from_airport = airport.airport_code
|
### Instruction:
Percentage of posts made each day with a given tag.
### Response:
|
SELECT TIME_TO_STR(Posts.CreationDate, '%Y') AS "Year", TIME_TO_STR(Posts.CreationDate, '%m') AS "Month", TIME_TO_STR(Posts.CreationDate, '%d') AS "Day", COUNT(*) AS "Total" FROM PostTags AS pt JOIN Posts AS posts ON pt.PostId = Posts.Id JOIN Tags AS tags ON pt.TagId = Tags.Id WHERE Tags.TagName IN ('##tag##') GROUP BY TIME_TO_STR(Posts.CreationDate, '%Y'), TIME_TO_STR(Posts.CreationDate, '%m'), TIME_TO_STR(Posts.CreationDate, '%d'), Tags.TagName ORDER BY TIME_TO_STR(Posts.CreationDate, '%Y') DESC, TIME_TO_STR(Posts.CreationDate, '%m') DESC, TIME_TO_STR(Posts.CreationDate, '%d') DESC
|
### Instruction:
okay what flights are there US from ORLANDO to CLEVELAND leaving 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 (((flight.departure_time <= 1200 AND flight.departure_time >= 1800) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CLEVELAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'US'
|
### Instruction:
what are patient 65582's changes in amylase last measured on the current hospital visit compared to the first value measured on the current hospital visit?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 65582 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'amylase') ORDER BY labevents.charttime DESC LIMIT 1) - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 65582 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'amylase') ORDER BY labevents.charttime LIMIT 1)
|
### Instruction:
total score of a tag. http://meta.stackexchange.com/questions/242611/how-can-i-calculate-the-total-score-of-a-tag#242611
### Response:
|
SELECT SUM(upvote) AS totup, SUM(downvote) AS totdown, SUM(upvote) * 5 - SUM(downvote) * 2 AS "score" FROM (SELECT p.Id, SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS upvote, SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS downvote FROM Posts AS p INNER JOIN PostTags AS pt ON pt.PostId = p.Id INNER JOIN Tags AS t ON t.Id = pt.TagId INNER JOIN Votes AS v ON v.PostId = p.Id WHERE t.TagName = '##tag:String##' AND v.VoteTypeId IN (2, 3) AND p.PostTypeId = 1 GROUP BY p.Id) AS basedata
|
### Instruction:
Questions with stack trace pattern.
### Response:
|
SELECT CASE WHEN DeletionDate IS NULL THEN 1 ELSE 0 END, CASE WHEN ClosedDate IS NULL THEN 1 ELSE 0 END, COUNT(*) AS Questions, AVG(CAST(Score AS FLOAT)) AS AvgScore, AVG(CAST(ViewCount AS FLOAT)) AS AvgViewCount, AVG(CAST(AnswerCount AS FLOAT)) AS AvgAnswerCount, AVG(CAST(FavoriteCount AS FLOAT)) AS AvgFavoriteCount FROM Posts WHERE PostTypeId = 1 AND DeletionDate IS NULL AND ClosedDate IS NULL AND NOT AcceptedAnswerId IS NULL AND Tags LIKE '%java%' AND CreationDate >= '2017-10-01' AND CreationDate < '2018-01-01' AND Body LIKE '%at %.java:% %at %.java:%' GROUP BY CASE WHEN DeletionDate IS NULL THEN 1 ELSE 0 END, CASE WHEN ClosedDate IS NULL THEN 1 ELSE 0 END
|
### Instruction:
please show me all round trip flights from NEW YORK to MIAMI
### 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MIAMI' AND NOT fare.round_trip_cost IS NULL AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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:
i want a one way ticket from DALLAS 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, fare, flight, flight_fare WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND fare.round_trip_required = 'NO' AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id 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.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
when was first time patient 739 was measured with a less respiratory rate than 21.0 on this month/22?
### 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 = 739)) 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 < 21.0 AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '22' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
Most Popular Tags In 2016.
### Response:
|
SELECT num.TagName AS Tag, ROW_NUMBER() OVER (ORDER BY rate.Rate DESC) AS YearRank, ROW_NUMBER() OVER (ORDER BY num.Num DESC) AS OverallRank, rate.Rate AS QuestionsIn2016, num.Num AS OverallQuestions FROM (SELECT COUNT(PostId) AS Rate, TagName FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate < '2016-12-31' AND Posts.CreationDate > '2016-01-01' 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:
Most popular StackOverflow tags in 2013.
### 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 QuestionsIn2013, 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 < '2014-12-31' AND Posts.CreationDate > '2014-01-01' 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:
Highest voted comment vs. answer score 2D histogram.
### Response:
|
SELECT sel.Idx - (sel.Idx / '##N##') * '##N##' AS "answer_score", sel.Idx / '##N##' AS "comment_score", COUNT(sel.Idx) AS "occurence" FROM (SELECT sel.AScore * '##N##' + sel.CScore AS "idx" FROM (SELECT CASE WHEN a.Score < '##N##' THEN a.Score ELSE '##N##' END AS "ascore", CASE WHEN c.Score < '##N##' THEN c.Score ELSE '##N##' END AS "cscore" FROM Posts AS a INNER JOIN (SELECT c.PostId, MAX(c.Score) AS "score" FROM Comments AS c WHERE c.Score > 0 GROUP BY c.PostId) AS c ON a.Id = c.PostId WHERE a.PostTypeId = 2 AND a.Score >= 0) AS sel) AS sel GROUP BY sel.Idx ORDER BY sel.Idx
|
### Instruction:
on this month/21, was patient 10855's arterial bp [diastolic] ever less than 61.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 = 10855)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') AND chartevents.valuenum < 61.0 AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', chartevents.charttime) = '21'
|
### Instruction:
okay i would like to know the type of aircraft used on a flight from CLEVELAND to DALLAS please
### Response:
|
SELECT DISTINCT aircraft.basic_type FROM aircraft, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, equipment_sequence, flight 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 = 'DALLAS' AND equipment_sequence.aircraft_code = aircraft.aircraft_code AND flight.aircraft_code_sequence = equipment_sequence.aircraft_code_sequence AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
All swift-related questions in 2015.
### Response:
|
SELECT Id, PostTypeId, Body, ParentId, CreationDate, Score FROM Posts AS p WHERE p.ParentId IN (SELECT Id FROM Posts AS q WHERE (q.Tags LIKE '%<swift>%' OR q.Tags LIKE '%<swift2>%' OR q.Tags LIKE '%<swift-playground>%' OR q.Tags LIKE '%<swift-json>%' OR q.Tags LIKE '%<swift-generics>%' OR q.Tags LIKE '%<swift-extensions>%' OR q.Tags LIKE '%<sqlite.swift>%' OR q.Tags LIKE '%<swift-protocols>%' OR q.Tags LIKE '%<swift-array>%' OR q.Tags LIKE '%<cocos2d-swift>%' OR q.Tags LIKE '%<swift-dictionary>%' OR q.Tags LIKE '%<objective-c-swift-bridge>%')) AND CreationDate >= '2015-01-01' AND CreationDate <= '2015-08-19'
|
### Instruction:
when was the first time patient 29635 arterial bp [systolic] was measured less than 144.0 until 12/31/2103.
### 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 = 29635)) 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 < 144.0 AND STRFTIME('%y-%m-%d', chartevents.charttime) <= '2103-12-31' ORDER BY chartevents.charttime LIMIT 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.