instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### 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:
what is the number of patients whose diagnoses icd9 code is v293 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 = "V293" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
|
### 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:
what is the drug patient 19627 was prescribed for the first time when they came to the hospital last time via ip route?
### Response:
|
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19627 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.route = 'ip' ORDER BY prescriptions.startdate LIMIT 1
|
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and department_id , and visualize them by a bar chart, and I want to show in desc by the DEPARTMENT_ID.
### Response:
|
SELECT FIRST_NAME, 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:
until 2104 has patient 003-33922 have had any allergy?
### Response:
|
SELECT COUNT(*) > 0 FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-33922')) AND STRFTIME('%y', allergy.allergytime) <= '2104'
|
### Instruction:
in total, count the number of times patient 79348 had been prescribed furosemide in this year.
### Response:
|
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 79348) AND prescriptions.drug = 'furosemide' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
what were the four most frequently taken specimen tests during this year?
### Response:
|
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 4
|
### 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:
what was the three most frequently tested lab test until 2 years ago?
### Response:
|
SELECT d_labitems.label FROM d_labitems WHERE d_labitems.itemid IN (SELECT t1.itemid FROM (SELECT labevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM labevents WHERE DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 3)
|
### 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:
count the number of patients whose diagnoses long title is other diseases of lung, not elsewhere classified and drug type is additive?
### 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 = "Other diseases of lung, not elsewhere classified" AND prescriptions.drug_type = "ADDITIVE"
|
### Instruction:
how many times was the metoclopramide prescribed in this month for patient 42829?
### Response:
|
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 42829) AND prescriptions.drug = 'metoclopramide' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
### 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 price of diagnosis of contusion of thigh?
### 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 = 'contusion of thigh'))
|
### Instruction:
how many hours does it have been since the first time patient 007-15837 stayed in ward 428 on the current hospital encounter?
### Response:
|
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '007-15837' AND patient.wardid = 428 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
Questions favorited only by the OP.
### Response:
|
SELECT Posts.Id AS "post_link", Posts.FavoriteCount, Posts.Score, Posts.CreationDate, Votes.UserId AS "user_link" FROM Votes JOIN Posts ON (Posts.Id = Votes.PostId) WHERE Posts.FavoriteCount = 1 AND VoteTypeId = 5 AND Posts.PostTypeId = 1 AND Posts.OwnerUserId = Votes.UserId ORDER BY Posts.CreationDate DESC
|
### Instruction:
count the number of patients whose diagnosis icd9 code is 3079 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 = "3079" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
|
### Instruction:
what is the minimum value of hematocrit in patient 14467's body in the current hospital encounter?
### Response:
|
SELECT MIN(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14467 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'hematocrit')
|
### Instruction:
tag is used in questions with the highest average score, excluding tags used in less than 5 questio.
### Response:
|
SELECT TagName, COUNT(PostId) AS numbers, AVG(CAST(Score AS FLOAT)) AS averageScore FROM (SELECT * FROM (SELECT Id, Score FROM Posts WHERE PostTypeId = 1) AS P JOIN PostTags ON PostTags.PostId = P.Id) AS T JOIN Tags ON Tags.Id = T.TagId GROUP BY TagName HAVING COUNT(PostId) >= 5 ORDER BY averageScore DESC
|
### Instruction:
tell me the dose of ns (syringe) that patient 30267 was prescribed in their last hospital encounter?
### Response:
|
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 30267 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.drug = 'ns (syringe)'
|
### Instruction:
calculate the length of the hospital stay of patient 008-186's first intensive care unit stay.
### Response:
|
SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '008-186') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
display the full name (first and last name ) of employee with ID and name of the country presently where (s)he is working.
### Response:
|
SELECT T1.first_name, T1.last_name, T1.employee_id, T4.country_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id JOIN locations AS T3 ON T2.location_id = T3.location_id JOIN countries AS T4 ON T3.country_id = T4.country_id
|
### Instruction:
Total views by tag for 2016.
### Response:
|
SELECT TagName AS tag_name, SUM(ViewCount) AS views FROM Tags, PostTags, Posts WHERE Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate > '2016-01-01' AND Posts.CreationDate < '2017-01-01' AND Posts.PostTypeId = 1 GROUP BY TagName HAVING SUM(ViewCount) > 10000
|
### Instruction:
give me the number of patients whose diagnoses short title is hx tia/stroke w/o resid and drug route is iv bolus?
### 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 = "Hx TIA/stroke w/o resid" AND prescriptions.route = "IV BOLUS"
|
### Instruction:
List the courses that satisfy the MDE requirement in Phys Princ Smart Dev ?
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%Phys Princ Smart Dev%' OR course.description LIKE '%Phys Princ Smart Dev%' OR course.name LIKE '%Phys Princ Smart Dev%') AND program_course.category LIKE '%MDE%'
|
### Instruction:
Tags with the highest percentage of closed questions.
### Response:
|
SELECT tag.TagName AS "tag_name", tag.Count AS "deletion_percentage", p.Id AS "post_link" FROM Tags AS tag INNER JOIN Posts AS p ON p.Tags LIKE CONCAT(CONCAT('%<', tag.TagName COLLATE SQL_Latin1_General_CP1_CI_AS), '>%') AND NOT p.ClosedDate IS NULL GROUP BY p.Id, tag.TagName, tag.Count ORDER BY tag.Count DESC LIMIT 10
|
### Instruction:
give me the number of patients whose diagnoses short title is crn ath atlg vn bps grft and lab test category is hematology?
### 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.short_title = "Crn ath atlg vn bps grft" AND lab."CATEGORY" = "Hematology"
|
### Instruction:
how many patients whose procedure long title is excision or destruction of other lesion or tissue of heart, open approach and lab test fluid is pleural?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE procedures.long_title = "Excision or destruction of other lesion or tissue of heart, open approach" AND lab.fluid = "Pleural"
|
### 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 last_name and employee_id , could you show EMPLOYEE_ID in ascending order?
### Response:
|
SELECT LAST_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
|
### Instruction:
Minecraft questions from the last ten days.
### Response:
|
SELECT DISTINCT Posts.Id AS "post_link", Posts.CreationDate, Posts.ClosedDate, Score, Tags FROM Posts INNER JOIN PostTags ON (Posts.Id = PostTags.PostId) INNER JOIN Tags ON (PostTags.TagId = Tags.Id AND Tags.TagName LIKE 'minecraft%') WHERE Posts.PostTypeId = 1 AND Posts.CreationDate >= DATEADD(d, -10, GETDATE()) ORDER BY CreationDate DESC
|
### Instruction:
had patient 2536 had a enterostomy nec?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'enterostomy nec') AND procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2536)
|
### Instruction:
What is the mpg-uk combined with an mpg-uk urban (cold) greater than 26.6, a m5 transmission, a diesel fuel type, and an engine capacity less than 1560?
### Response:
|
SELECT "mpg-UK Combined" FROM table_65277 WHERE "mpg-UK Urban (Cold)" > '26.6' AND "Transmission" = 'm5' AND "Fuel Type" = 'diesel' AND "Engine Capacity" < '1560'
|
### Instruction:
Questions and Answers per Day since some date.
### Response:
|
SELECT DATE(CreationDate), SUM(CASE WHEN PostTypeId = 1 THEN 1 ELSE 0 END) AS Questions, SUM(CASE WHEN PostTypeId = 2 THEN 1 ELSE 0 END) AS Answers FROM Posts WHERE CAST(TIME_TO_STR(CreationDate, '%Y-%m-%d %H:%M:%S') AS TEXT(10)) >= '##Date##' GROUP BY DATE(CreationDate) ORDER BY DATE(CreationDate) DESC
|
### Instruction:
during this year what was the four most commonly ordered specimen test?
### Response:
|
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY microlab.culturesite) 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, give me the comparison about department_id over the last_name by a bar chart, and could you rank from low to high by the DEPARTMENT_ID please?
### Response:
|
SELECT LAST_NAME, 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
|
### Instruction:
provide the number of patients whose diagnoses short title is hx tia/stroke w/o resid and drug name is warfarin?
### 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 = "Hx TIA/stroke w/o resid" AND prescriptions.drug = "Warfarin"
|
### Instruction:
What is the first name of each student who is not allergic to any type of food? Count them in a bar chart, and I want to list from high to low by the Y.
### Response:
|
SELECT Fname, COUNT(Fname) FROM Student WHERE NOT StuID IN (SELECT T1.StuID FROM Has_Allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.AllergyType = "food") GROUP BY Fname ORDER BY COUNT(Fname) DESC
|
### Instruction:
since 09/2104 has there been a urine microbiology test for patient 86791?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 86791) AND microbiologyevents.spec_type_desc = 'urine' AND STRFTIME('%y-%m', microbiologyevents.charttime) >= '2104-09'
|
### Instruction:
The names of Prof. Annette Masson 's 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 '%Annette Masson%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
|
### Instruction:
Can you show me which courses involve parts of Modern Dance and Restoration Ecology .
### Response:
|
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id WHERE (area.area LIKE '%Restoration Ecology%' OR course.description LIKE '%Restoration Ecology%' OR course.name LIKE '%Restoration Ecology%') AND (area.area LIKE '%Modern Dance%' OR course.description LIKE '%Modern Dance%' OR course.name LIKE '%Modern Dance%')
|
### Instruction:
in 2105 patient 006-202432 underwent any laboratory tests?
### 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 = '006-202432')) AND STRFTIME('%y', lab.labresulttime) = '2105'
|
### Instruction:
is patient 003-29149 prescribed medication in 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '003-29149')) AND STRFTIME('%y', medication.drugstarttime) = '2105'
|
### Instruction:
what was the amount of total output that patient 25312 had received on the first intensive care unit visit?
### Response:
|
SELECT SUM(outputevents.value) FROM outputevents WHERE outputevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25312) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1)
|
### Instruction:
Which slope length has a type of surface lift, and an elevation groundstation smaller than 1974, and a construction year(s) of 1971, and a Name or route of alpmatten 1?
### Response:
|
SELECT "slope length" FROM table_79056 WHERE "type" = 'surface lift' AND "elevation groundstation" < '1974' AND "construction year(s)" = '1971' AND "Name or route" = 'alpmatten 1'
|
### Instruction:
Show the number of courses for each course description in a stacked bar chart. The x-axis is course description and group by instructor's name.
### 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 EMP_FNAME, CRS_DESCRIPTION
|
### Instruction:
Which classes have been or will be taught by Prof. Sonya Lewis ?
### 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 '%Sonya Lewis%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
|
### Instruction:
whats the first ward id of patient 006-77873 in this year?
### Response:
|
SELECT patient.wardid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-77873') AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY patient.unitadmittime LIMIT 1
|
### Instruction:
What are the first names of the professors who do not play Canoeing or Kayaking as activities?
### Response:
|
SELECT lname FROM faculty WHERE rank = 'Professor' EXCEPT SELECT DISTINCT T1.lname FROM faculty AS T1 JOIN faculty_participates_in AS T2 ON T1.facid = T2.facid JOIN activity AS T3 ON T2.actid = T2.actid WHERE T3.activity_name = 'Canoeing' OR T3.activity_name = 'Kayaking'
|
### Instruction:
Who has taught , is teaching , or will teach Dissertation-Candidacy ?
### Response:
|
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN course_offering ON offering_instructor.offering_id = course_offering.offering_id INNER JOIN course ON course.course_id = course_offering.course_id WHERE course.name LIKE '%Dissertation-Candidacy%'
|
### Instruction:
what was the name of the medication that was prescribed during this month for patient 55360 last?
### Response:
|
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 55360) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
how many patients whose admission year is less than 2138 and diagnoses long title is adrenal cortical steroids causing adverse effects in therapeutic use?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2138" AND diagnoses.long_title = "Adrenal cortical steroids causing adverse effects in therapeutic use"
|
### Instruction:
Number of Distinct Dart Answerers with Score > 0 by Month.
### Response:
|
SELECT COUNT(DISTINCT OwnerUserId) AS Qty, MONTH(CreationDate) AS Month, YEAR(CreationDate) AS Year FROM Posts WHERE Posts.ParentId IN (SELECT PostTags.PostId FROM PostTags WHERE PostTags.TagId = 73780) AND Posts.PostTypeId = 2 AND Posts.Score > 0 GROUP BY MONTH(CreationDate), YEAR(CreationDate)
|
### Instruction:
Evolution of the time between the question and the answer up to a given number of days.
### Response:
|
SELECT CAST(q.CreationDate AS DATE) AS "Date", DATEDIFF(DAY, q.CreationDate, CreationDate) AS "Delay to answer" FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND a.PostTypeId = 2 AND DATEDIFF(DAY, q.CreationDate, CreationDate) < @N ORDER BY 'Date' DESC
|
### Instruction:
Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
### Response:
|
SELECT T1.fname, T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
|
### Instruction:
Count the Earnings per share ( ) in April smaller than 2012, a Revenue (US $million) of 432.6 and a EBIT (US $m) smaller than 150.5?
### Response:
|
SELECT SUM(earnings_per_share__) AS ¢_ FROM table_name_34 WHERE year_to_april < 2012 AND revenue__us_$million_ = 432.6 AND ebit__us_$m_ < 150.5
|
### Instruction:
Calculate the number of patients diagnosed with other anomalies of larynx, trachea, and bronchus who had delta abnormal lab tests.
### 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 anomalies of larynx, trachea, and bronchus" AND lab.flag = "delta"
|
### Instruction:
what is the number of patients whose primary disease is sigmoid diverticulitis, colovestical fistula/sda and drug route is dialys?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "SIGMOID DIVERTICULITIS, COLOVESTICAL FISTULA/SDA" AND prescriptions.route = "DIALYS"
|
### Instruction:
provide the number of patients on pb route of drug administration who are diagnosed with neonatal jaundice associated with preterm delivery.
### 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 = "Neonatal jaundice associated with preterm delivery" AND prescriptions.route = "PB"
|
### 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:
Manja Holland teaches which courses currently , previously or in the future ?
### 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 '%Manja Holland%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
|
### 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 many patients stayed in hospital for more than 5 days and were diagnosed with phlebitis and thrombophlebitis of superficial veins of upper extremities?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.days_stay > "5" AND diagnoses.long_title = "Phlebitis and thrombophlebitis of superficial veins of upper extremities"
|
### Instruction:
provide the number of patients whose primary disease is atrial fibrillation\thoracoscopic maze procedure bilateral/sda and year of death is less than or equal to 2148?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL FIBRILLATION\THORACOSCOPIC MAZE PROCEDURE BILATERAL/SDA" AND demographic.dod_year <= "2148.0"
|
### 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:
How many answers I posted by Year.
### Response:
|
SELECT YEAR(a.CreationDate) AS "year", MONTH(a.CreationDate) AS "month", COUNT(*) AS "number_of_answers" FROM Posts AS a INNER JOIN Users ON Users.Id = a.OwnerUserId WHERE a.OwnerUserId = @UserId GROUP BY YEAR(a.CreationDate), MONTH(a.CreationDate) ORDER BY YEAR(a.CreationDate) DESC, MONTH(a.CreationDate) DESC
|
### Instruction:
A bar chart about the number of faults for different fault short name, sort from low to high by the y-axis.
### Response:
|
SELECT fault_short_name, COUNT(fault_short_name) FROM Part_Faults AS T1 JOIN Skills_Required_To_Fix AS T2 ON T1.part_fault_id = T2.part_fault_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY fault_short_name ORDER BY COUNT(fault_short_name)
|
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, find phone_number and employee_id , and visualize them by a bar chart, and order total number from high to low order.
### Response:
|
SELECT PHONE_NUMBER, 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:
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:
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 payment_date in asc order.
### 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' GROUP BY payment_date ORDER BY payment_date
|
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the change of commission_pct over hire_date in a line chart, show HIRE_DATE in desc order.
### Response:
|
SELECT HIRE_DATE, COMMISSION_PCT 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:
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:
count the number of patients whose ethnicity is american indian/alaska native and drug name is syringe (neonatal) *d5w*?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND prescriptions.drug = "Syringe (Neonatal) *D5W*"
|
### 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 was the last weight for patient 005-73237 in the first hospital encounter?
### Response:
|
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-73237' 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 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 are the five most frequently occurrences of output events since 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 <= 5)
|
### Instruction:
what is the daily average amount of albumin of patient 19175?
### Response:
|
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19175) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'albumin') GROUP BY STRFTIME('%y-%m-%d', labevents.charttime)
|
### Instruction:
how many patients whose diagnoses long title is angioneurotic edema, not elsewhere classified 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.long_title = "Angioneurotic edema, not elsewhere classified" AND prescriptions.drug_type = "MAIN"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.