instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### Instruction: What is the monounsaturated fat with a smoke point of c (), a total fat of 100g, 11g of polyunsaturated fat, and 14g of saturated fat? ### Response:
SELECT "Monounsaturated fat" FROM table_63511 WHERE "Smoke point" = '°c ()' AND "Total fat" = '100g' AND "Polyunsaturated fat" = '11g' AND "Saturated fat" = '14g'
### Instruction: what was the first operation time of patient 006-2586 during their current hospital encounter? ### Response:
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-2586' AND patient.hospitaldischargetime IS NULL)) ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: what was the minimum daily number of patients who had hypercalcemia since 2105? ### Response:
SELECT MIN(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'hypercalcemia' AND STRFTIME('%y', diagnosis.diagnosistime) >= '2105' GROUP BY STRFTIME('%y-%m-%d', diagnosis.diagnosistime)) AS t1
### Instruction: What's the lowest Votes (SW Eng) with a % (SW Eng) that's larger than 2.1, Votes (Gib) of 1,127, and a Change (SW Eng) that's larger than -3.6? ### Response:
SELECT MIN("Votes (SW Eng)") FROM table_35626 WHERE "% (SW Eng)" > '2.1' AND "Votes (Gib.)" = '1,127' AND "Change (SW Eng)" > '-3.6'
### Instruction: provide the number of patients whose diagnoses short title is convulsions nec 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.short_title = "Convulsions NEC" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: Number Users Per Accepted Answers. ### Response:
SELECT sub.NumAccepted, COUNT(*) AS UserCount FROM (SELECT SUM(CASE WHEN q.AcceptedAnswerId = a.Id THEN 1 ELSE 0 END) AS NumAccepted FROM Posts AS a INNER JOIN Users AS u ON u.Id = a.OwnerUserId INNER JOIN Posts AS q ON a.ParentId = q.Id WHERE (q.OwnerUserId != u.Id OR q.OwnerUserId IS NULL) GROUP BY u.Id) AS sub GROUP BY sub.NumAccepted
### Instruction: number of patients who had been diagnosed with diabetes mellitus - type i last year. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'diabetes mellitus - type i' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: What is the sum of # Of Candidates, when # of Constituency Votes is less than 25,643,309, when Leader is Masayoshi hira, and when Election is before 1979? ### Response:
SELECT SUM("# of candidates") FROM table_50553 WHERE "# of Constituency votes" < '25,643,309' AND "Leader" = 'masayoshi ōhira' AND "Election" < '1979'
### Instruction: for the anal fistulotomy what does it cost? ### Response:
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'procedures_icd' AND cost.event_id IN (SELECT procedures_icd.row_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'anal fistulotomy'))
### Instruction: Most downvoted posts without a single (non-owner) comment. ### Response:
SELECT Posts.Id AS "post_link", Posts.OwnerUserId AS "user_link", Posts.Score FROM Posts LEFT JOIN Comments ON Comments.PostId = Posts.Id AND Comments.UserId != Posts.OwnerUserId AND Comments.UserId > 1 WHERE Comments.Id IS NULL AND Posts.OwnerUserId > 1 AND Posts.Score < 0 ORDER BY Posts.Score, Posts.Id
### Instruction: provide the number of patients whose diagnoses short title is chrnc hpt c wo hpat coma and drug type is main? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Chrnc hpt C wo hpat coma" AND prescriptions.drug_type = "MAIN"
### Instruction: what is the four most frequently ordered procedure for a patient with an age 40s? ### Response:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 40 AND 49) GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 4
### Instruction: Amount of users who's last activity was during that month. ### Response:
SELECT Month = DATEADD(MONTH, DATEDIFF(MONTH, 0, Last_activity), 0), 'Lost members' = COUNT(activity.UserId) FROM (SELECT UserId, Last_activity = MAX(Date) FROM Badges INNER JOIN Users ON Badges.UserId = Users.Id GROUP BY UserId) AS activity GROUP BY DATEADD(MONTH, DATEDIFF(MONTH, 0, Last_activity), 0) ORDER BY Month
### Instruction: Get me the number of patients admitted before 2145 who have a primary disease of atrial septal defect mitral valve replacement repair atrial-septal defect/sda. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "ATRIAL SEPTAL DEFECT\MITRAL VALVE REPLACEMENT;REPAIR ATRIAL-SEPTAL DEFECT/SDA" AND demographic.admityear < "2145"
### Instruction: provide the number of patients whose diagnoses short title is subtrochanteric fx-close and drug route is left eye? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.short_title = "Subtrochanteric fx-close" AND prescriptions.route = "LEFT EYE"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a bar chart about the distribution of phone_number and department_id , I want to rank from high to low by the Y please. ### Response:
SELECT PHONE_NUMBER, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY DEPARTMENT_ID DESC
### Instruction: Show the number of accounts for all accounts by the customer with first name 'Meaghan' opened in each day Bin the account open day by weekday in a bar chart, sort by the y-axis from high to low please. ### Response:
SELECT date_account_opened, COUNT(date_account_opened) FROM Accounts AS T1 JOIN Customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.customer_first_name = 'Meaghan' ORDER BY COUNT(date_account_opened) DESC
### Instruction: how much do resp tract intubat nec costs? ### 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 = 'resp tract intubat nec'))
### Instruction: How many professors whose office is located in DRE 102 are hired in each month? Return a bar chart, list by the how many emp hiredate in asc. ### Response:
SELECT EMP_HIREDATE, COUNT(EMP_HIREDATE) FROM EMPLOYEE AS T1 JOIN PROFESSOR AS T2 ON T1.EMP_NUM = T2.EMP_NUM WHERE T2.PROF_OFFICE = 'DRE 102' ORDER BY COUNT(EMP_HIREDATE)
### Instruction: give me the number of patients whose admission year is less than 2115 and procedure long title is insertion of non-drug-eluting coronary artery stent(s)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2115" AND procedures.long_title = "Insertion of non-drug-eluting coronary artery stent(s)"
### Instruction: How many items are listed under 'andrew and georgies guest lee mack replaced andrew flint as team captain for one week' for episode 04x04? ### Response:
SELECT COUNT(andrew_and_georgies_guest_lee_mack_replaced_andrew_flintoff_as_team_captain_for_one_week_in_series_4), _episode_2 FROM table_29141354_4 WHERE episode = "04x04"
### Instruction: count the number of patients whose diagnoses long title is embolism and thrombosis of iliac artery and lab test abnormal status is delta? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Embolism and thrombosis of iliac artery" AND lab.flag = "delta"
### Instruction: when did patient 94956 last receive a microbiology test in 06/2105? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 94956) AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2105-06' ORDER BY microbiologyevents.charttime DESC LIMIT 1
### Instruction: what was the first id of patient 1457's ward the last year? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 1457) AND NOT transfers.wardid IS NULL AND DATETIME(transfers.intime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY transfers.intime LIMIT 1
### Instruction: Accepted answers with lower scores. ### Response:
SELECT Ans.Id AS "post_link", * FROM Posts AS Ans INNER JOIN (SELECT ParentId, MAX(Score) AS Score FROM Posts GROUP BY ParentId) AS Highest ON Ans.ParentId = Highest.ParentId INNER JOIN Posts AS Parent ON Ans.ParentId = Parent.ParentId WHERE Ans.Id = Parent.AcceptedAnswerId AND Ans.Score <= Highest.Score AND Parent.CreationDate > '2014-06-01' LIMIT 10
### Instruction: what were the three most frequent specimen tests carried out until 2 years ago? ### 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) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 3
### Instruction: Tag Popularity (UpVote) per month. ### Response:
SELECT TagName, COUNT(*) AS UpVotes, DATEDIFF(month, 0, CreationDate) AS "month" FROM Tags INNER JOIN PostTags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON Posts.ParentId = PostTags.PostId INNER JOIN Votes ON Votes.PostId = Posts.Id AND VoteTypeId = 2 GROUP BY TagName, DATEDIFF(month, 0, CreationDate) ORDER BY UpVotes DESC
### Instruction: what is the first specimen test given to patient 7375 in 04/2100? ### Response:
SELECT microbiologyevents.spec_type_desc FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7375) AND STRFTIME('%y-%m', microbiologyevents.charttime) = '2100-04' ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: what is the minimum age of patients whose admission location is transfer within this facility and diagnosed with primary disease atrial fibrillation\thoracoscopic maze procedure bilateral/sda? ### Response:
SELECT MIN(demographic.age) FROM demographic WHERE demographic.admission_location = "TRSF WITHIN THIS FACILITY" AND demographic.diagnosis = "ATRIAL FIBRILLATION\THORACOSCOPIC MAZE PROCEDURE BILATERAL/SDA"
### Instruction: in 2105 patient 19412 received a rbc test? ### Response:
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'rbc') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 19412) AND STRFTIME('%y', labevents.charttime) = '2105'
### Instruction: what is the three most frequently ordered lab test until 2101? ### 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 STRFTIME('%y', labevents.charttime) <= '2101' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 3)
### Instruction: what were the top three most common lab tests in 2103? ### 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 STRFTIME('%y', labevents.charttime) = '2103' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 3)
### Instruction: VtC review queue all-time tag distribution. ### Response:
WITH Raw AS (SELECT * FROM ReviewTasks WHERE ReviewTaskTypeId = 2 AND ReviewTaskStateId = 1) SELECT Tags.TagName, COUNT(*) AS Count, 100.0 * COUNT(*) / (SELECT COUNT(*) FROM Raw) AS Pct FROM Raw, Posts, Tags, PostTags WHERE Posts.Id = Raw.PostId AND Posts.Id = PostTags.PostId AND PostTags.TagId = Tags.Id GROUP BY Tags.TagName ORDER BY Pct DESC
### Instruction: tell me the number of patients diagnosed with subarachnoid hemorrhage who have iv bolus route of drug administration. ### 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 = "Subarachnoid hemorrhage" AND prescriptions.route = "IV BOLUS"
### Instruction: count the number of patients whose diagnoses long title is mechanical complication of colostomy and enterostomy 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 = "Mechanical complication of colostomy and enterostomy" AND lab.flag = "abnormal"
### Instruction: Celebrities from Ukraine (top 500 users ordered by profile views to rep points). ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY 'views_to_rep' DESC) AS "#", * FROM (SELECT u.Id AS "user_link", u.Views, u.Reputation, 1. * u.Views / u.Reputation AS "views_to_rep" FROM Users AS u WHERE u.Location LIKE '%Ukraine%') AS q ORDER BY 'views_to_rep' DESC LIMIT 500
### Instruction: give me the number of patients whose diagnoses short title is malfunc oth device/graft and lab test name is urea nitrogen? ### 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 = "Malfunc oth device/graft" AND lab.label = "Urea Nitrogen"
### Instruction: Closed non-duplicate questions answered by a user. ### Response:
SELECT q.Id AS "post_link", q.Score AS "question_score", a.Score AS "answer_score", q.AcceptedAnswerId AS "accepted_answer" FROM Posts AS q INNER JOIN Posts AS a ON a.ParentId = q.Id WHERE NOT q.ClosedDate IS NULL AND a.OwnerUserId = '##UserId##' AND q.Id NOT IN (SELECT PostId FROM PostLinks) ORDER BY q.ClosedDate DESC
### Instruction: has patient 004-86136 had a base excess test on their current hospital visit? ### 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 = '004-86136' AND patient.hospitaldischargetime IS NULL)) AND lab.labname = 'base excess'
### Instruction: how many patients the previous year had enteral vital high protein intake? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT intakeoutput.patientunitstayid FROM intakeoutput WHERE intakeoutput.celllabel = 'enteral vital high protein' AND intakeoutput.cellpath LIKE '%input%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: How many times must Prof. Herbert Winful have taught 499 ? ### Response:
SELECT COUNT(*) FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.number = 499 AND instructor.name LIKE '%Herbert Winful%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: what was the first time that patient 25733 was prescribed for a drug during this month? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 25733) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY prescriptions.startdate LIMIT 1
### Instruction: A bar chart for finding the number of the name of the project for which a scientist whose name contains Smith is assigned to, could you rank by the Y-axis from high to low? ### Response:
SELECT T2.Name, COUNT(T2.Name) FROM AssignedTo AS T1 JOIN Projects AS T2 ON T1.Project = T2.Code JOIN Scientists AS T3 ON T1.Scientist = T3.SSN WHERE T3.Name LIKE '%Smith%' GROUP BY T2.Name ORDER BY COUNT(T2.Name) DESC
### Instruction: what is the number of patients whose diagnoses short title is cor ath unsp vsl ntv/gft 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.short_title = "Cor ath unsp vsl ntv/gft" AND prescriptions.route = "SL"
### Instruction: what is the number of patients whose ethnicity is hispanic/latino - puerto rican and drug name is influenza virus vaccine? ### 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.drug = "Influenza Virus Vaccine"
### Instruction: which airline has more BUSINESS class flights than any other airline ### Response:
SELECT DISTINCT COUNT(*), flight.airline_code FROM fare, fare_basis, flight, flight_fare WHERE fare_basis.class_type = 'BUSINESS' AND fare.fare_basis_code = fare_basis.fare_basis_code AND flight_fare.fare_id = fare.fare_id AND flight.flight_id = flight_fare.flight_id GROUP BY flight.airline_code
### Instruction: what was the number of patients that were tested during the last year for bone marrow microbiology? ### 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 = 'bone marrow' AND DATETIME(microbiologyevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: Find questions by a user answered by a user. ### Response:
SELECT q.Id AS "Question Id", q.Id AS "post_link", q.OwnerUserId AS "user_link", a.Id AS "Answer Id", a.Id AS "post_link", a.OwnerUserId AS "user_link" FROM Posts AS q, Posts AS a WHERE q.OwnerUserId = '##QuestionOwnerId:int##' AND a.OwnerUserId = '##AnswerOwnerId:int##' AND a.ParentId = q.Id
### Instruction: What is the percentage of answers contributed by Stack Exchange employees. http://meta.stackexchange.com/questions/247449/for-each-stack-exchange-site-what-is-the-percentage-of-answers-contributed-by-s ### Response:
SELECT u.Id AS "user_link", COUNT(*) AS "posts_q_and_a_" FROM Posts AS p INNER JOIN Users AS u ON u.Id = p.OwnerUserId WHERE u.AccountId IN (1190) GROUP BY u.Id
### Instruction: Programming Languages - C++ - Per Month. ### Response:
SELECT COUNT(*) AS PostCount, YEAR(P.CreationDate), MONTH(P.CreationDate) FROM Posts AS P INNER JOIN PostTags AS PT ON (P.Id = PT.PostId) INNER JOIN Tags AS T ON (PT.TagId = T.Id) WHERE T.TagName LIKE ('%c++%') GROUP BY YEAR(P.CreationDate), MONTH(P.CreationDate) ORDER BY 2 DESC, 3 DESC
### Instruction: when was the first microbiology test of patient 13528, since 149 months ago? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13528) AND DATETIME(microbiologyevents.charttime) >= DATETIME(CURRENT_TIME(), '-149 month') ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: In regard to Demotic Egyptian , who has , is or will teach it ? ### 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 '%Demotic Egyptian%'
### Instruction: what was the yearly average value of the lactate of patient 2482? ### Response:
SELECT AVG(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 2482) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'lactate') GROUP BY STRFTIME('%y', labevents.charttime)
### Instruction: Do you know the teacher for EDUC 790 ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'EDUC' AND course.number = 790 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: count the number of times that divalproex (extended release) has been prescribed to patient 70267 since 2105. ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 70267) AND prescriptions.drug = 'divalproex (extended release)' AND STRFTIME('%y', prescriptions.startdate) >= '2105'
### Instruction: give me the number of patients whose diagnoses long title is secondary neuroendocrine tumor of bone 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 = "Secondary neuroendocrine tumor of bone" AND lab.flag = "abnormal"
### Instruction: how many patients whose year of death is less than or equal to 2112 and drug code is kcl40/1000d5ns? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2112.0" AND prescriptions.formulary_drug_cd = "KCL40/1000D5NS"
### Instruction: when patient 18841 the last year first received 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 = 18841) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY procedures_icd.charttime LIMIT 1
### Instruction: mean resting blood pressure between 130 _ 160 systolic and 85 _ 100 diastolic ### Response:
SELECT * FROM table_train_95 WHERE (systolic_blood_pressure_sbp >= 130 AND systolic_blood_pressure_sbp <= 160) AND (diastolic_blood_pressure_dbp >= 85 AND diastolic_blood_pressure_dbp <= 100)
### Instruction: what is the number of patients whose diagnoses long title is pure hyperglyceridemia and drug name is torsemide? ### 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 = "Pure hyperglyceridemia" AND prescriptions.drug = "Torsemide"
### Instruction: Show the number of start dates of all the apartment bookings made by guests with gender code 'Female' for each year in a bar chart, and rank the number of booking start date in desc order. ### Response:
SELECT booking_start_date, COUNT(booking_start_date) FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id = T2.guest_id WHERE T2.gender_code = "Female" ORDER BY COUNT(booking_start_date) DESC
### Instruction: when was the first time that patient 007-16517 was given a mcv lab test? ### 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 = '007-16517')) AND lab.labname = 'mcv' ORDER BY lab.labresulttime LIMIT 1
### 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 last_name and commission_pct , and show from high to low by the Y. ### Response:
SELECT LAST_NAME, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT DESC
### Instruction: how many patients whose drug code is olan5 and lab test fluid is cerebrospinal fluid (csf)? ### 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 = "OLAN5" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: what are the top four most common lab tests until 2100? ### 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 STRFTIME('%y', labevents.charttime) <= '2100' GROUP BY labevents.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: Before 2017 best most language posts.... ### Response:
SELECT YEAR(p.CreationDate), TagName, COUNT(1) FROM Posts AS p, PostTags AS pt, Tags AS t WHERE p.Id = pt.PostId AND pt.TagId = t.Id AND TagName IN ('r', 'c', 'c++', 'python', 'php', 'c#') AND YEAR(p.CreationDate) < 2017 GROUP BY YEAR(p.CreationDate), TagName ORDER BY 3 DESC
### Instruction: Find the number of the physicians who are trained in a procedure that costs more than 5000, order by the Y from high to low. ### 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 COUNT(T1.Name) DESC
### Instruction: count the number of patients who underwent a nasopharynx microbiology test during the previous year. ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'nasopharynx' AND DATETIME(microlab.culturetakentime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### 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 first_name and commission_pct , and list by the Y in ascending. ### 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 COMMISSION_PCT
### Instruction: how many days has passed since patient 006-76924 stayed for the first time in ward 384 on this hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '006-76924' AND patient.wardid = 384 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1
### Instruction: whats the last care unit of patient 97733 in this year? ### Response:
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 97733) AND NOT transfers.careunit IS NULL AND DATETIME(transfers.intime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY transfers.intime DESC LIMIT 1
### Instruction: Which % GDP has a Year smaller than 2011, and an Expenditure larger than 41.3, and an Income smaller than 48, and a Surplus(Deficit) of (24.6)? ### Response:
SELECT "% GDP" FROM table_41813 WHERE "Year" < '2011' AND "Expenditure" > '41.3' AND "Income" < '48' AND "Surplus(Deficit)" = '(24.6)'
### 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 manager_id , and display MANAGER_ID in descending order. ### Response:
SELECT LAST_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: provide the number of patients whose diagnosis long title is malignant neoplasm of other sites of tongue and lab test fluid is urine. ### 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 = "Malignant neoplasm of other sites of tongue" AND lab.fluid = "Urine"
### Instruction: Show a bar graph, the data is those times of trains that run through stations for the local authority Chiltern, and the Y axis is the total number of different times, could you list in descending by the Y-axis? ### Response:
SELECT time, COUNT(time) FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = "Chiltern" GROUP BY time ORDER BY COUNT(time) DESC
### Instruction: How many staffs have contacted with each engineer? Give me a bar chart grouping by each engineer's first name, list from high to low by the total number. ### Response:
SELECT first_name, COUNT(first_name) FROM Staff AS T1 JOIN Engineer_Visits AS T2 ON T1.staff_id = T2.contact_staff_id JOIN Maintenance_Engineers AS T3 ON T2.engineer_id = T3.engineer_id GROUP BY first_name ORDER BY COUNT(first_name) DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of job_id and commission_pct in a bar chart, and order in asc by the y axis. ### Response:
SELECT JOB_ID, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY COMMISSION_PCT
### Instruction: provide the number of patients whose diagnoses long title is body mass index less than 19, adult 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 = "Body Mass Index less than 19, adult" AND prescriptions.drug_type = "BASE"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find phone_number and commission_pct , and visualize them by a bar chart, sort bar from high to low order please. ### Response:
SELECT PHONE_NUMBER, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of first_name and department_id in a bar chart, and could you show by the names from high to low? ### 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 FIRST_NAME DESC
### Instruction: what 's the ground transportation from OAKLAND to SAN FRANCISCO ### Response:
SELECT DISTINCT ground_service.transport_type FROM city AS CITY_0, city AS CITY_1, ground_service WHERE CITY_0.city_name = 'OAKLAND' AND CITY_1.city_name = 'SAN FRANCISCO' AND ground_service.city_code = CITY_0.city_code AND ground_service.city_code = CITY_1.city_code
### Instruction: what is the number of inpatient hospital admission patients who had excision or destruction of other lesion or tissue of heart via endovascular approach? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND procedures.long_title = "Excision or destruction of other lesion or tissue of heart, endovascular approach"
### Instruction: what is the maximum total cost of the hospital, which includes the laboratory amylase test? ### Response:
SELECT MAX(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 lab.patientunitstayid FROM lab WHERE lab.labname = 'amylase')) GROUP BY cost.patienthealthsystemstayid) AS t1
### Instruction: A bar chart for showing the number of the names of editors that are on the committee of journals with sales bigger than 3000, could you sort by the Y from low to high? ### Response:
SELECT Name, COUNT(Name) FROM journal_committee AS T1 JOIN editor AS T2 ON T1.Editor_ID = T2.Editor_ID JOIN journal AS T3 ON T1.Journal_ID = T3.Journal_ID WHERE T3.Sales > 3000 GROUP BY Name ORDER BY COUNT(Name)
### Instruction: what was the difference in votes -lrb- percentage -rrb- between savire hoxhaj and astrit sejdinaj in the fratar municipality ? ### Response:
SELECT ABS((SELECT "coalition for the citizen" FROM table_204_226 WHERE "coalition for the citizen" = 'sabire hoxhaj') - (SELECT "coalition for the future" FROM table_204_226 WHERE "coalition for the future" = 'astrit sejdinaj'))
### Instruction: what is the average number of patients diagnosed with cardiac arrest daily in 2102? ### Response:
SELECT AVG(t1.c1) FROM (SELECT COUNT(DISTINCT diagnosis.patientunitstayid) AS c1 FROM diagnosis WHERE diagnosis.diagnosisname = 'cardiac arrest' AND STRFTIME('%y', diagnosis.diagnosistime) = '2102' GROUP BY STRFTIME('%y-%m-%d', diagnosis.diagnosistime)) AS t1
### Instruction: What are the description and credit of the course which the student whose last name is Smithson took? ### Response:
SELECT T4.crs_description, T4.crs_credit FROM class AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T3.stu_num = T2.stu_num JOIN course AS T4 ON T4.crs_code = T1.crs_code WHERE T3.stu_lname = 'Smithson'
### Instruction: get the number of asian patients who have prescription for dorzolamide 2%/timolol 0.5% ophthalmic solution. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "ASIAN" AND prescriptions.drug = "Dorzolamide 2%/Timolol 0.5% Ophth."
### Instruction: provide the number of patients whose diagnoses short title is late ef-hemplga side nos 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 = "Late ef-hemplga side NOS" AND lab."CATEGORY" = "Hematology"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find last_name and department_id , and visualize them by a bar chart, and rank by the y axis from high to low 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 DESC
### Instruction: i need your help with information on ground transportation from the airport in PHILADELPHIA to downtown ### Response:
SELECT DISTINCT ground_service.transport_type FROM airport, airport_service, city, ground_service WHERE airport.airport_code = airport_service.airport_code AND city.city_code = airport_service.city_code AND city.city_name = 'PHILADELPHIA' AND ground_service.airport_code = airport.airport_code
### Instruction: % of questions edited after close (graph based on Date Closed). ### Response:
SELECT LAST_DATE_OF_MONTH(ClosedDate) AS Closed, 1.0 * SUM(CASE WHEN LastEditDate > ClosedDate THEN 1 ELSE 0 END) / COUNT(*) AS "%edit_after_close" FROM Posts WHERE NOT ClosedDate IS NULL AND PostTypeId = 1 GROUP BY LAST_DATE_OF_MONTH(ClosedDate) ORDER BY LAST_DATE_OF_MONTH(ClosedDate)
### Instruction: Name the courses taught by Prof. Bradley Moore . ### 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 '%Bradley Moore%' AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: count the number of times patient 025-30850 had received endotracheal tube - insertion. ### Response:
SELECT COUNT(*) FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-30850')) AND treatment.treatmentname = 'endotracheal tube - insertion'
### Instruction: how many days has it been since the first stay of patient 005-4471 in the ward 285 in this hospital visit? ### Response:
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', patient.unitadmittime)) FROM patient WHERE patient.uniquepid = '005-4471' AND patient.wardid = 285 AND patient.hospitaldischargetime IS NULL ORDER BY patient.unitadmittime LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me the trend about manager_id over hire_date with a line chart, and show X from high to low order. ### Response:
SELECT HIRE_DATE, MANAGER_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: What is the lowest interview for a contestant from North Carolina with a swimsuit larger than 9.021, an average smaller than 9.513, and an evening gown larger than 9.5? ### Response:
SELECT MIN("Interview") FROM table_10368 WHERE "Swimsuit" > '9.021' AND "Average" < '9.513' AND "State" = 'north carolina' AND "Evening Gown" > '9.5'
### Instruction: what is the number of patients whose ethnicity is hispanic/latino - puerto rican and drug code is warf5? ### 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 = "WARF5"
### Instruction: find the top three most commonly prescribed drugs for patients 50s? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age BETWEEN 50 AND 59) GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 3
### Instruction: retrieve patient ids of patients who are diagnosed with cerebral subdural hematoma - secondary to trauma until 4 years ago. ### Response:
SELECT patient.uniquepid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'cerebral subdural hematoma - secondary to trauma' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-4 year'))