instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
Geocoding topic within goole-maps-API tag with 10 answers.
### Response:
|
SELECT i.Id, i.CreationDate, i.Title, i.Body, i.Tags, i.Score, i.Reputation, i.ViewCount, i.AnswerCount, i.CommentCount, i.ClosedDate, i.Link FROM (SELECT DISTINCT p.Id, p.CreationDate, p.Title, p.Body, p.Tags, p.Score, p.ViewCount, p.AnswerCount, p.CommentCount, p.ClosedDate, CONCAT('http://stackoverflow.com/questions/', p.Id) AS Link, u.Reputation FROM Posts AS p INNER JOIN PostTags AS pt ON p.Id = Pt.PostId INNER JOIN Tags AS t ON pt.TagId = t.Id INNER JOIN Users AS u ON p.OwnerUserId = u.Id AND p.ClosedDate IS NULL WHERE t.TagName IN ('google-maps-api-3', 'google-maps', 'google-maps-api', 'google-geocoder', 'geocoder')) AS i WHERE i.AnswerCount >= 10 AND LOWER(i.Title) LIKE '%geocod%' ORDER BY i.Score DESC, i.Reputation DESC, i.CreationDate DESC
|
### Instruction:
Email and Twitter in AboutMe - ORM posts.
### Response:
|
SELECT u.Id, u.AboutMe, SUBSTRING(u.AboutMe, STR_POSITION(u.AboutMe, '@', 0) - 30, STR_POSITION(u.AboutMe, '@', 0) + 30) AS email, SUBSTRING(u.AboutMe, STR_POSITION(UPPER(u.AboutMe), 'TWITTER', 0) - 30, STR_POSITION(UPPER(u.AboutMe), 'TWITTER', 0) + 30) AS twitter, COUNT(*) FROM Tags AS t INNER JOIN PostTags AS pt ON pt.TagId = t.Id INNER JOIN Posts AS p ON p.ParentId = pt.PostId INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE (UPPER(TagName) = 'ORM' OR UPPER(TagName) = 'HIBERNATE' OR UPPER(TagName) = 'ECLIPSELINK' OR UPPER(TagName) = 'OPENJPA' OR UPPER(TagName) = 'JPA') AND ((AboutMe LIKE '%@%.%') OR (UPPER(AboutMe) LIKE '%TWITTER%')) GROUP BY u.Id, u.AboutMe ORDER BY COUNT(*) DESC
|
### Instruction:
until 2102 how many patients were prescribed cefazolin (ancef) in dextrose ivpb 2 g during the same month after being diagnosed with cholecystitis - acute?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'cholecystitis - acute' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2102') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'cefazolin (ancef) in dextrose ivpb 2 g' AND STRFTIME('%y', medication.drugstarttime) <= '2102') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month')
|
### Instruction:
what flights are available from PITTSBURGH to BALTIMORE on thursday 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
this year, how many patients were prescribed potassium chloride in the same month after they had a analgesics - narcotic analgesic?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'analgesics - narcotic analgesic' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'potassium chloride' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t1.treatmenttime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month')
|
### Instruction:
what was the top four most frequent specimen tests given to patients within the same month after diagnosis of valvular insufficiency - aortic valve?
### Response:
|
SELECT t3.culturesite FROM (SELECT t2.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'valvular insufficiency - aortic valve') AS t1 JOIN (SELECT patient.uniquepid, microlab.culturesite, microlab.culturetakentime FROM microlab JOIN patient ON microlab.patientunitstayid = patient.patientunitstayid) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.culturetakentime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.culturetakentime, 'start of month') GROUP BY t2.culturesite) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
i would like information information on flights from SAN FRANCISCO to DENVER on thursday 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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.departure_time BETWEEN 0 AND 1200
|
### Instruction:
is the heartrate in patient 031-13920 last measured on the last icu visit greater than first measured on the last icu visit?
### Response:
|
SELECT (SELECT vitalperiodic.heartrate FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-13920') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.heartrate IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1) > (SELECT vitalperiodic.heartrate FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-13920') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.heartrate IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1)
|
### Instruction:
since 2105, how many patients were prescribed sodium bicarbonate 8.4% 50 ml inj within the same month after they were diagnosed with hyponatremia?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hyponatremia' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2105') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'sodium bicarbonate 8.4% 50 ml inj' AND STRFTIME('%y', medication.drugstarttime) >= '2105') AS t2 WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month')
|
### Instruction:
show me all flights from BOSTON to PITTSBURGH on wednesday after 1800 o'clock pm
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1800 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
show me all flights from PHILADELPHIA to ATLANTA that leave after 1700 on wednesday
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1700 AND flight.flight_days = days.days_code) 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 = 'PHILADELPHIA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
i'd like to go from ST. PAUL to KANSAS CITY on friday with a meal
### 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, date_day, days, flight, food_service WHERE ((date_day.day_number = 25 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND food_service.meal_code = flight.meal_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'KANSAS CITY' 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. PAUL' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
can you give me the evening flight on wednesday from WASHINGTON to ATLANTA again
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'WASHINGTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
|
### Instruction:
what are the five most commonly prescribed drugs for patients who were also prescribed with adefovir dipivoxil at the same time since 4 years ago?
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'adefovir dipivoxil' AND DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-4 year')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-4 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
what is the number of patients who died after diagnosis of secondary malig neo nec during the same month?
### Response:
|
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime FROM (SELECT admissions.subject_id, diagnoses_icd.charttime FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'secondary malig neo nec')) AS t1 GROUP BY t1.subject_id HAVING MIN(t1.charttime) = t1.charttime) AS t2 JOIN (SELECT patients.subject_id, admissions.hadm_id, patients.dod FROM admissions JOIN patients ON patients.subject_id = admissions.subject_id WHERE NOT patients.dod IS NULL) AS t3 ON t2.subject_id = t3.subject_id WHERE DATETIME(t2.charttime, 'start of month') = DATETIME(t3.dod, 'start of month')
|
### Instruction:
list flights from CINCINNATI to SAN JOSE friday evening
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN JOSE' AND date_day.day_number = 25 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CINCINNATI' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
|
### Instruction:
how much difference is there in systemicdiastolic for patient 005-87465 last measured on the current icu visit compared to the value first measured on the current icu visit?
### Response:
|
SELECT (SELECT vitalperiodic.systemicdiastolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.systemicdiastolic IS NULL ORDER BY vitalperiodic.observationtime DESC LIMIT 1) - (SELECT vitalperiodic.systemicdiastolic FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-87465') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.systemicdiastolic IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1)
|
### Instruction:
is the bicarbonate level of patient 016-20141 second measured on the last hospital visit less than first measured on the last hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-20141' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'bicarbonate' ORDER BY lab.labresulttime LIMIT 1 OFFSET 1) < (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-20141' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'bicarbonate' ORDER BY lab.labresulttime LIMIT 1)
|
### Instruction:
patient must agree to use adequate contraception defined as: for female , one of the following ( 1 ) surgical sterilization, ( 2 ) approved hormonal contraceptives ( such as birth control pills, depo _ provera, or lupron depot ) , ( 3 ) barrier methods ( such as a condom or diaphragm ) used with a spermicide, or ( 4 ) an intrauterine device ( iud ) ; for male , one of the following: ( 1 ) surgical sterilization, or ( 2 ) a condom used with a spermicide.
### Response:
|
SELECT * FROM table_test_31 WHERE adequate_contraception = 1 OR (gender = 'female' AND ((surgical_sterilization = 1 OR hormonal_contraceptives = 1 OR birth_control_pills = 1 OR depo_provera = 1 OR lupron_depot = 1) OR (barrier_methods = 1 AND spermicide = 1) OR intrauterine_device = 1 OR iud = 1)) OR (gender = 'male' AND (surgical_sterilization = 1 OR condom_with_spermicide = 1))
|
### Instruction:
in 2102 how many patients have undergone neurosurgery - therapeutic craniotomy in the same hospital encounter after the diagnosis of pleural effusion - right?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'pleural effusion - right' AND STRFTIME('%y', diagnosis.diagnosistime) = '2102') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'neurosurgery - therapeutic craniotomy' AND STRFTIME('%y', treatment.treatmenttime) = '2102') AS t2 WHERE t1.diagnosistime < t2.treatmenttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
does UA have a flight from MIAMI to WASHINGTON on wednesday
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND CITY_1.state_code = 'DC' AND date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MIAMI' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
give me flights from SAN FRANCISCO to BOSTON on thursday 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BOSTON' AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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.departure_time BETWEEN 1200 AND 1800
|
### Instruction:
i need to know information for flights leaving DALLAS on tuesday evening and returning 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND date_day.day_number = 22 AND date_day.month_number = 3 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 1800 AND 2200
|
### Instruction:
tell me the difference between the total number of output and the input of patient 022-198713 since 397 days ago?
### Response:
|
SELECT (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 = '022-198713')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-397 day')) - (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 = '022-198713')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-397 day'))
|
### Instruction:
JavaScript MVC Framework Trends (Bottom-Tier, from TodoMVC) (# 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 ('agility.js', 'knockback.js', 'canjs', 'sammy.js', 'stapes.js', 'puremvc', 'enyo', 'sapui', 'vue.js', 'spine.js', 'sproutcore', 'yui') 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:
What are the most popular first words in question titles?.
### Response:
|
SELECT SUBSTRING(p.Title, 1, STR_POSITION(p.Title, ' ')) AS FirstWord, COUNT(DISTINCT p.Id) AS Questions, CAST(AVG(p.Score * 1.0) AS FLOAT(10, 1)) AS AvgScore, CAST(AVG(p.AnswerCount * 1.0) AS FLOAT(10, 1)) AS AvgAnswerCount, CAST(AVG(p.CommentCount * 1.0) AS FLOAT(10, 1)) AS AvgCommentCount, CAST(AVG(p.ViewCount * 1.0) AS FLOAT(10, 1)) AS AvgViewCount, CAST(AVG(p.FavoriteCount * 1.0) AS FLOAT(10, 1)) AS AvgFavoriteCount FROM dbo.Posts AS p WHERE p.PostTypeId = 1 AND STR_POSITION(p.Title, ' ') > 0 GROUP BY SUBSTRING(p.Title, 1, STR_POSITION(p.Title, ' ')) ORDER BY COUNT(DISTINCT p.Id) DESC LIMIT 100
|
### Instruction:
i need a flight leaving PITTSBURGH next monday arriving in FORT WORTH before 1000
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 21 AND date_day.month_number = 2 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.arrival_time < 1000 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'FORT WORTH' 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:
how much is the difference between the total output and the total input of patient 002-23819 until 1232 days ago?
### Response:
|
SELECT (SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-23819')) AND intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1232 day')) - (SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-23819')) AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime) <= DATETIME(CURRENT_TIME(), '-1232 day'))
|
### Instruction:
% of Eventually-Downvoted Questions&Answers Created per Month.
### Response:
|
SELECT Posts.Id, 1 AS question, 1 AS upvote FROM Posts LEFT JOIN Votes ON Votes.PostId = Posts.Id WHERE Posts.PostTypeId = 1 AND Votes.VoteTypeId = 2 GROUP BY Posts.Id LIMIT 100 UNION ALL SELECT Posts.Id, 0 AS question, 1 AS upvote FROM Posts LEFT JOIN Votes ON Votes.PostId = Posts.Id WHERE Posts.PostTypeId = 2 AND Votes.VoteTypeId = 2 GROUP BY Posts.Id LIMIT 100 UNION ALL SELECT Posts.Id, 1 AS question, 0 AS upvote FROM Posts LEFT JOIN Votes ON Votes.PostId = Posts.Id WHERE Posts.PostTypeId = 1 AND Votes.VoteTypeId = 3 GROUP BY Posts.Id LIMIT 100 UNION ALL SELECT Posts.Id, 0 AS question, 0 AS upvote FROM Posts LEFT JOIN Votes ON Votes.PostId = Posts.Id WHERE Posts.PostTypeId = 2 AND Votes.VoteTypeId = 3 GROUP BY Posts.Id LIMIT 100
|
### Instruction:
what is the round trip cost of a FIRST class ticket from BOSTON 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, fare_basis, flight, flight_fare WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND 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.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code
|
### Instruction:
New Questions View Analysis by Tags.
### Response:
|
SELECT YEAR(CreationDate) AS "year", MONTH(CreationDate) AS "month", t.TagName, AVG(AnswerCount) AS AverageAnswersPerQuestion, SUM(ViewCount) / COUNT(p.Id) AS AverageNewQuestionViews, COUNT(p.Id) AS NewQuestionCount, SUM(ViewCount) AS NewQViewCount FROM Posts AS p JOIN PostTypes AS pt ON p.PostTypeId = pt.Id JOIN PostTags AS ptg ON ptg.PostId = p.Id JOIN Tags AS t ON t.Id = ptg.TagId WHERE (YEAR(CreationDate) >= 2014 OR (YEAR(CreationDate) = 2013 AND MONTH(CreationDate) = 12)) AND pt.Name = 'Question' GROUP BY YEAR(CreationDate), MONTH(CreationDate), t.TagName HAVING (SUM(ViewCount) >= 10000 OR SUM(ViewCount) / COUNT(p.Id) >= 2000 OR SUM(ViewCount) / COUNT(p.Id) >= 2000) ORDER BY YEAR(CreationDate), MONTH(CreationDate), t.TagName
|
### Instruction:
what is the number of patients diagnosed with acute respiratory failure - due to pulmonary infiltrates who didn't come back to the hospital within 2 months?
### Response:
|
SELECT (SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute respiratory failure - due to pulmonary infiltrates') AS t1) - (SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute respiratory failure - due to pulmonary infiltrates') AS t2 JOIN patient ON t2.uniquepid = patient.uniquepid WHERE t2.diagnosistime < patient.hospitaladmittime AND DATETIME(patient.hospitaladmittime) BETWEEN DATETIME(t2.diagnosistime) AND DATETIME(t2.diagnosistime, '+2 month'))
|
### Instruction:
when was the first time that patient 99647 was prescribed 5% dextrose and aspirin in 12/2105 at the same time?
### Response:
|
SELECT t1.startdate FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'aspirin' AND admissions.subject_id = 99647 AND STRFTIME('%y-%m', prescriptions.startdate) = '2105-12') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = '5% dextrose' AND admissions.subject_id = 99647 AND STRFTIME('%y-%m', prescriptions.startdate) = '2105-12') AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) ORDER BY t1.startdate LIMIT 1
|
### Instruction:
until 2104 how many patients were diagnosed with acute respiratory failure within 2 months after diagnosis of lung trauma - with contusion of lung?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute respiratory failure' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'lung trauma - with contusion of lung' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104') AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
how many patients died during the same hospital encounter after having been diagnosed with hx of tongue malignancy?
### Response:
|
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime, t1.hadm_id FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'hx of tongue malignancy')) AS t1 GROUP BY t1.subject_id HAVING MIN(t1.charttime) = t1.charttime) AS t2 JOIN (SELECT patients.subject_id, admissions.hadm_id, patients.dod FROM admissions JOIN patients ON patients.subject_id = admissions.subject_id WHERE NOT patients.dod IS NULL) AS t3 ON t2.subject_id = t3.subject_id WHERE t2.hadm_id = t3.hadm_id
|
### Instruction:
list flights from BOSTON to PITTSBURGH leaving early in the morning on 8 6
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND date_day.day_number = 6 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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.departure_time BETWEEN 0 AND 800
|
### Instruction:
count the number of patients who were diagnosed with leukemia - acute lymphocytic within 2 months until 2102 after a antiemetic - promethazine procedure.
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'antiemetic - promethazine' AND STRFTIME('%y', treatment.treatmenttime) <= '2102') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'leukemia - acute lymphocytic' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2102') AS t2 WHERE t1.treatmenttime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
|
### Instruction:
Ratio of downvotes per total votes (of tags with 1000+ total votes). Divides the downvotes by total votes.
Does so only for tags with more than 1000 total votes.
Orders by ratio, descending
------------
Shows the tags with highest downvote ratio at the top.
### Response:
|
WITH TotalsByTag(tagName, totalUpVotes, totalDownVotes) AS (SELECT Tags.TagName, totalUpVotes = SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END), totalDownVotes = SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Votes ON Votes.PostId = PostTags.PostId WHERE Votes.VoteTypeId IN (2, 3) GROUP BY Tags.TagName) SELECT TagName, CASE WHEN totalUpVotes = 0 AND totalUpVotes = 0 THEN 0 ELSE ROUND(CAST(totalUpVotes AS FLOAT) / (totalDownVotes), 3) END AS ratioOfDownVotes FROM TotalsByTag WHERE (totalUpVotes + totalDownVotes) > 1000 ORDER BY 2 DESC
|
### Instruction:
i would like information on flights from DENVER to SAN FRANCISCO after 1200 on wednesday
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1200 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Questions with low score answers (from high rep users). Tries locating hidden gems by searching for answers by high rep users which has low score. To help decide score level it also lists max and average score on that question. It does however _not_ list the user, as we don't want to actually focus on the users when looking for hidden gems, but more to revisit and up-vote worthy answers.
### Response:
|
SELECT u.Id AS "user_link", a.Id AS "post_link", a.CreationDate, a.Score, q.MaxAns, q.AvgAns, q.Tags FROM Posts AS a JOIN Users AS u ON a.OwnerUserId = u.Id JOIN (SELECT q.Id, q.Tags, AVG(a.Score) AS AvgAns, MAX(a.Score) AS MaxAns FROM Posts AS q JOIN Posts AS a ON a.ParentId = q.Id WHERE q.AcceptedAnswerId IS NULL GROUP BY q.Id, q.Tags) AS q ON a.ParentId = q.Id WHERE (u.Reputation > @reputationLimit) AND a.Score <= @lowScoreLimit AND (@tag = '' OR q.Tags LIKE '%' + @tag + '%') ORDER BY a.CreationDate DESC LIMIT 100
|
### Instruction:
count the number of patients who had been diagnosed with dementia within 2 months after they had been diagnosed with change in mental status until 4 years ago.
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'dementia' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'change in mental status' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month')
|
### Instruction:
was the value of calcium of patient 028-11360 last measured on the first hospital visit less than it was second to last measured on the first hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-11360' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'calcium' ORDER BY lab.labresulttime DESC LIMIT 1) < (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '028-11360' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'calcium' ORDER BY lab.labresulttime DESC LIMIT 1 OFFSET 1)
|
### Instruction:
now i need a flight from DETROIT to SAN DIEGO leaving tuesday evening
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN DIEGO' AND date_day.day_number = 22 AND date_day.month_number = 3 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DETROIT' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
|
### Instruction:
how much does patient 26195's pco2 differ from the value measured at 2104-02-08 14:00:00 compared to the value measured at 2104-02-08 13:08:00?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26195) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'pco2') AND labevents.charttime = '2104-02-08 14:00:00') - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26195) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'pco2') AND labevents.charttime = '2104-02-08 13:08:00')
|
### Instruction:
Who is the most recent person that has taught BIOMATLS 577 ?
### Response:
|
SELECT DISTINCT instructor.name FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN offering_instructor ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE course_offering.semester = (SELECT MAX(SEMESTERalias0.semester_id) FROM semester AS SEMESTERalias0 INNER JOIN course_offering AS COURSE_OFFERINGalias1 ON SEMESTERalias0.semester_id = COURSE_OFFERINGalias1.semester INNER JOIN course AS COURSEalias1 ON COURSEalias1.course_id = COURSE_OFFERINGalias1.course_id WHERE COURSEalias1.department = 'BIOMATLS' AND COURSEalias1.number = 577 AND SEMESTERalias0.year < 2016) AND course.department = 'BIOMATLS' AND course.number = 577
|
### Instruction:
what flights are available thursday afternoon from BALTIMORE 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 1200 AND 1800
|
### Instruction:
i need a flight after 1800 on wednesday from OAKLAND to SALT LAKE CITY
### 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, date_day, days, flight WHERE ((date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1800 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SALT LAKE CITY' 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:
what is the difference in chloride levels of patient 031-23605 second measured on the first hospital visit compared to the value first measured on the first hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23605' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime LIMIT 1 OFFSET 1) - (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-23605' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime LIMIT 1)
|
### Instruction:
list DAILY flights from DENVER to BALTIMORE with FIRST class service
### 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, fare_basis, flight, flight_fare WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code 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 = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.flight_days = 'DAILY'
|
### Instruction:
Probability of having an answer accepted by Join Date.
### Response:
|
SELECT (ACC.cYear - 2011) * 12 + ACC.cMonth AS Monthy, (1.0 * ACC.AccAnswers / TOT.TotAnswers) AS Percentage FROM (SELECT YEAR(Users.CreationDate) AS cYear, MONTH(Users.CreationDate) AS cMonth, COUNT(Users.Id) AS AccAnswers FROM Posts AS A JOIN Posts AS B ON A.AcceptedAnswerId = B.Id JOIN Users ON Users.Id = B.OwnerUserId GROUP BY YEAR(Users.CreationDate), MONTH(Users.CreationDate)) AS ACC JOIN (SELECT YEAR(Users.CreationDate) AS cYear, MONTH(Users.CreationDate) AS cMonth, COUNT(Users.Id) AS TotAnswers FROM Posts AS A JOIN Users ON Users.Id = A.OwnerUserId WHERE A.PostTypeId = 2 GROUP BY YEAR(Users.CreationDate), MONTH(Users.CreationDate)) AS TOT ON ACC.cYear = TOT.cYear AND ACC.cMonth = TOT.cMonth ORDER BY 1, 2
|
### Instruction:
list all flights leaving on thursday morning from NEW YORK to MONTREAL
### 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, date_day, days, flight WHERE (((flight.departure_time BETWEEN 0 AND 1200) AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEW YORK' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'MONTREAL' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
count the number of patients who are dead after having been diagnosed with cortical blindness within the same hospital visit.
### Response:
|
SELECT COUNT(DISTINCT t2.subject_id) FROM (SELECT t1.subject_id, t1.charttime, t1.hadm_id FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'cortical blindness')) AS t1 GROUP BY t1.subject_id HAVING MIN(t1.charttime) = t1.charttime) AS t2 JOIN (SELECT patients.subject_id, admissions.hadm_id, patients.dod FROM admissions JOIN patients ON patients.subject_id = admissions.subject_id WHERE NOT patients.dod IS NULL) AS t3 ON t2.subject_id = t3.subject_id WHERE t2.hadm_id = t3.hadm_id
|
### Instruction:
what is the potassium difference of patient 47746 from the value measured at 2103-09-16 14:24:00 compared to the value measured at 2103-09-12 04:24:00?
### Response:
|
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 47746) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium') AND labevents.charttime = '2103-09-16 14:24:00') - (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 47746) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium') AND labevents.charttime = '2103-09-12 04:24:00')
|
### Instruction:
tell me the name of the medication that patient 58649 was prescribed during the same hospital encounter after having been diagnosed with delusional disorder?
### Response:
|
SELECT t2.drug FROM (SELECT admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE admissions.subject_id = 58649 AND diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'delusional disorder')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate, admissions.hadm_id FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE admissions.subject_id = 58649) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND t1.hadm_id = t2.hadm_id
|
### Instruction:
please give me all the flights from LONG BEACH CALIFORNIA to MEMPHIS TENNESSEE
### 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 AS STATE_0, state AS STATE_1 WHERE CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'LONG BEACH' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'MEMPHIS' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code AND STATE_0.state_code = CITY_0.state_code AND STATE_0.state_name = 'CALIFORNIA' AND STATE_1.state_code = CITY_1.state_code AND STATE_1.state_name = 'TENNESSEE'
|
### Instruction:
Number of questions by week, and Score Quality.
### Response:
|
SELECT ((DATEDIFF(DAY, '##StartDate:string##', CreationDate)) / 7) + 1 AS WeekNo, DATEADD(DAY, ((DATEDIFF(DAY, '##StartDate:string##', CreationDate)) / 7) * 7, '##StartDate:string##') AS WeekStarting, COUNT(P.Id) AS QuestionsAsked, COUNT(CASE WHEN Score > 0 THEN 1 END) AS PositiveScore, COUNT(CASE WHEN Score = 0 THEN 1 END) AS NeutralScore, COUNT(CASE WHEN Score < 0 THEN 1 END) AS NegativeScore, COUNT(ClosedDate) AS Closed FROM dbo.Posts AS P JOIN dbo.PostTypes AS PT ON P.PostTypeId = PT.Id WHERE P.CreationDate >= '##StartDate:string##' AND P.CreationDate < '##EndDate:string##' AND PT.Name = 'Question' GROUP BY ((DATEDIFF(DAY, '20181202', CreationDate)) / 7) ORDER BY ((DATEDIFF(DAY, '20181202', CreationDate)) / 7)
|
### Instruction:
Potentially abandoned questions with inactive owners. Returns questions that are old (+6 months), have low views and score,
have no upvoted or accept answer and where the user hasn't been active
in the last 6 months.
Modified from the query build out of this conversation
http://chat.stackexchange.com/rooms/118/conversation/querying-for-abandoned-questions
### Response:
|
SELECT p.Id AS "post_link", p.Score, p.Tags AS Tags, p.AnswerCount AS Answers, CASE WHEN p.ClosedDate IS NULL THEN NULL ELSE 'Y' END AS Closed, DATEDIFF(month, p.CreationDate, GETDATE()) AS MnthsQstAct, u.Id AS "user_link" FROM Posts AS p LEFT JOIN Users AS u ON p.OwnerUserId = u.Id JOIN PostTags ON PostTags.PostId = p.Id JOIN Tags ON Tags.Id = PostTags.TagId WHERE p.PostTypeId = 1 AND p.AnswerCount > 1 AND Tags.TagName = 'r' AND p.AcceptedAnswerId IS NULL AND p.CreationDate < DATEADD(month, -3, GETDATE()) AND p.ClosedDate IS NULL ORDER BY p.Score, p.AnswerCount
|
### Instruction:
are there any flights before 1200 on 6 15 from LONG BEACH to COLUMBUS
### 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, date_day, days, flight WHERE ((date_day.day_number = 15 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time < 1200 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'COLUMBUS' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'LONG BEACH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
how many patients died in the same hospital visit after being diagnosed since 1 year ago with hypotension / pressor dependent?
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime, t1.patienthealthsystemstayid FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hypotension / pressor dependent') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND DATETIME(t1.diagnosistime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE t2.patienthealthsystemstayid = t3.patienthealthsystemstayid
|
### Instruction:
what are the flights from KANSAS CITY to BURBANK on saturday 5 22 on WN
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BURBANK' AND date_day.day_number = 22 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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.airline_code = 'WN'
|
### Instruction:
on 5 4 ATLANTA to DENVER DL flight 257
### 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, date_day, days, flight WHERE (((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND flight.flight_number = 257 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) AND date_day.day_number = 4 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code) AND flight.airline_code = 'DL'
|
### Instruction:
show me the flights from BOSTON to PITTSBURGH leaving WEDNESDAY and THURSDAY
### 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 AS DAYS_0, days AS DAYS_1, flight WHERE ((DAYS_0.day_name = 'WEDNESDAY' AND DAYS_1.day_name = 'THURSDAY' AND flight.flight_days = DAYS_0.days_code AND flight.flight_days = DAYS_1.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
was the -eos value of patient 035-11731 last measured on the first hospital visit less than the value second to last measured on the first hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-11731' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = '-eos' ORDER BY lab.labresulttime DESC LIMIT 1) < (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-11731' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = '-eos' ORDER BY lab.labresulttime DESC LIMIT 1 OFFSET 1)
|
### Instruction:
show me the flights from BOSTON to SAN FRANCISCO leaving after 1600 on friday
### 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, date_day, days, flight WHERE ((date_day.day_number = 25 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1600 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
Team's Answers - 10 agents.
### Response:
|
SELECT p.Id, p.CreationDate, u.DisplayName, p.Score, p.Id AS "post_link", pP.AcceptedAnswerId FROM Posts AS p, Users AS u, Posts AS pP WHERE p.PostTypeId = 2 AND (p.OwnerUserId = 5937420 OR p.OwnerUserId = 9498806 OR p.OwnerUserId = 9485673 OR p.OwnerUserId = 9524052 OR p.OwnerUserId = 9521610 OR p.OwnerUserId = 9929045 OR p.OwnerUserId = 9928809 OR p.OwnerUserId = 3156333 OR p.OwnerUserId = 9929015 OR p.OwnerUserId = 9892073) AND p.OwnerUserId = u.Id AND p.ParentId = pP.Id AND p.CreationDate >= '2018-08-19' AND p.CreationDate < '2018-08-25' ORDER BY CreationDate
|
### Instruction:
show me the flights leaving from ATLANTA for WASHINGTON on thursday 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'WASHINGTON' AND date_day.day_number = 24 AND date_day.month_number = 5 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
Get the number of questions per South-american country.
### Response:
|
SELECT Tags.TagName, COUNT(PostTags.TagId) AS no FROM PostTags, Tags WHERE Tags.Id = PostTags.TagId AND TagName = 'argentina' OR Tags.Id = PostTags.TagId AND TagName = 'venezuela' OR Tags.Id = PostTags.TagId AND TagName = 'brazil' OR Tags.Id = PostTags.TagId AND TagName = 'chile' OR Tags.Id = PostTags.TagId AND TagName = 'bolivia' OR Tags.Id = PostTags.TagId AND TagName = 'colombia' OR Tags.Id = PostTags.TagId AND TagName = 'ecuador' OR Tags.Id = PostTags.TagId AND TagName = 'guyana' OR Tags.Id = PostTags.TagId AND TagName = 'paraguay' OR Tags.Id = PostTags.TagId AND TagName = 'suriname' OR Tags.Id = PostTags.TagId AND TagName = 'uruguay' OR Tags.Id = PostTags.TagId AND TagName = 'peru' OR Tags.Id = PostTags.TagId AND TagName = 'french-guiana' GROUP BY TagName ORDER BY no DESC
|
### Instruction:
what were the five most frequent drugs prescribed within the same month to the patients aged 60 or above after they had been diagnosed with hepatic dysfunction - chronic,?
### Response:
|
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hepatic dysfunction - chronic') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE patient.age >= 60) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month') GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
Posts, Comments by askerID and answererID..
### Response:
|
SELECT 'Answers' AS Post_Type, p1.Id AS "post_link", p1.* FROM Posts AS p1 JOIN Posts AS p2 ON p1.Id = p2.ParentId AND p2.OwnerUserId = '##AnswererUserId##' WHERE p1.OwnerUserId = '##AskerUserId##' UNION ALL SELECT 'Comments on question' AS Post_Type, p1.Id AS "post_link", p1.* FROM Posts AS p1 JOIN Comments AS c1 ON p1.Id = c1.PostId AND c1.UserId = '##AnswererUserId##' WHERE p1.OwnerUserId = '##AskerUserId##' UNION ALL SELECT 'Comments on other answers' AS Post_Type, p2.Id AS "post_link", p2.* FROM Posts AS p1 JOIN Posts AS p2 ON p1.Id = p2.ParentId JOIN Comments AS c1 ON p2.Id = c1.PostId AND c1.UserId = '##AnswererUserId##' WHERE p1.OwnerUserId = '##AskerUserId##' AND p1.Id != p2.Id
|
### Instruction:
i'd like a flight tomorrow from KANSAS CITY to NEWARK 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEWARK' AND date_day.day_number = 20 AND date_day.month_number = 1 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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:
list the flights on sunday afternoon from OAKLAND to DALLAS
### 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, date_day, days, flight WHERE (((flight.departure_time BETWEEN 1200 AND 1800) AND date_day.day_number = 27 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code) 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 = 'OAKLAND' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
does UA provide any FIRST class flights from DENVER 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, fare_basis, 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 = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id) AND flight.airline_code = 'UA'
|
### Instruction:
is there a flight from NASHVILLE to HOUSTON in the evening tomorrow
### 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'HOUSTON' AND date_day.day_number = 20 AND date_day.month_number = 1 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NASHVILLE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 1800 AND 2200
|
### Instruction:
show me US flights from SAN FRANCISCO to PITTSBURGH 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND date_day.day_number = 22 AND date_day.month_number = 3 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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 = 'US'
|
### Instruction:
show me flights available from ATLANTA to BALTIMORE leaving on monday 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND date_day.day_number = 21 AND date_day.month_number = 2 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
for the first time until 31 months ago, when was patient 7165 prescribed insulin human regular and labetalol hcl at the same time?
### Response:
|
SELECT t1.startdate FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'insulin human regular' AND admissions.subject_id = 7165 AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-31 month')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'labetalol hcl' AND admissions.subject_id = 7165 AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-31 month')) AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) ORDER BY t1.startdate LIMIT 1
|
### Instruction:
how many patients were diagnosed with atrial fibrillation - with rapid ventricular response in 2104 after being diagnosed with metabolic acidosis in the same month?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'atrial fibrillation - with rapid ventricular response' AND STRFTIME('%y', diagnosis.diagnosistime) = '2104') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'metabolic acidosis' AND STRFTIME('%y', diagnosis.diagnosistime) = '2104') AS t2 WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.diagnosistime, 'start of month')
|
### Instruction:
all round trip flights between NEW YORK and MIAMI BUSINESS class fare
### 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, fare_basis, flight, flight_fare WHERE ((fare_basis.class_type = 'BUSINESS' AND fare.fare_basis_code = fare_basis.fare_basis_code) AND 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:
what airport in NEW YORK is closest to downtown
### Response:
|
SELECT DISTINCT airport.airport_code FROM airport, airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1 WHERE AIRPORT_SERVICE_1.miles_distant = (SELECT MIN(AIRPORT_SERVICEalias2.miles_distant) FROM airport_service AS AIRPORT_SERVICEalias2, city AS CITYalias2 WHERE CITYalias2.city_code = AIRPORT_SERVICEalias2.city_code AND CITYalias2.city_name = 'NEW YORK') AND airport.airport_code = AIRPORT_SERVICE_0.airport_code AND airport.airport_code = AIRPORT_SERVICE_1.airport_code AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEW YORK' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'NEW YORK'
|
### Instruction:
is the glucose of patient 031-11804 second measured on the last hospital visit less than it was first measured on the last hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-11804' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'glucose' ORDER BY lab.labresulttime LIMIT 1 OFFSET 1) < (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-11804' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'glucose' ORDER BY lab.labresulttime LIMIT 1)
|
### Instruction:
i would like direct COACH flights from PITTSBURGH to ATLANTA
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, fare, fare_basis, flight, flight_fare WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' AND fare_basis.class_type = 'COACH' AND fare.fare_basis_code = fare_basis.fare_basis_code 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 = 'PITTSBURGH' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.stops = 0
|
### Instruction:
is the value of chloride second measured on the first hospital visit of patient 030-40641 less than its value first measured on the first hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-40641' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime LIMIT 1 OFFSET 1) < (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-40641' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime LIMIT 1)
|
### Instruction:
i would like a flight from ATLANTA to DALLAS on friday that arrives in DALLAS by 1800
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 25 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.arrival_time <= 1800 AND flight.flight_days = days.days_code) 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 = 'ATLANTA' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
please repeat the flight departures for monday august nineteenth from DENVER 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, date_day, days, flight WHERE ((date_day.day_number = 21 AND date_day.month_number = 2 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time <= 2400 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'PITTSBURGH' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'DENVER' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
among patients that were prescribed with pyridostigmine bromide, what were the four most frequently prescribed drugs at the same time, since 2100.
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'pyridostigmine bromide' AND STRFTIME('%y', prescriptions.startdate) >= '2100') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE STRFTIME('%y', prescriptions.startdate) >= '2100') AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 4
|
### Instruction:
on 7 8 i'd like a flight from NEWARK to ORLANDO 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO' AND date_day.day_number = 8 AND date_day.month_number = 7 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'NEWARK' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
|
### Instruction:
among patients who were prescribed nystatin ointment, what are the three most commonly ordered drugs at the same time until 1 year ago?
### Response:
|
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE prescriptions.drug = 'nystatin ointment' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE DATETIME(t1.startdate) = DATETIME(t2.startdate) GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 3
|
### Instruction:
how many patients received a hemodialysis after the procedure of the hypothermia in the previous year within 2 months?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'hypothermia' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'hemodialysis' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) AS t2 WHERE t1.treatmenttime < t2.treatmenttime AND DATETIME(t2.treatmenttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
|
### Instruction:
how many patients until 4 years ago were diagnosed with failure to wean in the same hospital visit after a procedure of anticonvulsant - valproate?
### Response:
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'anticonvulsant - valproate' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'failure to wean' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year')) AS t2 WHERE t1.treatmenttime < t2.diagnosistime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
### Instruction:
List of pending query with indication of user's score for it. This lists the tag synonyms suggestion that are still opened, but only shows the one where the given user can vote (needs a score of 5 on it).
### Response:
|
SELECT * FROM (SELECT st.TagName AS stTagName, tt.TagName AS ttTagName, ts.CreationDate, ts.OwnerUserId AS "user_link", SUM(CASE v.VoteTypeId WHEN 2 THEN 1 WHEN 3 THEN -1 END) AS Score FROM TagSynonyms AS ts INNER JOIN Tags AS st ON ts.SourceTagName = st.TagName INNER JOIN Tags AS tt ON ts.TargetTagName = tt.TagName INNER JOIN PostTags AS pt ON pt.TagId = tt.Id INNER JOIN Posts AS q ON q.Id = pt.PostId INNER JOIN Posts AS a ON a.ParentId = q.Id INNER JOIN Votes AS v ON v.PostId = a.Id WHERE ts.ApprovalDate IS NULL AND q.PostTypeId = 1 AND a.PostTypeId = 2 AND a.OwnerUserId = @user GROUP BY tt.TagName, st.TagName, ts.CreationDate, ts.OwnerUserId) AS list WHERE Score > 4 ORDER BY Score DESC
|
### Instruction:
calculate the number of patients who were dead after being diagnosed with brain tumor - brain tumor, type unknown during the same month until 2104.
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'brain tumor - brain tumor, type unknown') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND STRFTIME('%y', t1.diagnosistime) <= '2104') AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE DATETIME(t2.diagnosistime, 'start of month') = DATETIME(t3.hospitaldischargetime, 'start of month')
|
### Instruction:
show me all flights from BOSTON to ATLANTA which leave ATLANTA after 1200 tomorrow
### 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, date_day, days, flight WHERE ((date_day.day_number = 20 AND date_day.month_number = 1 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1200 AND flight.flight_days = days.days_code) 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 = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
what is the cost of round trip ticket FIRST class between OAKLAND and ATLANTA
### 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, flight, flight_fare WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'OAKLAND' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ATLANTA' 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.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND fare_basis.class_type = 'FIRST' AND fare.fare_basis_code = fare_basis.fare_basis_code
|
### Instruction:
calculate the number of patients who were dead after being diagnosed with neck tumor - laryngeal ca during the same month until 2103.
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'neck tumor - laryngeal ca') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND STRFTIME('%y', t1.diagnosistime) <= '2103') AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE DATETIME(t2.diagnosistime, 'start of month') = DATETIME(t3.hospitaldischargetime, 'start of month')
|
### Instruction:
list all flights going from BOSTON to ATLANTA after 1800 o'clock pm on wednesday
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 23 AND date_day.month_number = 4 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1800 AND flight.flight_days = days.days_code) 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 = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
|
### Instruction:
how many patients died in the same month after having been diagnosed in 2105 with signs and symptoms of sepsis (sirs)?
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'signs and symptoms of sepsis (sirs)') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND STRFTIME('%y', t1.diagnosistime) = '2105') AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE DATETIME(t2.diagnosistime, 'start of month') = DATETIME(t3.hospitaldischargetime, 'start of month')
|
### Instruction:
what is the changing/difference of chloride of patient 010-9767 last measured on the last hospital visit compared to the first value measured on the last hospital visit?
### Response:
|
SELECT (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-9767' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime DESC LIMIT 1) - (SELECT lab.labresult FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-9767' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1)) AND lab.labname = 'chloride' ORDER BY lab.labresulttime LIMIT 1)
|
### Instruction:
what are the top five most common diagnoses that patients were diagnosed with within 2 months after the diagnosis of meningitis - chronic?
### Response:
|
SELECT t3.diagnosisname FROM (SELECT t2.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'meningitis - chronic') AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosisname, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.diagnosistime AND DATETIME(t2.diagnosistime) BETWEEN DATETIME(t1.diagnosistime) AND DATETIME(t1.diagnosistime, '+2 month') GROUP BY t2.diagnosisname) AS t3 WHERE t3.c1 <= 5
|
### Instruction:
count the number of patients who are dead after having been diagnosed with sepsis - severe during the same hospital visit until 2104.
### Response:
|
SELECT COUNT(DISTINCT t2.uniquepid) FROM (SELECT t1.uniquepid, t1.diagnosistime, t1.patienthealthsystemstayid FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'sepsis - severe') AS t1 GROUP BY t1.uniquepid HAVING MIN(t1.diagnosistime) = t1.diagnosistime AND STRFTIME('%y', t1.diagnosistime) <= '2104') AS t2 JOIN (SELECT patient.uniquepid, patient.patienthealthsystemstayid, patient.hospitaldischargetime FROM patient WHERE patient.hospitaldischargestatus = 'expired') AS t3 ON t2.uniquepid = t3.uniquepid WHERE t2.patienthealthsystemstayid = t3.patienthealthsystemstayid
|
### Instruction:
what flight do you have from DALLAS to DENVER on 8 27 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, date_day, days, flight WHERE ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'DENVER' AND date_day.day_number = 27 AND date_day.month_number = 8 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_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) AND flight.departure_time BETWEEN 0 AND 1200
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.