instruction
stringlengths 53
549
| output
stringlengths 30
2.33k
|
---|---|
### Instruction:
What is the number of patients discharged to psychiatric facility-partial hospitalization who had a (aorto)coronary bypass of three coronary arteries procedure?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DISCH-TRAN TO PSYCH HOSP" AND procedures.long_title = "(Aorto)coronary bypass of three coronary arteries" |
### Instruction:
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of hire_date and the average of salary bin hire_date by time.
### Response:
| SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 |
### Instruction:
how many patients have actually had a urea nitrogen, body fluid test until 3 years ago?
### Response:
| SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'urea nitrogen, body fluid') AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-3 year')) |
### Instruction:
when the last time patient 76332 had a phosphate lab test in their current hospital encounter?
### Response:
| SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76332 AND admissions.dischtime IS NULL) ORDER BY labevents.charttime DESC LIMIT 1 |
### Instruction:
how many times did patient 021-196241 during this year go to the icu?
### Response:
| SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-196241') AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') |
### Instruction:
Top 100 questions by tags in the last year (sorted by viewcount).
### Response:
| SELECT Id, Title, CreationDate, Tags, ClosedDate, FavoriteCount, ViewCount, Score FROM Posts WHERE PostTypeId = 1 AND Tags LIKE '%##TagName1##%' AND Tags LIKE '%##TagName2##%' AND NOT Tags LIKE '%##ExcludedTag##%' AND Posts.CreationDate > CURRENT_TIMESTAMP() - 365 ORDER BY ViewCount DESC, FavoriteCount DESC, Score DESC LIMIT 100 |
### Instruction:
what is [ / ] when [ ] is [t ]?
### Response:
| SELECT "\u0494\u044c \u0495\u044c [\u0281\u02b2/\u0263\u02b2]" FROM table_23624 WHERE "\u0413\u044c \u0433\u044c [\u0261\u02b2]" = 'Ҷ ҷ [t͡ʃʼ]' |
### Instruction:
subjects between the ages of 18 and 65 years, inclusive, with a body mass index ( bmi ) of 18.5 to 45 kg / m2 and c _ peptide > 0.8 ng / ml.
### Response:
| SELECT * FROM table_dev_54 WHERE (age >= 18 AND age <= 65) AND (body_mass_index_bmi >= 18.5 AND body_mass_index_bmi <= 45 AND c_peptide_level > 0.8) |
### Instruction:
what is the number of patients whose admission location is transfer from hosp/extram and primary disease is coronary artery disease\coronary artery bypass graft with mvr; ? maze?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" |
### Instruction:
provide the number of patients whose diagnoses icd9 code is v4281 and lab test fluid is cerebrospinal fluid (csf)?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "V4281" AND lab.fluid = "Cerebrospinal Fluid (CSF)" |
### Instruction:
when did patient 013-30085 get a lab test for the first time on their current hospital visit?
### Response:
| SELECT lab.labresulttime FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-30085' AND patient.hospitaldischargetime IS NULL)) ORDER BY lab.labresulttime LIMIT 1 |
### Instruction:
provide the number of patients whose primary disease is squamous cell carcinoma oral tongue/sda and procedure short title is opn mitral valvuloplasty?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "SQUAMOUS CELL CARCINOMA ORAL TONGUE/SDA" AND procedures.short_title = "Opn mitral valvuloplasty" |
### Instruction:
StackOverflow Rank and Percentile With Minimum Rep.
### Response:
| WITH Rankings AS (SELECT Id, Reputation, Ranking = ROW_NUMBER() OVER (ORDER BY Reputation DESC) FROM Users), Counts AS (SELECT Count = COUNT(*) FROM Users WHERE Reputation > '##minRep:int?200##') SELECT Id, Reputation, Ranking, CAST(Ranking AS FLOAT(20, 5)) / (SELECT Count FROM Counts) AS Percentile FROM Rankings WHERE Id = '##userid:int##' |
### Instruction:
what is the minimum hospital bill that includes pneumonia - aspiration?
### Response:
| SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'pneumonia - aspiration')) GROUP BY cost.patienthealthsystemstayid) AS t1 |
### Instruction:
how much does diagnostics of peritoneal abscess cost?
### Response:
| SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'peritoneal abscess')) |
### Instruction:
calculate the number of times that sodium chloride 0.9% was prescribed to patient 032-2747.
### Response:
| SELECT COUNT(*) FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '032-2747')) AND medication.drugname = 'sodium chloride 0.9%' |
### Instruction:
the number of patients who had a blood culture ( myco/f lytic bottle) microbiological test in 2105.
### Response:
| SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT microbiologyevents.hadm_id FROM microbiologyevents WHERE microbiologyevents.spec_type_desc = 'blood culture ( myco/f lytic bottle)' AND STRFTIME('%y', microbiologyevents.charttime) = '2105') |
### Instruction:
Rollback Done By A User. This shows rollbacks that a particular user has performed. Enter the user ID. Results will be all rollback edits that that user has done.
### Response:
| SELECT h.UserId AS "user_link", h.PostId AS "post_link", h.CreationDate AS Date, h.PostHistoryTypeId AS Type, h.Comment, h.Text FROM PostHistory AS h WHERE UserId = 285587 AND PostHistoryTypeId IN (7, 8, 9) ORDER BY h.CreationDate DESC |
### Instruction:
Show the number of documents for different budget type code in a bar chart, show by the Y-axis in desc.
### Response:
| SELECT T1.Budget_Type_Code, COUNT(T1.Budget_Type_Code) FROM Documents_with_Expenses AS T1 JOIN Ref_Budget_Codes AS T2 ON T1.Budget_Type_Code = T2.Budget_Type_Code GROUP BY T1.Budget_Type_Code ORDER BY COUNT(T1.Budget_Type_Code) DESC |
### Instruction:
give the number of patients who have been diagnosed with asthma, unspecified type, unspecified and drug type base.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Asthma, unspecified type, unspecified" AND prescriptions.drug_type = "BASE" |
### Instruction:
when did patient 015-56556 get admitted into the hospital via recovery room for the first time during a year before?
### Response:
| SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '015-56556' AND patient.hospitaladmitsource = 'recovery room' AND DATETIME(patient.hospitaladmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY patient.hospitaladmittime LIMIT 1 |
### Instruction:
how many patients whose diagnoses long title is other and unspecified noninfectious gastroenteritis and colitis and lab test abnormal status is delta?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Other and unspecified noninfectious gastroenteritis and colitis" AND lab.flag = "delta" |
### Instruction:
has patient 99883 received meds in 12/this year?
### Response:
| SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 99883) AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', prescriptions.startdate) = '12' |
### Instruction:
baseline hgb below the lower limits of normal at the local laboratory; lymphopenia ( < 1000 / l ) , neutropenia ( < 1500 / l ) , or thrombocytopenia ( platelets < 100000 / l ) .
### Response:
| SELECT * FROM table_dev_20 WHERE lymphopenia < 1000 AND neutropenia < 1500 OR thrombocytopenia = 1 OR platelets < 100000 |
### Instruction:
tell me the last test that patient 29806 had received on their first hospital visit?
### Response:
| SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT labevents.itemid FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 29806 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) ORDER BY labevents.charttime DESC LIMIT 1) |
### Instruction:
count the number of patients whose admission locations is phys referral/normal deli and diagnosis long title is diverticulitis of colon (without mention of hemorrhage).
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND diagnoses.long_title = "Diverticulitis of colon (without mention of hemorrhage)" |
### Instruction:
what is the average number of yearly diagnosed cases of hypoxemia until 4 years ago?
### Response:
| SELECT AVG(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'hypoxemia' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY STRFTIME('%y', diagnosis.diagnosistime)) AS t1 |
### Instruction:
how many hours have passed since last time that patient 021-111547 stayed in ward 814 in this hospital visit?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '021-111547' AND patient.wardid = 814 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1 |
### Instruction:
how long was patient 011-54801's first hospital stay in the icu?
### Response:
| SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-54801') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime LIMIT 1 |
### Instruction:
what's the number of patients who had a pantoprazole (ns)-in intake until 2104?
### Response:
| SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT intakeoutput.patientunitstayid FROM intakeoutput WHERE intakeoutput.celllabel = 'pantoprazole (ns)-in' AND intakeoutput.cellpath LIKE '%input%' AND STRFTIME('%y', intakeoutput.intakeoutputtime) <= '2104') |
### Instruction:
tell me the last specimen test given to patient 51177 in 10/2105?
### Response:
| SELECT microbiologyevents.spec_type_desc FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 51177) AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2105-10' ORDER BY microbiologyevents.charttime DESC LIMIT 1 |
### Instruction:
Count of posts by age in days.
### Response:
| WITH PostAge AS (SELECT Id, DATEDIFF(day, CreationDate, @LastVote) AS Age FROM Posts WHERE PostTypeId = '##PostTypeId:int?2##'), PostsByAge AS (SELECT Age, COUNT(*) AS Count FROM PostAge GROUP BY Age) SELECT Age, Count, SUM(Count) OVER (ORDER BY Age DESC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS RollingCount FROM PostsByAge ORDER BY Age |
### Instruction:
what is the number of patients whose primary disease is st-segment elevation myocardial infarction\cardiac cath and drug route is iv bolus?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "ST-SEGMENT ELEVATION MYOCARDIAL INFARCTION\CARDIAC CATH" AND prescriptions.route = "IV BOLUS" |
### Instruction:
significant neurologic disease such as alzheimer's disease, parkinson's disease, stroke, brain tumor, multiple sclerosis or seizure disorder.
### Response:
| SELECT * FROM table_train_123 WHERE neurological_disease = 1 OR (alzheimer_disease_ad = 1 OR parkinson_disease = 1 OR stroke = 1 OR brain_tumor = 1 OR multiple_sclerosis = 1 OR seizure_disorder = 1) |
### Instruction:
how many hours have passed since patient 007-16517 stayed in ward 425 for the last time on the current hospital encounter?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '007-16517' AND patient.wardid = 425 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1 |
### Instruction:
Show the names of donors who donated to both school 'Glenn' and 'Triton.
### Response:
| SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Glenn' INTERSECT SELECT T1.donator_name FROM endowment AS T1 JOIN school AS T2 ON T1.school_id = T2.school_id WHERE T2.school_name = 'Triton' |
### Instruction:
was patient 003-30817 diagnosed with an anemia - acute blood loss anemia?
### Response:
| SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-30817')) AND diagnosis.diagnosisname = 'anemia - acute blood loss anemia' |
### Instruction:
List the number of enginners in a stacked bar chart The x-axis is first name and group by skill description, could you rank Y-axis in ascending order?
### Response:
| SELECT first_name, COUNT(first_name) FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY skill_description, first_name ORDER BY COUNT(first_name) |
### Instruction:
Users with highest reputation both in SO and Math ( geometric mean = average digits).
### Response:
| SELECT s.DisplayName, s.Reputation AS RepSO, m.Reputation AS RepMath, (LOG10(s.Reputation) + LOG10(m.Reputation)) / 2 AS RepAvDigits FROM "stackexchange.math".Users AS m, "stackoverflow".Users AS s WHERE s.Reputation > 10000 AND m.Reputation > 10000 AND s.AccountId = m.AccountId ORDER BY 4 DESC |
### Instruction:
what cost does a procedure called inject/inf thrombo agent cost?
### Response:
| SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'procedures_icd' AND cost.event_id IN (SELECT procedures_icd.row_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'inject/inf thrombo agent')) |
### Instruction:
What is the lowest number of members on the Cultural and Educational Panel, when the University of Dublin had 3 members, when the Industrial and Commercial Panel had more than 0 members, and when the Agricultural Panel had more than 4 members?
### Response:
| SELECT MIN("Cultural and Educational Panel") FROM table_40908 WHERE "University of Dublin" < '3' AND "Industrial and Commercial Panel" > '0' AND "Agricultural Panel" > '4' |
### Instruction:
tell me the number of times a extracorporeal circulat procedure was done until 1 year ago?
### Response:
| SELECT COUNT(*) FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'extracorporeal circulat') AND DATETIME(procedures_icd.charttime) <= DATETIME(CURRENT_TIME(), '-1 year') |
### Instruction:
Extract accepted and most-voted answer of a question.
### Response:
| SELECT * FROM (SELECT Id, Body, Score, DENSE_RANK() OVER (ORDER BY Score DESC) AS Rank FROM (SELECT a.Id, a.ParentId, a.Body, a.Score FROM Posts AS a WHERE a.ParentId = '##QuestionId##') AS x LIMIT 2) AS x WHERE (SELECT q.AcceptedAnswerId FROM Posts AS q WHERE q.Id = '##QuestionId##') = Id OR Rank = 1 |
### Instruction:
Lists users in descending order of number of rollback edits they've done.. Lists users in descending order of number of rollback edits they've done.
### Response:
| SELECT r.UserId AS "user_link", COUNT(*) AS "Count" FROM (SELECT h.UserId FROM PostHistory AS h WHERE h.PostHistoryTypeId IN (7, 8, 9) AND NOT h.UserId IS NULL GROUP BY h.UserId, h.RevisionGUID) AS r GROUP BY r.UserId ORDER BY 'Count' DESC |
### Instruction:
Regarding the ANTHRARC 487 class , is there one on Friday ?
### Response:
| SELECT DISTINCT course_offering.friday FROM course INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'ANTHRARC' AND course.number = 487 AND semester.semester = 'WN' AND semester.year = 2016 |
### Instruction:
Find the physicians who are trained in a procedure that costs more than 5000, and count them by a bar chart, could you show in asc by the x axis?
### Response:
| SELECT T1.Name, COUNT(T1.Name) FROM Physician AS T1 JOIN Trained_In AS T2 ON T1.EmployeeID = T2.Physician JOIN Procedures AS T3 ON T3.Code = T2.Treatment WHERE T3.Cost > 5000 GROUP BY T1.Name ORDER BY T1.Name |
### Instruction:
how much does it cost to get checked for fall from ladder?
### Response:
| SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'diagnoses_icd' AND cost.event_id IN (SELECT diagnoses_icd.row_id FROM diagnoses_icd WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'fall from ladder')) |
### Instruction:
People who ask questions but do not accept answers.
### Response:
| SELECT u.Id, u.DisplayName, u.Reputation, COUNT(*) - COUNT(q.AcceptedAnswerId) FROM Users AS u INNER JOIN Posts AS q ON u.Id = q.OwnerUserId WHERE q.PostTypeId = 1 AND q.AnswerCount > 0 GROUP BY u.Id, u.DisplayName, u.Reputation HAVING COUNT(*) = (COUNT(*) - COUNT(q.AcceptedAnswerId)) AND COUNT(*) > 10 ORDER BY COUNT(*) DESC |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and employee_id , and visualize them by a bar chart, and sort by the y axis in descending.
### Response:
| SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID DESC |
### Instruction:
calculate the number of patients diagnosed during the last year with valvular stenosis - with chf.
### Response:
| SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'valvular stenosis - with chf' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')) |
### Instruction:
what is the yearly maximum amount of myelocytes patient 19412 has?
### Response:
| SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19412) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'myelocytes') GROUP BY STRFTIME('%y', labevents.charttime) |
### Instruction:
when did during the last year patient 64873 receive a first procedure?
### Response:
| SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 64873) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY procedures_icd.charttime LIMIT 1 |
### Instruction:
when did patient 19144 first undergo the procedure in this year?
### Response:
| SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19144) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY procedures_icd.charttime LIMIT 1 |
### Instruction:
when was the first hospital admission that patient 15209 was admitted to via the transfer from hosp/extram in this year?
### Response:
| SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 15209 AND admissions.admission_location = 'transfer from hosp/extram' AND DATETIME(admissions.admittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY admissions.admittime LIMIT 1 |
### Instruction:
how many days have elapsed since patient 015-23047's last stay in the ward 608 during this hospital visit?
### Response:
| SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '015-23047' AND patient.wardid = 608 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1 |
### Instruction:
Highest voted answers (obsolete query).
### Response:
| SELECT r.Score AS rRep, q.Score AS qRep, 'http://earthscience.stackexchange.com/a/' + CAST(r.Id AS TEXT) + '/5917|' + q.Title AS link, q.Tags AS tags, r.LastEditDate AS rDate FROM Posts AS r, Posts AS q WHERE q.Id = r.ParentId AND r.PostTypeId = 2 AND r.Score >= 30 ORDER BY rRep DESC |
### Instruction:
users by location (stack overflow).
### Response:
| SELECT u.Id, u.DisplayName, u.Reputation, u.WebsiteUrl, u.Age, u.LastAccessDate, u.Location FROM Users AS u WHERE (LOWER(u.Location) LIKE LOWER('##Location:string##')) OR (LOWER(u.Location) LIKE LOWER('##AltLocation:string##')) OR (LOWER(u.Location) LIKE LOWER('##AltLocation2:string##')) ORDER BY u.Reputation DESC LIMIT 100 |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, show me the trend about employee_id over hire_date with a line chart, could you order x-axis in descending order?
### Response:
| SELECT HIRE_DATE, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY HIRE_DATE DESC |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, return a bar chart about the distribution of first_name and manager_id , and could you sort by the y-axis from high to low?
### Response:
| SELECT FIRST_NAME, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY MANAGER_ID DESC |
### Instruction:
For Computational Complexity , will there be a reading group this year ?
### Response:
| SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE (course.description LIKE '%reading group%' OR course.name LIKE '%reading group%') AND (course.description LIKE '%Computational Complexity%' OR course.name LIKE '%Computational Complexity%') AND course.course_id = course_offering.course_id AND semester.semester_id = course_offering.semester AND semester.year = 2016 |
### Instruction:
Users with answers in most tags.
### Response:
| SELECT RANK() OVER (ORDER BY COUNT(DISTINCT pt.TagId) DESC) AS Rank, a.OwnerUserId AS "user_link", COUNT(DISTINCT pt.TagId) AS "#_of_tags" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id INNER JOIN PostTags AS pt ON pt.PostId = q.Id GROUP BY a.OwnerUserId ORDER BY COUNT(DISTINCT pt.TagId) DESC LIMIT 100 |
### Instruction:
Prof. Wilhelm Piskorowski teaches which courses ?
### Response:
| SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND instructor.name LIKE '%Wilhelm Piskorowski%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id |
### Instruction:
Find the last name of the first ever contact person of the organization with the highest UK Vat number.
### Response:
| SELECT t3.individual_last_name FROM organizations AS t1 JOIN organization_contact_individuals AS t2 ON t1.organization_id = t2.organization_id JOIN individuals AS t3 ON t2.individual_id = t3.individual_id WHERE t1.uk_vat_number = (SELECT MAX(uk_vat_number) FROM organizations) ORDER BY t2.date_contact_to LIMIT 1 |
### Instruction:
What is the total population in 2010 for the township located in Mountrail which has land less than 34.424 sq miles and a GEO ID less than 3806159940?
### Response:
| SELECT SUM("Pop. (2010)") FROM table_63856 WHERE "Land ( sqmi )" < '34.424' AND "County" = 'mountrail' AND "GEO ID" < '3806159940' |
### Instruction:
give me the number of patients whose diagnoses long title is electrolyte and fluid disorders not elsewhere classified and drug route is sl?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Electrolyte and fluid disorders not elsewhere classified" AND prescriptions.route = "SL" |
### Instruction:
what is the number of patients whose primary disease is st elevated myocardial infarction\cardiac cath and procedure icd9 code is 9465?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "ST ELEVATED MYOCARDIAL INFARCTION\CARDIAC CATH" AND procedures.icd9_code = "9465" |
### Instruction:
When critical altitude is sea level, what is the compression ration for a supercharger gear ratio of 7:1?
### Response:
| SELECT "Compression ratio" FROM table_16551 WHERE "Critical altitude This is the highest altitude at which the engine can achieve its full continuous power rating. Above this altitude, power falls off with height as with a naturally aspirated engine . See Supercharger#Altitude effects for details." = 'sea level' AND "Supercharger gear ratio" = '7:1' |
### Instruction:
how many patients who are diagnosed with short title encephalopathy nos have been prescibed additive type of drug?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Encephalopathy NOS" AND prescriptions.drug_type = "ADDITIVE" |
### Instruction:
what is the total bag dose that until 51 months ago patient 27591 has been prescribed?
### Response:
| SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27591) AND prescriptions.drug = 'bag' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-51 month') |
### Instruction:
What is the venue of the competition '1994 FIFA World Cup qualification' hosted by 'Nanjing ( Jiangsu )'?
### Response:
| SELECT T3.venue FROM city AS T1 JOIN hosting_city AS T2 ON T1.city_id = T2.host_city JOIN match AS T3 ON T2.match_id = T3.match_id WHERE T1.city = "Nanjing ( Jiangsu )" AND T3.competition = "1994 FIFA World Cup qualification" |
### Instruction:
Find number of Unanswered Questions on SO (questions with no answers at all). Counts the number of unanswered questions on SO, that are not community-wiki, not closed and have no accepted answer.
### Response:
| SELECT q.Id, q.ViewCount, q.Title FROM Posts AS q WHERE (SELECT COUNT(*) FROM Posts AS a WHERE a.ParentId = q.Id) = 0 AND CommunityOwnedDate IS NULL AND ClosedDate IS NULL AND q.ParentId IS NULL AND AcceptedAnswerId IS NULL ORDER BY ViewCount DESC |
### Instruction:
What are the number of the payment dates for any payments that have an amount greater than 10 or were handled by a staff member with the first name Elsa?, and show by the total number in asc please.
### Response:
| SELECT payment_date, COUNT(payment_date) FROM payment WHERE amount > 10 UNION SELECT T1.payment_date FROM payment AS T1 JOIN staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = 'Elsa' ORDER BY COUNT(payment_date) |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, a bar chart shows the distribution of job_id and commission_pct , and rank in descending by the Y-axis please.
### Response:
| SELECT JOB_ID, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT DESC |
### Instruction:
has patient 031-13920 undergone any lab test since 2104?
### Response:
| SELECT COUNT(*) > 0 FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-13920')) AND STRFTIME('%y', lab.labresulttime) >= '2104' |
### Instruction:
What is the full name of the staff member who has rented a film to a customer with the first name April and the last name Burns?
### Response:
| SELECT DISTINCT T1.first_name, T1.last_name FROM staff AS T1 JOIN rental AS T2 ON T1.staff_id = T2.staff_id JOIN customer AS T3 ON T2.customer_id = T3.customer_id WHERE T3.first_name = 'APRIL' AND T3.last_name = 'BURNS' |
### Instruction:
Which state spent the most revenue towards schools and whats the state average score
### Response:
| SELECT T2.state, T3.average_scale_score FROM finrev_fed_key_17 AS T2 JOIN finrev_fed_17 AS T1 ON T1.state_code = T2.state_code JOIN ndecoreexcel_math_grade8 AS T3 ON T2.state = T3.state GROUP BY T2.state ORDER BY SUM(T1.t_fed_rev) DESC LIMIT 1 |
### Instruction:
what is last weight of patient 013-29301 during their first hospital visit.
### Response:
| SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '013-29301' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1 |
### Instruction:
what's the top four most common output events until 2 years ago?
### Response:
| SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT outputevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM outputevents WHERE DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 4) |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, find phone_number and commission_pct , and visualize them by a bar chart, list total number in descending order.
### Response:
| SELECT PHONE_NUMBER, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT DESC |
### Instruction:
What are the names of the products that have a color description of 'red' and the 'fast' characteristic?
### Response:
| SELECT product_name FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN characteristics AS t3 ON t2.characteristic_id = t3.characteristic_id JOIN ref_colors AS t4 ON t1.color_code = t4.color_code WHERE t4.color_description = "red" AND t3.characteristic_name = "fast" |
### Instruction:
How many courses for each course description? Show me a bar chart, sort y-axis from low to high order.
### Response:
| SELECT CRS_DESCRIPTION, COUNT(CRS_DESCRIPTION) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE GROUP BY CRS_DESCRIPTION ORDER BY COUNT(CRS_DESCRIPTION) |
### Instruction:
how many hours have elapsed since the last time patient 016-9636 stayed in the ward 613 in this hospital visit?
### Response:
| SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '016-9636' AND patient.wardid = 613 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1 |
### Instruction:
Percentage of closed questions by each hour of the day.
### Response:
| SELECT TIME_TO_STR(q.CreationDate, '%I') AS "Hour", CAST((100.0 * COUNT(q.ClosedDate) / COUNT(*)) AS FLOAT(10, 0)) AS "Closed percent", COUNT(*) AS "question_count" FROM Posts AS q WHERE q.PostTypeId = 1 GROUP BY TIME_TO_STR(q.CreationDate, '%I') ORDER BY 'Hour' |
### Instruction:
what is the unabbreviated version of the imp crtd sinus stm,totl?
### Response:
| SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'imp crtd sinus stm,totl' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'imp crtd sinus stm,totl' |
### Instruction:
count the number of patients whose ethnicity is american indian/alaska native and procedure long title is initial insertion of single-chamber device, rate responsive?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND procedures.long_title = "Initial insertion of single-chamber device, rate responsive" |
### Instruction:
for the anal fistulotomy what does it cost?
### Response:
| SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'procedures_icd' AND cost.event_id IN (SELECT procedures_icd.row_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'anal fistulotomy')) |
### Instruction:
Most downvoted posts without a single (non-owner) comment.
### Response:
| SELECT Posts.Id AS "post_link", Posts.OwnerUserId AS "user_link", Posts.Score FROM Posts LEFT JOIN Comments ON Comments.PostId = Posts.Id AND Comments.UserId != Posts.OwnerUserId AND Comments.UserId > 1 WHERE Comments.Id IS NULL AND Posts.OwnerUserId > 1 AND Posts.Score < 0 ORDER BY Posts.Score, Posts.Id |
### Instruction:
provide the number of patients whose diagnoses short title is chrnc hpt c wo hpat coma and drug type is main?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Chrnc hpt C wo hpat coma" AND prescriptions.drug_type = "MAIN" |
### Instruction:
what is the four most frequently ordered procedure for a patient with an age 40s?
### Response:
| SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 40 AND 49) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4 |
### Instruction:
Amount of users who's last activity was during that month.
### Response:
| SELECT Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, Last_activity), 0), 'Lost members' = COUNT(activity.UserId) FROM (SELECT UserId, Last_activity = MAX(Date) FROM Badges INNER JOIN Users ON Badges.UserId = Users.Id GROUP BY UserId) AS activity GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Last_activity), 0) ORDER BY Month |
### Instruction:
Get me the number of patients admitted before 2145 who have a primary disease of atrial septal defect mitral valve replacement repair atrial-septal defect/sda.
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL SEPTAL DEFECT\MITRAL VALVE REPLACEMENT;REPAIR ATRIAL-SEPTAL DEFECT/SDA" AND demographic.admityear < "2145" |
### Instruction:
provide the number of patients whose diagnoses short title is subtrochanteric fx-close and drug route is left eye?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Subtrochanteric fx-close" AND prescriptions.route = "LEFT EYE" |
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a bar chart about the distribution of phone_number and department_id , I want to rank from high to low by the Y please.
### Response:
| SELECT PHONE_NUMBER, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY DEPARTMENT_ID DESC |
### Instruction:
Show the number of accounts for all accounts by the customer with first name 'Meaghan' opened in each day Bin the account open day by weekday in a bar chart, sort by the y-axis from high to low please.
### Response:
| SELECT date_account_opened, COUNT(date_account_opened) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan' ORDER BY COUNT(date_account_opened) DESC |
### Instruction:
How many professors whose office is located in DRE 102 are hired in each month? Return a bar chart, list by the how many emp hiredate in asc.
### Response:
| SELECT EMP_HIREDATE, COUNT(EMP_HIREDATE) FROM EMPLOYEE AS T1 JOIN PROFESSOR AS T2 ON T1.EMP_NUM = T2.EMP_NUM WHERE T2.PROF_OFFICE = 'DRE 102' ORDER BY COUNT(EMP_HIREDATE) |
### Instruction:
give me the number of patients whose admission year is less than 2115 and procedure long title is insertion of non-drug-eluting coronary artery stent(s)?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2115" AND procedures.long_title = "Insertion of non-drug-eluting coronary artery stent(s)" |
### Instruction:
How many items are listed under 'andrew and georgies guest lee mack replaced andrew flint as team captain for one week' for episode 04x04?
### Response:
| SELECT COUNT(andrew_and_georgies_guest_lee_mack_replaced_andrew_flintoff_as_team_captain_for_one_week_in_series_4), _episode_2 FROM table_29141354_4 WHERE episode = "04x04" |
### Instruction:
count the number of patients whose diagnoses long title is embolism and thrombosis of iliac artery and lab test abnormal status is delta?
### Response:
| SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Embolism and thrombosis of iliac artery" AND lab.flag = "delta" |
### Instruction:
when did patient 94956 last receive a microbiology test in 06/2105?
### Response:
| SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 94956) AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2105-06' ORDER BY microbiologyevents.charttime DESC LIMIT 1 |
### Instruction:
what was the first id of patient 1457's ward the last year?
### Response:
| SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1457) AND NOT transfers.wardid IS NULL AND DATETIME(transfers.intime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY transfers.intime LIMIT 1 |
Subsets and Splits