instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
What are the completion dates of all the tests that have result 'Fail', and count them by a bar chart, and display Y from high to low order.
### Response:
|
SELECT date_of_completion, COUNT(date_of_completion) FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Fail" ORDER BY COUNT(date_of_completion) DESC
|
### Instruction:
find the number of patients with admission location as clinic referral/premature who have drug code niac100.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND prescriptions.formulary_drug_cd = "NIAC100"
|
### Instruction:
count the number of patients whose primary disease is coronary artery disease\coronary artery bypass graft; myomectomy/sda and age is less than 67?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT; MYOMECTOMY/SDA" AND demographic.age < "67"
|
### 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 hire_date and the amount of hire_date bin hire_date by weekday.
### Response:
|
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
|
### Instruction:
What was the percentage in 1980 that had less than 37.8% in 2006, more than 29.4% in 2000, and more than 18.2% in 1970?
### Response:
|
SELECT MIN(1980) FROM table_name_30 WHERE 2006 < 37.8 AND 2000 > 29.4 AND 1970 > 18.2
|
### Instruction:
Show the dates of performances with attending members whose roles are 'Violin', and count them by a bar chart, and display from low to high by the Y.
### Response:
|
SELECT Date, COUNT(Date) FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID WHERE T2.Role = "Violin" GROUP BY Date ORDER BY COUNT(Date)
|
### Instruction:
Will there be any PATH 581 classes 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 = 'PATH' AND course.number = 581 AND semester.semester = 'WN' AND semester.year = 2016
|
### Instruction:
Which customers made orders between 2009-01-01 and 2010-01-01? Find their names.
### Response:
|
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.date_order_placed >= "2009-01-01" AND T2.date_order_placed <= "2010-01-01"
|
### Instruction:
how many patients who had percu gastrojejunostomy were discharged to wdisc-tran cancer/chldrn h
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DISC-TRAN CANCER/CHLDRN H" AND procedures.short_title = "Percu gastrojejunostomy"
|
### Instruction:
Find the names of the customers who have order status both 'On Road' and 'Shipped'.
### Response:
|
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "On Road" INTERSECT SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 ON T1.customer_id = T2.customer_id WHERE T2.order_status = "Shipped"
|
### 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 hire_date and the sum of department_id bin hire_date by time.
### Response:
|
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
|
### Instruction:
give me the number of patients whose diagnoses short title is encephalopathy nos 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.short_title = "Encephalopathy NOS" AND lab.flag = "abnormal"
|
### Instruction:
when patient 025-24306 was admitted to the hospital via the emergency department for the first time until 2104?
### Response:
|
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '025-24306' AND patient.hospitaladmitsource = 'emergency department' AND STRFTIME('%y', patient.hospitaladmittime) <= '2104' ORDER BY patient.hospitaladmittime LIMIT 1
|
### Instruction:
how many patients whose diagnoses long title is observation for suspected infectious condition 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 = "Observation for suspected infectious condition" AND lab.flag = "abnormal"
|
### Instruction:
Count the number of patients categorized under a hematology lab test who had unilateral radical neck dissection.
### 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 = "Radical neck dissection, unilateral" AND lab."CATEGORY" = "Hematology"
|
### Instruction:
how many patients whose drug code is atro1i and lab test category is hematology?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE prescriptions.formulary_drug_cd = "ATRO1I" AND lab."CATEGORY" = "Hematology"
|
### Instruction:
calculate the number of patients that had a wound, decubitus microbiology test since 2101.
### Response:
|
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'wound, decubitus' AND STRFTIME('%y', microlab.culturetakentime) >= '2101')
|
### Instruction:
provide the number of patients whose diagnoses icd9 code is 99799 and drug route is ng?
### 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.icd9_code = "99799" AND prescriptions.route = "NG"
|
### Instruction:
For all employees who have the letters D or S in their first name, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id by a bar chart, and sort from low to high by the y axis please.
### Response:
|
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID)
|
### Instruction:
For those employees who was hired before 2002-06-21, find hire_date and the sum of department_id bin hire_date by weekday, and visualize them by a bar chart, could you order from high to low by the y axis please?
### Response:
|
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY SUM(DEPARTMENT_ID) DESC
|
### Instruction:
Which courses in U S satisfy the PreMajor requirement for my schedule ?
### 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 '%U S%' OR course.description LIKE '%U S%' OR course.name LIKE '%U S%') AND program_course.category LIKE '%PreMajor%'
|
### Instruction:
what is the number of patients on pb route of drug administration who are diagnosed with hypothyroidism nos?
### 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 = "Hypothyroidism NOS" AND prescriptions.route = "PB"
|
### Instruction:
how many patients prescribed with base drug type have been diagnosed with von willebrand's disease?
### 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 = "Von Willebrand's disease" AND prescriptions.drug_type = "BASE"
|
### Instruction:
how many patients are diagnosed with perforation of intestine and with procedure packed cell transfusion?
### 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.long_title = "Perforation of intestine" AND procedures.short_title = "Packed cell transfusion"
|
### Instruction:
Votes on Your Posts Aggregations.
### Response:
|
SELECT pt.Name, vt.Name, COUNT(*) FROM Users AS u JOIN Posts AS p ON p.OwnerUserId = u.Id JOIN PostTypes AS pt ON pt.Id = p.PostTypeId JOIN Votes AS v ON v.PostId = p.Id JOIN VoteTypes AS vt ON vt.Id = v.VoteTypeId WHERE u.Id = '##UserID##' GROUP BY vt.Name, pt.Name
|
### Instruction:
tell me the total dose of d5w (excel bag) that patient 97330 was prescribed in this 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 = 97330 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'd5w (excel bag)'
|
### Instruction:
what is patient 46330's last careunit until 2 years ago?
### Response:
|
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 46330) AND NOT transfers.careunit IS NULL AND DATETIME(transfers.intime) <= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY transfers.intime 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, show me about the correlation between salary and department_id in a scatter chart.
### Response:
|
SELECT SALARY, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
|
### Instruction:
provide the number of patients whose days of hospital stay is greater than 9 and procedure long title is initial insertion of transvenous lead [electrode] into ventricle?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "9" AND procedures.long_title = "Initial insertion of transvenous lead [electrode] into ventricle"
|
### Instruction:
how many patients whose diagnoses long title is von willebrand's disease 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 = "Von Willebrand's disease" AND prescriptions.drug_type = "BASE"
|
### Instruction:
Show birthdates of the professors in charge of ACCT-211 and bin the date by year interval in a line chart, and I want to list by the x axis in descending.
### Response:
|
SELECT EMP_DOB, COUNT(EMP_DOB) FROM EMPLOYEE AS T1 JOIN CLASS AS T2 ON T1.EMP_NUM = T2.PROF_NUM WHERE CRS_CODE = "ACCT-211" ORDER BY EMP_DOB DESC
|
### Instruction:
calculate the number of patients who received a microbiology sputum, expectorated test in 2104.
### Response:
|
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'sputum, expectorated' AND STRFTIME('%y', microlab.culturetakentime) = '2104')
|
### Instruction:
what is the township when the land (sqmi) is more than 36.112, the geo id is higher than 3801985060 and the latitude is 46.062384?
### Response:
|
SELECT township FROM table_name_20 WHERE land___sqmi__ > 36.112 AND geo_id > 3801985060 AND latitude = 46.062384
|
### Instruction:
What is the highest Total Foreign-born (1000) from a non EU state (1000) of 685 and a population (1000) smaller than 10,666?
### Response:
|
SELECT MAX("Total Foreign-born (1000)") FROM table_14532 WHERE "Born in a non EU state (1000)" = '685' AND "Total population (1000)" > '10,666'
|
### Instruction:
For those employees who was hired before 2002-06-21, visualize a bar chart about the distribution of job_id and the average of department_id , and group by attribute job_id, and display in desc by the Y.
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID) DESC
|
### Instruction:
since 2103, when did patient 27656 receive a procedure for the first time?
### Response:
|
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27656) AND STRFTIME('%y', procedures_icd.charttime) >= '2103' ORDER BY procedures_icd.charttime LIMIT 1
|
### Instruction:
What are the number of the names of the technicians that are assigned to repair machines with more point values than 70?, sort by the x-axis from low to high.
### Response:
|
SELECT Name, COUNT(Name) FROM repair_assignment AS T1 JOIN machine AS T2 ON T1.Machine_ID = T2.Machine_ID JOIN technician AS T3 ON T1.technician_id = T3.technician_id WHERE T2.value_points > 70 GROUP BY Name ORDER BY Name
|
### Instruction:
For those employees who did not have any job in the past, visualize a bar chart about the distribution of hire_date and the sum of employee_id bin hire_date by weekday, list total number of employee id from high to low order.
### Response:
|
SELECT HIRE_DATE, SUM(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(EMPLOYEE_ID) DESC
|
### Instruction:
when was the last time in 2102 that patient 20332 had a 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 = 20332) AND STRFTIME('%y', procedures_icd.charttime) = '2102' ORDER BY procedures_icd.charttime DESC LIMIT 1
|
### Instruction:
What is the number of patients who were diagnosed with alcohol abuse-continuous and their lab test fluid is ascites?
### 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 = "Alcohol abuse-continuous" AND lab.fluid = "Ascites"
|
### Instruction:
how many patients follow episcopalian religion and were diagnosed with personal history of malignant neoplasm of large intestine?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.religion = "EPISCOPALIAN" AND diagnoses.long_title = "Personal history of malignant neoplasm of large intestine"
|
### Instruction:
count the number of patients whose diagnoses short title is subendo infarct, initial 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 = "Subendo infarct, initial" AND prescriptions.drug_type = "MAIN"
|
### Instruction:
What is the average share at 8:00 p.m., and an 18-49 of 1.3/4 with an air date of April 4, 2008?
### Response:
|
SELECT AVG("Share") FROM table_40541 WHERE "Timeslot" = '8:00 p.m.' AND "18-49" = '1.3/4' AND "Air Date" = 'april 4, 2008'
|
### Instruction:
give me the number of patients whose admission location is emergency room admit and primary disease is coronary artery disease\coronary artery bypass graft /sda?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "EMERGENCY ROOM ADMIT" AND demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT /SDA"
|
### Instruction:
Next semester , how many ORALSURG classes will be offered ?
### Response:
|
SELECT COUNT(DISTINCT course_offering.course_id) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ORALSURG' AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
what is the five most common specimen test done in 2104?
### Response:
|
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE STRFTIME('%y', microlab.culturetakentime) = '2104' GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
give me the number of patients whose admission location is clinic referral/premature and primary disease is st elevated myocardial infarction\cardiac cath?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "ST ELEVATED MYOCARDIAL INFARCTION\CARDIAC CATH"
|
### Instruction:
All My Answers Sorted by Votes.
### Response:
|
SELECT COUNT(*) AS UpVotes, p2.Title FROM Posts AS p INNER JOIN Votes AS v ON v.PostId = p.Id INNER JOIN Posts AS p2 ON p2.Id = p.ParentId AND p2.PostTypeId = 1 WHERE p.OwnerUserId = @UserId AND p.PostTypeId = 2 AND v.VoteTypeId = 2 GROUP BY p2.Title ORDER BY UpVotes DESC
|
### Instruction:
how is the most cited author in ACL ?
### Response:
|
SELECT DISTINCT COUNT(DISTINCT cite.citingpaperid), writes.authorid FROM cite, paper, venue, writes WHERE venue.venueid = paper.venueid AND venue.venuename = 'ACL' AND writes.paperid = cite.citedpaperid AND writes.paperid = paper.paperid GROUP BY writes.authorid ORDER BY COUNT(DISTINCT cite.citingpaperid) DESC
|
### Instruction:
what are the five most common specimen test performed until 2103?
### Response:
|
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE STRFTIME('%y', microlab.culturetakentime) <= '2103' GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
since 2101 what were the top five most common specimen tests?
### Response:
|
SELECT t1.culturesite FROM (SELECT microlab.culturesite, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microlab WHERE STRFTIME('%y', microlab.culturetakentime) >= '2101' GROUP BY microlab.culturesite) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
What tyre is on the talbot-lago and an Entrant of automobiles talbot-darracq sa, and a Chassis of talbot-lago t26c-da?
### Response:
|
SELECT "Tyre" FROM table_56199 WHERE "Constructor" = 'talbot-lago' AND "Entrant" = 'automobiles talbot-darracq sa' AND "Chassis" = 'talbot-lago t26c-da'
|
### Instruction:
what is the number of clinic referral/premature admission patients who have myco500t drug code?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND prescriptions.formulary_drug_cd = "MYCO500T"
|
### Instruction:
count the number of patients whose procedure icd9 code is 8968 and drug type is additive?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "8968" AND prescriptions.drug_type = "ADDITIVE"
|
### Instruction:
how many times is this other skeletal traction procedure done in 2105?
### 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 = 'other skeletal traction') AND STRFTIME('%y', procedures_icd.charttime) = '2105'
|
### Instruction:
what's the maximum total cost of a hospital that includes a laboratory ntprobnp test?
### Response:
|
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'ntprobnp')) GROUP BY cost.hadm_id) AS t1
|
### Instruction:
please list all flights on UA out of DENVER before 1200
### Response:
|
SELECT DISTINCT flight.flight_id FROM airport_service, city, flight WHERE (city.city_code = airport_service.city_code AND city.city_name = 'DENVER' AND flight.departure_time < 1200 AND flight.from_airport = airport_service.airport_code) AND flight.airline_code = 'UA'
|
### Instruction:
What is the number of american indian/alaska native ethnic background patients who have a benz1i drug code?
### 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.formulary_drug_cd = "BENZ1I"
|
### Instruction:
For all employees who have the letters D or S in their first name, visualize a bar chart about the distribution of job_id and the average of department_id , and group by attribute job_id, and list by the y-axis from high to low.
### Response:
|
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID) DESC
|
### Instruction:
provide the number of patients whose procedure icd9 code is 4523 and drug type is additive?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "4523" AND prescriptions.drug_type = "ADDITIVE"
|
### Instruction:
how many patients who had emergency admission have been prescribed the drug 0.9% sodium chloride (mini bag plus)?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND prescriptions.drug = "0.9% Sodium Chloride (Mini Bag Plus)"
|
### Instruction:
Who is the Glendale principal with Greg Smorel as m.s. principal and Joleen Reinholz as H.S. principal during 2006-2007?
### Response:
|
SELECT "Glendale Principal" FROM table_66896 WHERE "M.S. Principal" = 'greg smorel' AND "H.S. Principal" = 'joleen reinholz' AND "Year" = '2006-2007'
|
### Instruction:
how many times since 6 years ago has patient 035-9846 been to icu?
### Response:
|
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '035-9846') AND DATETIME(patient.unitadmittime) >= DATETIME(CURRENT_TIME(), '-6 year')
|
### Instruction:
count the number of patients whose procedure icd9 code is 3799 and drug type is additive?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "3799" AND prescriptions.drug_type = "ADDITIVE"
|
### Instruction:
what are the five most common events since 2103?
### Response:
|
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y', intakeoutput.intakeoutputtime) >= '2103' GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 5
|
### Instruction:
was the cyanocobalamin prescribed to patient 83062 in 2105?
### Response:
|
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 83062) AND prescriptions.drug = 'cyanocobalamin' AND STRFTIME('%y', prescriptions.startdate) = '2105'
|
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of hire_date and the sum of manager_id bin hire_date by time.
### Response:
|
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
|
### 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, what is the relationship between employee_id and department_id ?
### Response:
|
SELECT EMPLOYEE_ID, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
|
### Instruction:
how many patients have blood gas lab test category along with diagnoses icd9 code 99591?
### 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 = "99591" AND lab."CATEGORY" = "Blood Gas"
|
### Instruction:
count the number of patients on main type drug prescription who have diagnoses icd9 code 496.
### 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.icd9_code = "496" AND prescriptions.drug_type = "MAIN"
|
### Instruction:
how many patients whose diagnoses short title is disrup-external op wound 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 = "Disrup-external op wound" AND lab."CATEGORY" = "Hematology"
|
### Instruction:
pejorative tagged by day of week.
### Response:
|
SELECT TIME_TO_STR(CreationDate, '%W'), COUNT(P.Id) FROM Posts AS P JOIN PostTags AS PT ON P.Id = PT.PostId JOIN Tags AS T ON PT.TagId = T.Id WHERE T.TagName = 'pejorative-language' GROUP BY TIME_TO_STR(CreationDate, '%W') ORDER BY TIME_TO_STR(CreationDate, '%W')
|
### Instruction:
count the number of patients whose procedure icd9 code is 8960 and drug type is additive?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "8960" AND prescriptions.drug_type = "ADDITIVE"
|
### Instruction:
When earnings ($) is more than 583,796 after 1998 with 1 LPGA wins and greater than 10 Money list rank, what is the smallest average?
### Response:
|
SELECT MIN("Average") FROM table_66181 WHERE "Year" > '1998' AND "Earnings ($)" > '583,796' AND "LPGA wins" = '1' AND "Money list rank" > '10'
|
### Instruction:
Other income sources of 2%, and a State pensions of 7%, and a Working tax credit of 2%, and a Employment ( salaries & wages) of 66% has what occupational pensions?
### Response:
|
SELECT occupational_pensions FROM table_name_34 WHERE other_income_sources = "2%" AND state_pensions = "7%" AND working_tax_credit = "2%" AND employment___salaries_ & _wages_ = "66%"
|
### Instruction:
Which Annual ridership (2008) has a Number of stations larger than 70, and an Annual ridership (1998) smaller than 451,971,849?
### Response:
|
SELECT MIN("Annual ridership (2008)") FROM table_50723 WHERE "Number of stations" > '70' AND "Annual ridership (1998)" < '451,971,849'
|
### Instruction:
count the number of patients whose ethnicity is white and diagnoses long title is mechanical complication due to other implant and internal device, not elsewhere classified?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "WHITE" AND diagnoses.long_title = "Mechanical complication due to other implant and internal device, not elsewhere classified"
|
### Instruction:
Which Number of electorates (2009) has a District of jhajjar, and a Reserved for (SC/ST/None) of sc, and a Constituency number smaller than 66?
### Response:
|
SELECT COUNT("Number of electorates (2009)") FROM table_12299 WHERE "District" = 'jhajjar' AND "Reserved for ( SC / ST /None)" = 'sc' AND "Constituency number" < '66'
|
### Instruction:
What is the country of origin of the artist who is female and produced a song in Bangla, and count them by a bar chart, rank by the y-axis from low to high.
### Response:
|
SELECT T1.country, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = "Female" AND T2.languages = "bangla" GROUP BY T1.country ORDER BY T1.country
|
### Instruction:
provide the number of patients whose admission location is phys referral/normal deli and drug code is baci15o?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND prescriptions.formulary_drug_cd = "BACI15O"
|
### Instruction:
What's the total number of years with a Rank that smaller than 7, Studio of Red Chillies Entertainment, and Opening Weekend Net Gross of 52,93,00,000?
### Response:
|
SELECT COUNT("Year") FROM table_11618 WHERE "Rank" < '7' AND "Studio(s)" = 'red chillies entertainment' AND "Opening Weekend Net Gross" = '52,93,00,000'
|
### Instruction:
how many adrenal exploration nos treatments have been performed until 2102?
### 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 = 'adrenal exploration nos') AND STRFTIME('%y', procedures_icd.charttime) <= '2102'
|
### Instruction:
For those employees who did not have any job in the past, show me about the distribution of hire_date and the average of employee_id bin hire_date by weekday in a bar chart, and list in descending by the Y.
### Response:
|
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(EMPLOYEE_ID) DESC
|
### Instruction:
For those employees who do not work in departments with managers that have ids between 100 and 200, draw a bar chart about the distribution of email and manager_id , show by the y axis in desc.
### Response:
|
SELECT EMAIL, 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:
what is patient 016-34108's last ward id until 2104?
### Response:
|
SELECT patient.wardid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '016-34108') AND STRFTIME('%y', patient.unitadmittime) <= '2104' ORDER BY patient.unitadmittime DESC LIMIT 1
|
### Instruction:
provide the number of patients whose primary disease is st elevated myocardial infarction\cardiac cath and lab test fluid is joint fluid?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "ST ELEVATED MYOCARDIAL INFARCTION\CARDIAC CATH" AND lab.fluid = "Joint Fluid"
|
### Instruction:
what is the number of patients taking drug via dwell route who have unspecified opioid dependence 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 = "Opioid dependence-unspec" AND prescriptions.route = "DWELL"
|
### Instruction:
Find popular stackoverflow question with java tag with code segment.
### Response:
|
SELECT p1.Id FROM Posts AS p1 JOIN Posts AS p2 ON p1.Id = p2.ParentId WHERE p1.PostTypeId = 1 AND p1.Score > 10 AND p1.Body LIKE '%<code>%' AND p1.Tags LIKE '%<java>%' AND p2.PostTypeId = 2 AND p2.Score > 10 AND p2.Body LIKE '%<code>%'
|
### Instruction:
give me the number of patients whose procedure icd9 code is 3972 and drug route is inhalation?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "3972" AND prescriptions.route = "INHALATION"
|
### Instruction:
How many events have each participants attended? Show their average number by each participant type code using a bar chart, I want to order from high to low by the Y.
### Response:
|
SELECT T1.Participant_Type_Code, AVG(COUNT(*)) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_Type_Code ORDER BY AVG(COUNT(*)) DESC
|
### Instruction:
the last ward id of patient 56009 until 1 year ago is?
### Response:
|
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 56009) AND NOT transfers.wardid IS NULL AND DATETIME(transfers.intime) <= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY transfers.intime DESC LIMIT 1
|
### Instruction:
What source has a race winner of ben adriaenssen / ben van den bogaart, and the gp winner of ben adriaenssen / ben van den bogaart, for the date of 1 april?
### Response:
|
SELECT "Source" FROM table_49573 WHERE "Race winners" = 'ben adriaenssen / ben van den bogaart' AND "GP winner" = 'ben adriaenssen / ben van den bogaart' AND "Date" = '1 april'
|
### Instruction:
provide the number of patients whose diagnoses icd9 code is 2538 and drug route is neb?
### 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.icd9_code = "2538" AND prescriptions.route = "NEB"
|
### Instruction:
For all employees who have the letters D or S in their first name, find job_id and the average of manager_id , and group by attribute job_id, and visualize them by a bar chart, I want to list in desc by the y axis.
### Response:
|
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID) DESC
|
### Instruction:
Tell me the number of patients with diagnoses icd9 code v1083 who had an other body fluid lab test.
### 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 = "V1083" AND lab.fluid = "Other Body Fluid"
|
### Instruction:
when was the first time of hospital admission in which patient 17462 was admitted through the transfer from hosp/extram since 2105?
### Response:
|
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 17462 AND admissions.admission_location = 'transfer from hosp/extram' AND STRFTIME('%y', admissions.admittime) >= '2105' ORDER BY admissions.admittime LIMIT 1
|
### Instruction:
What is the country of origin of the artist who is female and produced a song in Bangla, and count them by a bar chart, I want to display by the bars in asc please.
### Response:
|
SELECT T1.country, T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T1.gender = "Female" AND T2.languages = "bangla" GROUP BY T1.country ORDER BY T1.country
|
### Instruction:
what are the three most commonly ordered procedures in patients aged 60 or above?
### 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 >= 60) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
During next semester , how many NEAREAST classes are being offered ?
### Response:
|
SELECT COUNT(DISTINCT course_offering.course_id) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'NEAREAST' AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
For those employees who did not have any job in the past, visualize a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by weekday, and list in descending by the Y.
### Response:
|
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(EMPLOYEE_ID) DESC
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.