instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
what time does flight AA 459 depart
### Response:
|
SELECT DISTINCT flight.departure_time FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.flight_number = 459 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:
what flights go from BOSTON to PITTSBURGH after 1205 in the afternoon
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.departure_time > 1205 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:
please list nonstop TW flights from LAS VEGAS to NEW YORK
### 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 = 'LAS VEGAS' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEW YORK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0) AND flight.airline_code = 'TW'
|
### Instruction:
what is the distance between PITTSBURGH airport and downtown PITTSBURGH
### Response:
|
SELECT DISTINCT AIRPORT_SERVICE_0.miles_distant FROM airport, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1 WHERE airport.airport_code = AIRPORT_SERVICE_0.airport_code AND airport.airport_code = AIRPORT_SERVICE_1.airport_code AND CITY_0.city_code = AIRPORT_SERVICE_1.city_code AND CITY_0.city_name = 'PITTSBURGH' AND CITY_1.city_code = AIRPORT_SERVICE_0.city_code AND CITY_1.city_name = 'PITTSBURGH'
|
### Instruction:
find the flights that leave PHILADELPHIA and arrive in DALLAS by 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 = 'DALLAS' AND flight.arrival_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
|
### Instruction:
what flights are available between BOSTON and WASHINGTON arriving in WASHINGTON at 630
### 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 = 630 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:
Most popular tags since 2012 started..
### 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-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) > 10) AS num ON rate.TagName = num.TagName ORDER BY rate.rate DESC
|
### Instruction:
what is the total 1/2ns ivf consumption amount that patient 015-96048 has received on 10/01/last year?
### Response:
|
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-96048')) AND intakeoutput.celllabel = '1/2ns ivf' AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '10-01'
|
### Instruction:
among the patients aged 40s in a year before, what were the top four most frequent procedures?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 40 AND 49) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
had the morphine inj, sodium chloride 0.9% 1,000 ml bag or potassium chloride crys er 20 meq po tbcr been prescribed for patient 009-15 in 2104?
### 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 = '009-15')) AND medication.drugname IN ('morphine inj', 'sodium chloride 0.9% 1,000 ml bag', 'potassium chloride crys er 20 meq po tbcr') AND STRFTIME('%y', medication.drugstarttime) = '2104'
|
### Instruction:
when was the first time patient 31854 measured its heart rate greater than 76.0 the previous day?
### 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 = 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 > 76.0 AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-1 day') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
and flight from OAKLAND to BOSTON leaving after 0
### 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 <= 600 AND flight.departure_time > 0) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
when was the last time the arterial bp [systolic] of patient 10855 was greater than 141.0, on the current intensive care unit 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 = 10855) AND icustays.outtime IS NULL) 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 DESC LIMIT 1
|
### Instruction:
PresenceInsights tag; monthly totals.
### 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 ('presence-insights') AND PostTypes.Name = 'Question' AND CreationDate > '1/01/2012 12:00AM' GROUP BY YEAR(Posts.CreationDate), MONTH(Posts.CreationDate), Tags.TagName ORDER BY YEAR(Posts.CreationDate), MONTH(Posts.CreationDate), Tags.TagName
|
### Instruction:
when did patient 13837 first have the minimum value of arterial bp mean on 05/20/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 = 13837)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) = '2105-05-20' ORDER BY chartevents.valuenum, chartevents.charttime LIMIT 1
|
### Instruction:
what flights from CHICAGO to KANSAS CITY in the morning
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CHICAGO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'KANSAS CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
Top Moroccan Dev in stack (Java, React, Spring).
### Response:
|
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", u.Id AS "user_link", DisplayName, WebsiteUrl, Reputation FROM Users AS u INNER JOIN Comments AS c ON c.UserId = u.Id INNER JOIN Posts AS p ON p.Id = c.PostId INNER JOIN PostTags AS pt ON p.Id = pt.PostId INNER JOIN Tags AS t ON t.Id = pt.TagId WHERE (UPPER(TagName) LIKE '%REACT%' OR UPPER(TagName) LIKE '%java%' OR UPPER(TagName) LIKE '%spring%') AND YEAR(u.CreationDate) > 2010 AND Reputation >= 100 AND (LOWER(Location) LIKE '%morocco%' OR LOWER(Location) LIKE '%maroc%') GROUP BY u.Id, DisplayName, WebsiteUrl, Reputation ORDER BY Reputation DESC
|
### Instruction:
show me the airlines that fly from TORONTO 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 CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'TORONTO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.airline_code = airline.airline_code AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code
|
### Instruction:
Users with reputation < 5,000 who posted the most 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 > 1 AND Users.Reputation < 5000 GROUP BY Users.Id, Users.CreationDate, Users.LastAccessDate, Users.Reputation, Users.DisplayName, Users.CreationDate, Users.Views, Users.UpVotes, Users.DownVotes ORDER BY Answers DESC LIMIT 100
|
### Instruction:
until 12/30/2105, what was first arterial bp [diastolic] for patient 26175?
### 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 = 26175)) 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-30' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
can you list all nonstop flights departing from ST. PETERSBURG and arriving in CHARLOTTE
### 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 = 'ST. PETERSBURG' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CHARLOTTE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
|
### Instruction:
indicate the yearly maximum arterial bp [systolic] of patient 11095 until 208 days ago.
### 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 = 11095)) 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) <= DATETIME(CURRENT_TIME(), '-208 day') GROUP BY STRFTIME('%y', chartevents.charttime)
|
### Instruction:
what is the monthly minimum amount of urinary catheter output: indwelling/continuous ure in patient 027-22704 since 146 months ago?
### Response:
|
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-22704')) AND intakeoutput.celllabel = 'urinary catheter output: indwelling/continuous ure' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-146 month') GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
|
### Instruction:
how many days has it been since patient 012-66291 dext 5%-nacl 0.9% 1000 ml lvp was last prescribed on this hospital encounter?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', medication.drugstarttime)) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-66291') AND patient.hospitaldischargetime IS NULL) AND medication.drugname = 'dext 5%-nacl 0.9% 1000 ml lvp' ORDER BY medication.drugstarttime DESC LIMIT 1
|
### Instruction:
what's last arterial bp [diastolic] value of patient 4368 on 05/28/2105?
### 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 = 4368)) 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-05-28' ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
how much changes in the weight of patient 006-181433 last measured on the current hospital visit compared to the first value measured on the current hospital visit?
### Response:
|
SELECT (SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-181433' AND patient.hospitaldischargetime IS NULL) 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-181433' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime LIMIT 1)
|
### Instruction:
i want the list of DAILY flights from MILWAUKEE to ST. LOUIS
### 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 = 'MILWAUKEE' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. LOUIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.flight_days = 'DAILY'
|
### Instruction:
Evolution of the up-/downvote ratio by year and month. Look at the Graph, to see the evolution of the upvote/downvote ratio.
### Response:
|
SELECT DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS YearMonth, (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS FLOAT), 0)) AS Ratio FROM Votes WHERE CreationDate > '01-01-2015' AND CreationDate < '12-31-2020' GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) ORDER BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1)
|
### Instruction:
(fout, reputation is nu, niet in het verleden) Average reputation users that post answers.
### Response:
|
SELECT answers.year, Average_reputation_answers = answers.SUM_REPUTATION FROM (SELECT year, SUM(SUM_REPUTATION / CAST(posts AS FLOAT)) OVER (ORDER BY year rows BETWEEN unbounded preceding AND CURRENT ROW) AS SUM_REPUTATION FROM (SELECT Year = DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0), SUM_REPUTATION = SUM(CAST(Users.Reputation AS BIGINT)), Posts = COUNT(Posts.Id) FROM Posts INNER JOIN Users ON Posts.OwnerUserId = Users.Id WHERE PostTypeId = 2 GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, CreationDate), 0)) AS ANSWERS) AS answers ORDER BY answers.year
|
### Instruction:
how many days has elapsed since the last time that patient 12775 had an intake of .9% normal saline on the current intensive care unit visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = 12775) AND icustays.outtime IS NULL) 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') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
afternoon flight from DENVER to SAN FRANCISCO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 1200 AND 1800
|
### Instruction:
give me all flights from BOSTON to PHILADELPHIA next week arriving after lunch
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.arrival_time > 1400 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:
when was the arterial bp [diastolic] of patient 27739 first measured on 11/23/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 = 27739)) 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) = '2103-11-23' ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
i would like information on TW flights from WASHINGTON to PHILADELPHIA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'TW'
|
### Instruction:
i'd like to know what flights UA has from DALLAS to SAN FRANCISCO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DALLAS' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
the number of times that patient 594 had taken tpn d5.0 on 05/02/this year.
### Response:
|
SELECT COUNT(*) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 594)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d5.0' 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-02'
|
### Instruction:
indicate the monthly maximum dose of replete w/fiber that patient 13806 has received until 07/2103.
### Response:
|
SELECT MAX(inputevents_cv.amount) FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13806)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'replete w/fiber' AND d_items.linksto = 'inputevents_cv') AND STRFTIME('%y-%m', inputevents_cv.charttime) <= '2103-07' GROUP BY STRFTIME('%y-%m', inputevents_cv.charttime)
|
### Instruction:
when did patient 006-133605 have a maximum systemicdiastolic for the last time on this month/27?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-133605')) AND NOT vitalperiodic.systemicdiastolic IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '27' ORDER BY vitalperiodic.systemicdiastolic DESC, vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
i'd like an evening flight from NEWARK to LOS ANGELES
### 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 = 'NEWARK')) 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 = 'LOS ANGELES'))) AND departure_time BETWEEN 1800 AND 2200)
|
### Instruction:
indicate the yearly average arterial bp [systolic] of patient 18677 until 44 months ago.
### 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 = 18677)) 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) <= DATETIME(CURRENT_TIME(), '-44 month') GROUP BY STRFTIME('%y', chartevents.charttime)
|
### Instruction:
looking for a flight from DC to DENVER COLORADO
### 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.state_code = 'DC' 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'
|
### Instruction:
what are the top three most frequent diagnoses for patients with an age 60 or above the last year?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND DATETIME(diagnoses_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 3)
|
### Instruction:
show me flights from SAN FRANCISCO to DENVER after 1600
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.departure_time > 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 = 'SAN FRANCISCO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
please list the flights leaving from ST. LOUIS to ST. PAUL after 1000
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. PAUL' AND flight.departure_time > 1000 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'ST. LOUIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
has tpn d17.5 been administered to patient 29666 in 04/this year?
### Response:
|
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 29666)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d17.5' 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', inputevents_cv.charttime) = '04'
|
### Instruction:
indicate the daily maximum amount of sao2 for patient 23858 since 05/20/2103.
### 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 = 23858)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'sao2' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2103-05-20' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
|
### Instruction:
DALLAS to SAN FRANCISCO leaving after 1600 in the afternoon 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 WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.departure_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 = 'DALLAS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
when was the last time that patient 23237 was measured / taken a measurement of arterial bp [systolic] since 337 days ago?
### Response:
|
SELECT chartevents.charttime FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23237)) 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) >= DATETIME(CURRENT_TIME(), '-337 day') ORDER BY chartevents.charttime DESC LIMIT 1
|
### Instruction:
all flights from SAN FRANCISCO to BOSTON leaving before 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
|
### Instruction:
when was the last time on this month/31 patient 002-34744 was measured for a heartrate that was less than 76.0?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-34744')) AND vitalperiodic.heartrate < 76.0 AND NOT vitalperiodic.heartrate IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '31' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
have patient 007-8066 been prescribed with the medication lisinopril 10 mg po tabs, parenteral nutrition, or pantoprazole (protonix) injection 40 mg since 08/2101?
### 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 = '007-8066')) AND medication.drugname IN ('lisinopril 10 mg po tabs', 'parenteral nutrition', 'pantoprazole (protonix) injection 40 mg') AND STRFTIME('%y-%m', medication.drugstarttime) >= '2101-08'
|
### Instruction:
list the flight from PHILADELPHIA 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 (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
Why is my Archaeologist progress off?.
### Response:
|
SELECT DISTINCT (p.Id) AS "post_link" FROM Users AS u INNER JOIN PostHistory AS h ON u.Id = h.UserId INNER JOIN Posts AS p ON p.Id = h.PostId LEFT JOIN LATERAL (SELECT MAX(CreationDate) AS PreviousEditDate FROM PostHistory WHERE PostId = h.PostId AND PostHistoryTypeId IN (1, 2, 3, 4, 5, 6) AND CreationDate < h.CreationDate) AS oa WHERE u.AccountId = '##AccountId:int##' AND h.PostHistoryTypeId IN (4, 5) AND h.CreationDate >= DATEADD(DAY, 180, oa.PreviousEditDate) AND p.PostTypeId IN (1, 2) AND (p.OwnerUserId IS NULL OR p.OwnerUserId != u.Id)
|
### Instruction:
i need a flight from SAN FRANCISCO to BOSTON that leaves after 700
### 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 > 700 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:
please list only the flights from CLEVELAND to DALLAS that leave before 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 = '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 = 'CLEVELAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
show me patient 006-13677's monthly average output (ml)-urethral catheter dr wrenn output amount until 09/2105.
### Response:
|
SELECT AVG(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-13677')) AND intakeoutput.celllabel = 'output (ml)-urethral catheter dr wrenn' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m', intakeoutput.intakeoutputtime) <= '2105-09' GROUP BY STRFTIME('%y-%m', intakeoutput.intakeoutputtime)
|
### Instruction:
give me the total quantity of br milk fs ng that patient 27703 has taken on last month/03.
### 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 = 27703)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'br milk fs ng' 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) = '03'
|
### Instruction:
Community Value of an Answer.
### Response:
|
SELECT COUNT(DISTINCT Answer.Id), SUM(CASE WHEN AnswerVotes.VoteTypeId = 1 THEN 1 ELSE 0 END) AS Accepted, SUM(CASE WHEN AnswerVotes.VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes FROM Posts AS Question JOIN Posts AS Answer ON Question.Id = Answer.ParentId LEFT OUTER JOIN Votes AS AnswerVotes ON (AnswerVotes.PostId = Answer.Id AND AnswerVotes.CreationDate > DATEADD(m, -6, Answer.CreationDate) AND VoteTypeId IN (1, 2)) WHERE Question.PostTypeId = 1 AND Answer.PostTypeId = 2 AND (Question.Tags LIKE '%<amazon-%' OR Question.Tags LIKE '%<aws-%') AND Answer.OwnerUserId = '##UserId##' AND Answer.CreationDate < '##CompareDate##'
|
### Instruction:
how many days have there been since patient 016-22566 was first diagnosed with acute coronary syndrome - acute myocardial infarction (with st elevation) on the current hospital visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', diagnosis.diagnosistime)) FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-22566' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'acute coronary syndrome - acute myocardial infarction (with st elevation)' ORDER BY diagnosis.diagnosistime LIMIT 1
|
### Instruction:
Top 100 users with very similar tag score distribution to you.
### Response:
|
WITH Raw AS (SELECT Posts.OwnerUserId AS UserId, PostTags.TagId, SUM(5 - 2 * Votes.VoteTypeId) AS Score FROM Posts, Votes, PostTags WHERE Votes.PostId = Posts.Id AND Votes.VoteTypeId BETWEEN 2 AND 3 AND Posts.PostTypeId = 2 AND Posts.ParentId = PostTags.PostId AND Posts.OwnerUserId > 0 GROUP BY Posts.OwnerUserId, PostTags.TagId) SELECT * FROM Raw AS You FULL JOIN Raw AS Other ON Other.TagId = You.TagId WHERE You.UserId = '##SiteAccountId:int##' AND Other.UserId != You.UserId ORDER BY Other.UserId, COALESCE(You.TagId, Other.TagId) LIMIT 100
|
### Instruction:
what are the four most common procedures for patients with the age 20s in this year?
### Response:
|
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 20 AND 29) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
early morning flights between CINCINNATI and TAMPA
### 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 = 'CINCINNATI' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'TAMPA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 800
|
### Instruction:
show me all flights on WN from SAN DIEGO to SAN FRANCISCO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN DIEGO' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'WN'
|
### Instruction:
i would like some information on a flight from DENVER to SAN FRANCISCO on UA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
IBM Cloud Tags by year.
### Response:
|
WITH tag_year AS (SELECT TIME_TO_STR(Posts.CreationDate, '%B') + ' ' + CAST(TIME_TO_STR(Posts.CreationDate, '%Y') AS TEXT) AS year, Tags.TagName AS cloud, Posts.Id AS postid FROM PostTags JOIN Tags ON PostTags.TagId = Tags.Id JOIN Posts ON PostTags.PostId = Posts.Id JOIN PostTypes ON Posts.PostTypeId = PostTypes.Id WHERE PostTypes.Name = 'Question' AND YEAR(Posts.CreationDate) >= 2015 AND (Tags.TagName LIKE '%bluemix%' OR Tags.TagName LIKE '%softlayer%' OR Tags.TagName LIKE '%ibm-cloud%' OR Tags.TagName LIKE '%ibm-watson%')) SELECT year, cloud, COUNT(DISTINCT PostId) AS questions FROM tag_year GROUP BY year, cloud
|
### Instruction:
what is the name of a procedure that patient 015-94351 has been given for two times in 07/last year?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, COUNT(treatment.treatmenttime) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-94351')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', treatment.treatmenttime) = '07' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 = 2
|
### Instruction:
Score history graph of a post. The vote timestamps are estimated by level distributing their time in the day (they are estimated to 12:00:00 if it was a single vote on that day).
### Response:
|
WITH Raw AS (SELECT CreationDate, RANK() OVER (PARTITION BY CreationDate ORDER BY Id) AS DayNo, COUNT(*) OVER (PARTITION BY CreationDate) AS DayCount, VoteTypeId FROM Votes WHERE VoteTypeId BETWEEN 2 AND 3 AND PostId = '##PostId:int##') SELECT DATE(CreationDate, '86400.0 / (DayCount + 1) * DayNo s') AS EstCrDate, SUM(5 - 2 * VoteTypeId) OVER (ORDER BY CreationDate, DayNo ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS Score FROM Raw
|
### Instruction:
until 04/2105 was the arterial bp [systolic] of patient 7165 ever less than 164.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 = 7165)) 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 < 164.0 AND STRFTIME('%y-%m', chartevents.charttime) <= '2105-04'
|
### Instruction:
on last month/05, what was the average value of the heart rate of patient 27703?
### 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 = 27703)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'heart rate' AND d_items.linksto = 'chartevents') AND DATETIME(chartevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') AND STRFTIME('%d', chartevents.charttime) = '05'
|
### Instruction:
i would like to fly on TW from BALTIMORE to SAN FRANCISCO
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'SAN FRANCISCO' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'TW'
|
### Instruction:
give me morning flights from ATLANTA to BALTIMORE
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'ATLANTA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
had on 06/02/this year patient 002-25577's systemicdiastolic been greater than 69.0?
### Response:
|
SELECT COUNT(*) > 0 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-25577')) AND vitalperiodic.systemicdiastolic > 69.0 AND NOT vitalperiodic.systemicdiastolic IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', vitalperiodic.observationtime) = '06-02'
|
### Instruction:
what were the top four most frequent diagnoses among the patients in the age 30s until 2 years ago?
### Response:
|
SELECT d_icd_diagnoses.short_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.icd9_code IN (SELECT t1.icd9_code FROM (SELECT diagnoses_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnoses_icd WHERE diagnoses_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 30 AND 39) AND DATETIME(diagnoses_icd.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY diagnoses_icd.icd9_code) AS t1 WHERE t1.c1 <= 4)
|
### Instruction:
show me return flights from CINCINNATI to SALT LAKE CITY nonstop
### 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 = 'CINCINNATI' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.stops = 0
|
### Instruction:
does patient 31243 have a normal arterial bp mean since 02/11/2104?
### 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 = 31243)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND chartevents.valuenum BETWEEN mean_bp_lower AND mean_bp_upper AND STRFTIME('%y-%m-%d', chartevents.charttime) >= '2104-02-11'
|
### Instruction:
As far as pre-requisites , what are they for the class with Bobbie Holland as the GSI ?
### Response:
|
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0 INNER JOIN course_prerequisite ON COURSE_0.course_id = course_prerequisite.pre_course_id INNER JOIN course AS COURSE_1 ON COURSE_1.course_id = course_prerequisite.course_id INNER JOIN course_offering ON COURSE_1.course_id = course_offering.course_id INNER JOIN gsi ON gsi.course_offering_id = course_offering.offering_id INNER JOIN student ON student.student_id = gsi.student_id WHERE student.firstname LIKE 'Bobbie' AND student.lastname LIKE 'Holland'
|
### Instruction:
Number of Posts edited by > 1 user.
### Response:
|
SELECT (SELECT (100.0 * COUNT(*) / @totalPosts) AS PercentPostsEditedSeveralTimes FROM (SELECT COUNT(*) AS NumRevisions FROM PostHistory GROUP BY PostId) AS Revisions WHERE Revisions.NumRevisions > 1) AS PostsEditedSeveralTimes, (SELECT 100.0 * COUNT(*) / @totalPosts AS PercentPostsEditedBySeveralUsers FROM (SELECT COUNT(DISTINCT UserId) AS NumUsers FROM PostHistory GROUP BY PostId) AS Revisions WHERE Revisions.NumUsers > 1) AS PostsEditedBySeveralUsers, (SELECT 100.0 * COUNT(DISTINCT (PostId)) / @totalPosts FROM SuggestedEdits WHERE NOT ApprovalDate IS NULL) AS PercentPostsWithAcceptedSuggestedEdits
|
### Instruction:
list flights from TAMPA to CINCINNATI after 1500
### 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 = 'CINCINNATI' AND flight.departure_time > 1500 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'TAMPA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
has sennosides-docusate sodium 8.6-50 mg po tabs, tamsulosin 0.4 mg cap, or neostigmine been prescribed to patient 030-72509 until 2104?
### 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 = '030-72509')) AND medication.drugname IN ('sennosides-docusate sodium 8.6-50 mg po tabs', 'tamsulosin 0.4 mg cap', 'neostigmine') AND STRFTIME('%y', medication.drugstarttime) <= '2104'
|
### Instruction:
when was the first time patient 3125 was having less than 92.0 heart rate today?
### Response:
|
SELECT chartevents.charttime FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3125)) 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 < 92.0 AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY chartevents.charttime LIMIT 1
|
### Instruction:
how many hours have passed since the last time that patient 3125 had a promote w/fiber intake on the current intensive care unit visit?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = 3125) AND icustays.outtime IS NULL) 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') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
what is the amount of days it has elapsed since the last time patient 25733 had a d5w intake on the current intensive care unit visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = 25733) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'd5w' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime DESC LIMIT 1
|
### Instruction:
what is the daily maximum of output amt-blake drain a output of patient 017-58432 until 12/26/2105?
### Response:
|
SELECT MAX(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-58432')) AND intakeoutput.celllabel = 'output amt-blake drain a' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) <= '2105-12-26' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
### Instruction:
is arterial bp [systolic] of patient 9566 less than 158.0 today?
### 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 = 9566)) 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 < 158.0 AND DATETIME(chartevents.charttime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day')
|
### Instruction:
has ever been greater than 116.0 the arterial bp mean of patient 7241 until 09/21/2104?
### 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 = 7241)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp mean' AND d_items.linksto = 'chartevents') AND chartevents.valuenum > 116.0 AND STRFTIME('%y-%m-%d', chartevents.charttime) <= '2104-09-21'
|
### Instruction:
when was the last time the respiration of patient 004-79017 was greater than 47.0, on this month/28?
### Response:
|
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '004-79017')) AND vitalperiodic.respiration > 47.0 AND NOT vitalperiodic.respiration IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND STRFTIME('%d', vitalperiodic.observationtime) = '28' ORDER BY vitalperiodic.observationtime DESC LIMIT 1
|
### Instruction:
Best time for an answer.
### Response:
|
WITH tmp AS (SELECT TimeDiff = DATEDIFF(minute, q.CreationDate, CreationDate), Period = ROUND((CAST(DATEPART('weekday', q.CreationDate) AS DECIMAL) + CAST(DATEPART('hour', q.CreationDate) AS DECIMAL) / 24), 2) FROM Posts AS q LEFT OUTER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id WHERE q.AcceptedAnswerId > 0 AND q.CreationDate > DATEADD('year', -@YearsBack, CURRENT_TIMESTAMP())) SELECT Period, ROUND(AVG(CAST(TimeDiff AS FLOAT)), 2) AS "average_time-to-answer,_minutes,_utc_(gmt)" FROM tmp WHERE ABS(TimeDiff) < @MaxTimeDiff GROUP BY Period ORDER BY Period
|
### Instruction:
in 03/last year, patient 22897 has had any pe 20 fs ng intake?
### Response:
|
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22897)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'pe 20 fs ng' 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', inputevents_cv.charttime) = '03'
|
### Instruction:
what was the prescription drug that patient 007-4322 had received two or more times in 08/this year?
### Response:
|
SELECT t1.drugname FROM (SELECT medication.drugname, COUNT(medication.drugstarttime) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-4322')) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '08' GROUP BY medication.drugname) AS t1 WHERE t1.c1 >= 2
|
### Instruction:
what is the percentile of 10.5 in a lab test of hemoglobin given the same age of patient 95968 when they came to the hospital first time?
### Response:
|
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hemoglobin') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 95968 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1))) AS t1 WHERE t1.valuenum = 10.5
|
### Instruction:
Average score of all answers (depending on month of questions' creationdate) - some tags excluded.
### Response:
|
WITH ascore_cte AS (SELECT q.Id AS qid, q.CreationDate AS cre, SUM(a.Score) AS ascore FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND NOT ((q.Tags LIKE '%<##tag1?big-list##>%') OR (q.Tags LIKE '%<##tag2?soft-question##>%')) GROUP BY q.Id, q.CreationDate) SELECT LAST_DATE_OF_MONTH(cre), AVG(CAST(ascore AS FLOAT)) AS "average_sum_of_answer-scores" FROM ascore_cte GROUP BY LAST_DATE_OF_MONTH(cre) ORDER BY LAST_DATE_OF_MONTH(cre)
|
### Instruction:
how many days have elapsed since the first intake of tpn d13.0 in patient 4401 on the current intensive care unit visit?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = 4401) AND icustays.outtime IS NULL) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'tpn d13.0' AND d_items.linksto = 'inputevents_cv') ORDER BY inputevents_cv.charttime LIMIT 1
|
### Instruction:
meet criteria for either a ) amnestic mild cognitive impairment ( single or mixed domain ) or mild alzheimer's disease, or b ) have no cognitive impairment, based on history, exam, neuropsychological testing, and consensus diagnosis. mci and mild ad patients must have clinical dementia rating scale score of 0.5 or 1. unimpaired subjects must have clinical dementia rating scale score of 0.
### Response:
|
SELECT * FROM table_train_125 WHERE ((amnestic_mild_cognitive_impairment = 1 OR alzheimer_disease_ad = 1) AND (clinical_dementia_rating_scale = 0.5 OR clinical_dementia_rating_scale = 1)) OR (cognitive_impairment = 0 AND clinical_dementia_rating_scale = 0)
|
### Instruction:
please give me a flight from BOSTON to ATLANTA before 1000 in the morning
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND flight.departure_time < 1000 AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
morning flight from BOSTON to PHILADELPHIA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
Stack Overflow questions with outstanding final close vote. A list of Stack Overflow questions with outstanding close votes, sorted by number of votes.
### Response:
|
SELECT * FROM (SELECT Posts.Id AS "post_link", AVG(Posts.Score) AS "score", COUNT(*) AS "close_votes", MAX(Votes.CreationDate) AS "last_vote", MIN(Votes.CreationDate) AS "first_vote", Posts.CreationDate FROM Posts INNER JOIN Votes ON Posts.Id = Votes.PostId WHERE Votes.VoteTypeId = 6 AND Posts.ClosedDate IS NULL AND Posts.CreationDate > 2014 - 01 - 01 GROUP BY Posts.Id, Posts.CreationDate) AS Myview WHERE 'close_votes' > 3 ORDER BY 'last_vote' DESC, 'score', 'close_votes' DESC, CreationDate
|
### Instruction:
please list all the flights from BOSTON to DENVER which serve meals
### 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, food_service WHERE (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 food_service.meal_code = flight.meal_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:
what is the procedure, which patient 011-59493 underwent two or more times in 06/this year?
### Response:
|
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, COUNT(treatment.treatmenttime) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-59493')) AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', treatment.treatmenttime) = '06' GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 >= 2
|
### Instruction:
please list the flights from CINCINNATI to BURBANK on AA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BURBANK' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'CINCINNATI' AND flight.to_airport = AIRPORT_SERVICE_0.airport_code AND flight.from_airport = AIRPORT_SERVICE_1.airport_code) AND flight.airline_code = 'AA'
|
### Instruction:
Posts with a few edits after CW-ification.
### Response:
|
WITH cw_cte AS (SELECT ph.Id AS cwid, ph.PostId AS pid FROM PostHistory AS ph INNER JOIN Posts AS p ON ph.PostId = p.Id WHERE (ph.PostHistoryTypeId = 16)) SELECT COUNT(DISTINCT RevisionGUID), ph.PostId AS "post_link", revisions = 'site://posts/' + CAST(ph.PostId AS TEXT) + '/revisions' FROM cw_cte AS c INNER JOIN PostHistory AS ph ON (ph.PostId = c.pid) AND (ph.Id > c.cwid) WHERE (ph.PostHistoryTypeId IN (1, 2, 3, 4, 5, 6, 7, 8, 9)) GROUP BY ph.PostId ORDER BY COUNT(DISTINCT RevisionGUID) LIMIT 100
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.