instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: Most cited papers on Parsing ### Response:
SELECT DISTINCT cite.citedpaperid, COUNT(cite.citedpaperid) FROM cite, keyphrase, paper, paperkeyphrase WHERE keyphrase.keyphrasename = 'Parsing' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = cite.citedpaperid AND paper.paperid = paperkeyphrase.paperid GROUP BY cite.citedpaperid ORDER BY COUNT(cite.citedpaperid) DESC
### Instruction: how many patients were prescribed with maalox/benadryl/lidocaine in the previous year? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'maalox/benadryl/lidocaine' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: what was the last weight for patient 021-250695 during the last hospital visit? ### Response:
SELECT patient.admissionweight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-250695' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1) AND NOT patient.admissionweight IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: have patient 010-20205 produce any med ct x2? ### Response:
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-20205')) AND intakeoutput.cellpath LIKE '%output%' AND intakeoutput.celllabel = 'med ct x2'
### 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, for salary, hire_date, visualize the trend, rank in asc by the X please. ### Response:
SELECT HIRE_DATE, SALARY FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 ORDER BY HIRE_DATE
### Instruction: whats the three most common specimen test this year? ### Response:
SELECT t1.spec_type_desc FROM (SELECT microbiologyevents.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microbiologyevents WHERE DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 3
### Instruction: find the number of patients who were diagnosed with arterial embolism and thrombosis of lower extremity and lab test abnormal status is abnormal? ### 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 = "Arterial embolism and thrombosis of lower extremity" AND lab.flag = "abnormal"
### Instruction: when was for the last time during the last hospital encounter patient 31696 prescribed a medication via po/ng route? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31696 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.route = 'po/ng' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: count the number of patients whose ethnicity is hispanic/latino - puerto rican and drug code is lide4500i? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND prescriptions.formulary_drug_cd = "LIDE4500I"
### Instruction: count the number of patients whose diagnoses icd9 code is 56721 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 = "56721" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: give me the number of patients whose diagnoses short title is full incontinence-feces and procedure short title is int insert dual-cham dev? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE diagnoses.short_title = "Full incontinence-feces" AND procedures.short_title = "Int insert dual-cham dev"
### Instruction: BIOMATLS 568 has who as a teacher ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'BIOMATLS' AND course.number = 568 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: count how many times patient 030-49739 came to the intensive care unit in this year. ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-49739') AND DATETIME(patient.unitadmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
### Instruction: did there exist any microbiological tests for patient 1114's sputum since 11/2105? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1114) AND microbiologyevents.spec_type_desc = 'sputum' AND STRFTIME('%y-%m', microbiologyevents.charttime) >= '2105-11'
### Instruction: Top US JavaScript answerers with email. ### Response:
SELECT u.Id AS "user_link", u.Reputation, u.WebsiteUrl, COUNT(*) AS JavascriptAnswers FROM Users AS u, Posts AS p, Posts AS pp WHERE u.Id IN (SELECT Id FROM Users WHERE Location LIKE ('%United States')) AND p.OwnerUserId = u.Id AND pp.Id = p.ParentId AND pp.Tags LIKE ('%<javascript>%') GROUP BY u.Id, u.Reputation, u.WebsiteUrl ORDER BY JavascriptAnswers DESC
### Instruction: how many patients underwent a therapeutic antibacterials - aminoglycoside two or more times? ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'therapeutic antibacterials - aminoglycoside') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 >= 2
### Instruction: since 2 years ago, had patient 006-7325 had any allergies? ### 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 = '006-7325')) AND DATETIME(allergy.allergytime) >= DATETIME(CURRENT_TIME(), '-2 year')
### Instruction: What are the names of the campus that have more faculties in 2002 than the maximum number in Orange county? ### Response:
SELECT T1.campus FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND faculty > (SELECT MAX(faculty) FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = T2.campus WHERE T2.year = 2002 AND T1.county = "Orange")
### Instruction: what specimen test was given to patient 97330 for the last time since 09/2103? ### Response:
SELECT microbiologyevents.spec_type_desc FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97330) AND STRFTIME('%y-%m', microbiologyevents.charttime) >= '2103-09' ORDER BY microbiologyevents.charttime DESC LIMIT 1
### 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, give me the comparison about the amount of hire_date over the hire_date bin hire_date by time. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: Find Questions that link to Mine. ### Response:
SELECT 'pl'."postid" AS "post_link", 'pl'."relatedpostid" AS "post_link", 'pl'.* FROM PostLinks AS "pl" INNER JOIN Posts AS "p1" ON ('pl'."postid" = 'p1'."id") INNER JOIN Posts AS "p2" ON ('pl'."relatedpostid" = 'p2'."id") WHERE '##UserId##' IN ('p1'.owneruserid, 'p2'.owneruserid)
### Instruction: is in their current hospital encounter patient 013-28507 diagnosed with 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 = '013-28507' AND patient.hospitaldischargetime IS NULL)) AND diagnosis.diagnosisname = 'anemia'
### 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: in the current hospital encounter, what was the first value of the po2 for patient 76332? ### Response:
SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76332 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'po2') ORDER BY labevents.charttime LIMIT 1
### 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: How many students taking a course who received an A or C? Group by students' first name with a bar chart, and show in desc by the names. ### Response:
SELECT STU_FNAME, COUNT(STU_FNAME) FROM STUDENT AS T1 JOIN ENROLL AS T2 ON T1.STU_NUM = T2.STU_NUM WHERE T2.ENROLL_GRADE = 'C' OR T2.ENROLL_GRADE = 'A' GROUP BY STU_FNAME ORDER BY STU_FNAME DESC
### 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: how many hours have passed since the first stay of patient 006-143187 in the ward 376 in the current hospital visit? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '006-143187' AND patient.wardid = 376 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1
### 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: what are the four most frequent intakes since 2104? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT inputevents_cv.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM inputevents_cv WHERE STRFTIME('%y', inputevents_cv.charttime) >= '2104' GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 4)
### 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: For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and commission_pct , and visualize them by a bar chart, and I want to list from high to low by the X. ### Response:
SELECT FIRST_NAME, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY FIRST_NAME DESC
### 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: what the first height of patient 011-36282 until 12 months ago. ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '011-36282') AND NOT patient.admissionheight IS NULL AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-12 month') ORDER BY patient.unitadmittime LIMIT 1
### 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: Recruiting Query Tool - Badge, Location. ### Response:
SELECT * FROM Badges INNER JOIN Users ON Users.Id = UserId WHERE Name LIKE '##Badge##' AND Location LIKE '##Location##' AND (AboutMe LIKE '%@%' OR AboutMe LIKE '%gmail%' OR AboutMe LIKE '%yahoo%' OR AboutMe LIKE '%linkedin%' OR AboutMe LIKE '.edu' OR AboutMe LIKE '%github%' OR AboutMe LIKE '%.com' OR AboutMe LIKE '%.org' OR AboutMe LIKE '%.io%') ORDER BY 'lastaccessdate' DESC
### Instruction: did any phenytoin (suspension) ever been prescribed to patient 77980 until 4 years ago? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77980) AND prescriptions.drug = 'phenytoin (suspension)' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-4 year')
### 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 display in desc by the EMPLOYEE_ID? ### 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 DESC
### Instruction: Top 10 users with most rep, that never accepted anything. ### Response:
WITH Raw AS (SELECT OwnerUserId AS UserId, COUNT(*) AS Questions FROM Posts WHERE PostTypeId = 1 AND OwnerUserId > 0 GROUP BY OwnerUserId HAVING COUNT(AcceptedAnswerId) = 0) SELECT Users.Id, Users.Id AS "user_link", Users.Reputation, Raw.Questions FROM Raw, Users WHERE Raw.UserId = Users.Id ORDER BY Users.Reputation DESC, Users.Id LIMIT 100
### Instruction: Upvoted questions closed as duplicate of downvoted one. ### Response:
SELECT s.Id AS "post_link", s.Score, MAX(t.Score) AS tScore FROM Posts AS t INNER JOIN PostLinks AS l ON t.Id = l.RelatedPostId INNER JOIN Posts AS s ON s.Id = l.PostId WHERE s.Score >= '##minscore:int?20##' AND l.LinkTypeId = 3 GROUP BY s.Id, s.Score ORDER BY MAX(t.Score) LIMIT 200
### Instruction: what were the top five most common procedures? ### Response:
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT t1.icd9_code FROM (SELECT procedures_icd.icd9_code, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM procedures_icd GROUP BY procedures_icd.icd9_code) AS t1 WHERE t1.c1 <= 5)
### Instruction: What is the Lower index Kcal/ Nm 3 entry, for the row with entries of an Upper index Kcal/ Nm 3 smaller than 19,376, and a Lower index MJ/ Nm 3 of 74.54? ### Response:
SELECT AVG("Lower index Kcal/ Nm 3") FROM table_64434 WHERE "Lower index MJ/ Nm 3" = '74.54' AND "Upper index Kcal/ Nm 3" < '19,376'
### Instruction: Order questions by links for selected user. ### Response:
SELECT pl.RelatedPostId AS "post_link", COUNT(pl.RelatedPostId) AS "number_of_links", p.Title, p.Score, p.ViewCount, p.AnswerCount FROM PostLinks AS pl JOIN Posts AS p ON p.Id = pl.PostId AND p.OwnerUserId = @user_id GROUP BY pl.RelatedPostId, p.ViewCount, p.Score, p.AnswerCount, p.Title ORDER BY 'number_of_links' DESC
### Instruction: tell me the minimum total hospital cost that involves methylprednisolone until 2 years ago? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'methylprednisolone') AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1
### Instruction: What is the last name of each student who is not allergic to any type of food? Count them with a bar chart, and could you rank from high to low by the total number please? ### Response:
SELECT LName, COUNT(LName) 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 LName ORDER BY COUNT(LName) DESC
### Instruction: when did patient 97314 get prescribed a drug via iv for the last time until 3 months ago? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97314) AND prescriptions.route = 'iv' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-3 month') ORDER BY prescriptions.startdate DESC LIMIT 1
### 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 job_id and employee_id , I want to list from high to low by the Y-axis. ### Response:
SELECT JOB_ID, 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: give me the number of patients whose diagnoses long title is chronic kidney disease, stage iv (severe) 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 = "Chronic kidney disease, Stage IV (severe)" AND prescriptions.drug_type = "MAIN"
### Instruction: what is the number of patients diagnosed with primary disease left internal jugular vein thrombosis;left arm edema and with procedure icd9 code 9229? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "LEFT INTERNAL JUGULAR VEIN THROMBOSIS;LEFT ARM EDEMA" AND procedures.icd9_code = "9229"
### Instruction: Which frequency has voltage of 1.6v and part number kp80524kx300256kc80524kx300256pmg30002002aa? ### Response:
SELECT frequency FROM table_name_64 WHERE voltage = "1.6v" AND part_number_s_ = "kp80524kx300256kc80524kx300256pmg30002002aa"
### Instruction: Rust questions per day averaged over weeks. ### Response:
SELECT MIN(Posts.CreationDate), COUNT(*) / 7.0 AS "posts per day" FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.Id = PostTags.PostId WHERE Tags.TagName = 'c++' GROUP BY TIME_TO_STR(Posts.CreationDate, '%W'), TIME_TO_STR(Posts.CreationDate, '%Y') ORDER BY MIN(Posts.CreationDate)
### Instruction: what are the number of outputs patient 8814 had until 1910 days ago? ### 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 = 8814)) AND DATETIME(outputevents.charttime) <= DATETIME(CURRENT_TIME(), '-1910 day')
### Instruction: give me the number of patients who were admitted via physician referral/normal delivery and had pneumonia; human immunodeficiency virus; rule out tuberculosis primary disease. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND demographic.diagnosis = "PNEUMONIA;HUMAN IMMUNODEFIENCY VIRUS;RULE OUT TUBERCULOSIS"
### Instruction: what is the since beginning of big 12 when last 10 meetings is ou, 7-3, neutral site is ou, 2-1, and last 5 meetings is bu, 3-2? ### Response:
SELECT "Since Beginning of Big 12" FROM table_50605 WHERE "Last 10 Meetings" = 'ou, 7-3' AND "at Neutral Site" = 'ou, 2-1' AND "Last 5 Meetings" = 'bu, 3-2'
### Instruction: how many hours have passed since patient 004-79017 stayed in their current hospital encounter in the ward 185 for the last time? ### Response:
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '004-79017' AND patient.wardid = 185 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
### Instruction: Is tag and tag-synonym table schema current in the Data Explorer?. http://meta.stackexchange.com/questions/184082/is-tag-and-tag-synonym-table-schema-current-in-the-data-explorer ### Response:
SELECT * FROM (SELECT Id, TagName, 'count', TagName AS tname FROM Tags UNION SELECT t.Id, TagName, 'count', SourceTagName FROM Tags AS t INNER JOIN TagSynonyms AS ts ON ts.TargetTagName = t.TagName) AS ctags ORDER BY 'count' DESC
### Instruction: during the last hospital encounter, when was the last time patient 8773 was prescribed pantoprazole? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 8773 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.drug = 'pantoprazole' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: what is the minimum hospital cost for a drug with a name called clarithromycin since 4 years ago? ### Response:
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT prescriptions.hadm_id FROM prescriptions WHERE prescriptions.drug = 'clarithromycin') AND DATETIME(cost.chargetime) >= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY cost.hadm_id) AS t1
### Instruction: What is the number of each allergie type that the student with first name Lisa has? Visualize by bar chart, and order x axis from high to low order. ### Response:
SELECT AllergyType, COUNT(AllergyType) FROM Allergy_Type AS T1 JOIN Has_Allergy AS T2 ON T1.Allergy = T2.Allergy JOIN Student AS T3 ON T3.StuID = T2.StuID WHERE T3.Fname = "Lisa" GROUP BY AllergyType ORDER BY AllergyType DESC
### Instruction: provide me the number of patients who have abnormal lab test status and diagnosed for the need for prophylactic vaccination and inoculation against viral hepatitis. ### 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 = "Need prphyl vc vrl hepat" AND lab.flag = "abnormal"
### Instruction: Is there a EECS class that does n't meet on Friday ? ### Response:
SELECT DISTINCT course.department, course.name, course.number 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_offering.friday = 'N' AND course.department = 'EECS' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: provide the number of patients whose diagnoses long title is myelodysplastic syndrome, unspecified and drug type is 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 = "Myelodysplastic syndrome, unspecified" AND prescriptions.drug_type = "BASE"
### Instruction: how many patients have had cpap/peep therapy - 5-10 cm h2o two or more times? ### Response:
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, COUNT(*) AS c1 FROM patient WHERE patient.patientunitstayid = (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'cpap/peep therapy - 5-10 cm h2o') GROUP BY patient.uniquepid) AS t1 WHERE t1.c1 >= 2
### Instruction: Return a bar chart to show how many documents for different budget type code, and I want to sort X-axis in ascending order. ### 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 T1.Budget_Type_Code
### Instruction: hi i want a round trip ticket to DALLAS ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service, city, fare, flight, flight_fare WHERE city.city_code = airport_service.city_code AND city.city_name = 'DALLAS' 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.airport_code
### Instruction: Top-N users for a tag. ### Response:
WITH t AS (SELECT SUM(Score) AS total, DisplayName AS name FROM Posts INNER JOIN PostTags ON Posts.ParentId = PostTags.PostId INNER JOIN Tags ON PostTags.TagId = Tags.Id INNER JOIN Users ON Posts.OwnerUserId = Users.Id WHERE Tags.TagName = @Tag AND Score != 0 GROUP BY Users.Id, DisplayName ORDER BY total DESC LIMIT 10) SELECT ROW_NUMBER() OVER (ORDER BY total DESC) AS rank, total, name FROM t
### Instruction: Among patients admitted to emergency, how many of them had atrial septal defect\mitral valve replacement and repair atrial-septal defect/sda as their primary disease? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "EMERGENCY ROOM ADMIT" AND demographic.diagnosis = "ATRIAL SEPTAL DEFECT\MITRAL VALVE REPLACEMENT;REPAIR ATRIAL-SEPTAL DEFECT/SDA"
### Instruction: how many patients were diagnosed with a fracture ischium-closed? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT diagnoses_icd.hadm_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 = 'fracture ischium-closed'))
### Instruction: subjects with obesity or hypertension considered in a dangerous range ( bmi > 45 , systolic bp > 170 , or diastolic bp > 110 ) . ### Response:
SELECT * FROM table_dev_51 WHERE obesity = 1 OR hypertension = 1 OR (body_mass_index_bmi > 45 OR systolic_blood_pressure_sbp > 170 OR diastolic_blood_pressure_dbp > 110)
### Instruction: What is the number of bulls that has oxen larger than 113.8, and a sheep and goats larger than 4533.4, and a cows smaller than 3987, and a total horses larger than 5056.5? ### Response:
SELECT bulls FROM table_name_58 WHERE oxen > 113.8 AND sheep_and_goats > 4533.4 AND cows < 3987 AND total_horses > 5056.5
### Instruction: On what date was the tournament played that eneded with a winning score of +6 (74-71-70-71=286) and margin of victory of 2 strokes, and with Arnold palmer as the runner-up? ### Response:
SELECT "Date" FROM table_40791 WHERE "Runner(s)-up" = 'arnold palmer' AND "Margin of victory" = '2 strokes' AND "Winning score" = '+6 (74-71-70-71=286)'
### Instruction: How many patients on a base drug type prescription have recurrent severe episode of major depressive affective disorder without mention of psychotic behavior diagnoses? ### 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 = "Rec depr psych-psychotic" AND prescriptions.drug_type = "BASE"
### Instruction: Can you tell me if any AAS classes meet on another day besides Friday ? ### Response:
SELECT DISTINCT course.department, course.name, course.number 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_offering.friday = 'N' AND course.department = 'AAS' AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: return me the number of citations of ' Making database systems usable ' before 2010 . ### Response:
SELECT COUNT(DISTINCT (PUBLICATION_1.title)) FROM cite, publication AS PUBLICATION_0, publication AS PUBLICATION_1 WHERE PUBLICATION_0.pid = cite.cited AND PUBLICATION_0.title = 'Making database systems usable' AND PUBLICATION_1.pid = cite.citing AND PUBLICATION_1.year < 2010
### Instruction: Highest Scoring Solo Question Askers With Reputation above 10K. ### Response:
SELECT * FROM Users AS u INNER JOIN (SELECT u.Id FROM Users AS u INNER JOIN (SELECT p.OwnerUserId FROM Posts AS p GROUP BY p.OwnerUserId HAVING COUNT(*) = 1) AS a ON a.OwnerUserId = u.Id WHERE Reputation > 10000) AS a ON a.Id = u.Id INNER JOIN Posts AS p ON p.OwnerUserId = u.Id AND p.PostTypeId = 1
### Instruction: what was the daily maximum value of weight for patient 017-88691 on their current hospital encounter? ### Response:
SELECT MAX(patient.admissionweight) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '017-88691' AND patient.hospitaldischargetime IS NULL) AND NOT patient.admissionweight IS NULL GROUP BY STRFTIME('%y-%m-%d', patient.unitadmittime)
### Instruction: Questions closed by user, sorted by reason. ### Response:
SELECT (CASE WHEN GROUPING(t.Id) = 1 THEN '(Total)' ELSE t.Name END) AS "Close Reason", COUNT(t.Id) AS "Count" FROM PostHistory AS h LEFT OUTER JOIN CloseReasonTypes AS t ON CAST(h.Comment AS INT) = t.Id WHERE h.PostHistoryTypeId = 10 AND ((h.Text LIKE @searchUserId2)) GROUP BY ROLLUP (t.Id, t.Name) ORDER BY t.Id
### Instruction: Guess NAA flags on SU by comments. ### Response:
SELECT 'http://superuser.com/questions/' + CAST(c.PostId AS TEXT) FROM Comments AS c INNER JOIN Posts AS p ON (p.Id = c.PostId) WHERE c.Text LIKE '%This does not provide an answer to the question.%' AND c.Score >= 0 AND p.Score <= 0 AND NOT EXISTS(SELECT * FROM PostHistory AS h WHERE PostHistoryTypeId IN (12, 13) AND h.PostId = c.PostId)
### Instruction: give me the number of patients on main type drug prescription who have cerebral embolism with cerebral infarction diagnoses. ### 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 = "Crbl emblsm w infrct" AND prescriptions.drug_type = "MAIN"
### Instruction: what is the total dose of ns that patient 63781 was prescribed until 03/2103? ### Response:
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 63781) AND prescriptions.drug = 'ns' AND STRFTIME('%y-%m', prescriptions.startdate) <= '2103-03'
### 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: give me the number of patients taking main drug type prescription who have diagnoses of other specified disorders resulting from impaired renal tubular function. ### 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 = "Impair ren funct dis NEC" AND prescriptions.drug_type = "MAIN"
### Instruction: What PSYCH classes don 't get together on Fridays ? ### Response:
SELECT DISTINCT course.department, course.name, course.number 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_offering.friday = 'N' AND course.department = 'PSYCH' AND semester.semester = 'WN' AND semester.year = 2016
### 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