instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### 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 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: 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: 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: 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: 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'))
### Instruction: what is the part number(s) when l2 cache is 512 kb, release date is june 2001 and sSpec number is sl5lv, sl5pu, sl6bw, sl6jm? ### Response:
SELECT part_number_s_ FROM table_name_71 WHERE l2_cache = "512 kb" AND release_date = "june 2001" AND sspec_number = "sl5lv, sl5pu, sl6bw, sl6jm"
### 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 phone_number and employee_id in a bar chart, I want to show names in desc order. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER DESC
### Instruction: What are the first names of all Accounting professors who teach and what are the classrooms of the courses they teach? ### Response:
SELECT T2.emp_fname, T1.class_room FROM class AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN professor AS T3 ON T2.emp_num = T3.emp_num JOIN department AS T4 ON T4.dept_code = T3.dept_code WHERE T4.dept_name = 'Accounting'
### Instruction: what is the number of patients whose admission type is elective and procedure long title is removal of t-tube, other bile duct tube, or liver tube? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND procedures.long_title = "Removal of T-tube, other bile duct tube, or liver tube"
### Instruction: what are the three most common specimen tests performed until 4 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(), '-4 year') GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 3
### Instruction: How many Map Key has an Area km larger than 14,003 and a Capital City of al mukalla, and a Pop (2004) larger than 1,028,556? ### Response:
SELECT SUM("Map Key") FROM table_76269 WHERE "Area km\u00b2" > '14,003' AND "Capital City" = 'al mukalla' AND "Pop (2004)" > '1,028,556'
### Instruction: what is the average cost of the hospital involving lamotrigine until 2 years ago? ### Response:
SELECT AVG(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 = 'lamotrigine') AND DATETIME(cost.chargetime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY cost.hadm_id) AS t1
### Instruction: the list of the patient ids of patients diagnosed with pleural effusion - transudate by lab analysis last year. ### Response:
SELECT patient.uniquepid FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'pleural effusion - transudate by lab analysis' AND DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
### Instruction: Almost dead zombie finder on C++ tag. ### Response:
SELECT q.Id AS "post_link", MAX(a.Score) AS "best_answer_score" FROM Posts AS q JOIN Posts AS a ON a.ParentId = q.Id WHERE q.PostTypeId = 1 AND q.AnswerCount > 0 AND q.AcceptedAnswerId IS NULL AND a.PostTypeId = 2 AND q.Tags LIKE 'c++' GROUP BY q.Id HAVING MAX(a.Score) = 0
### Instruction: What is the total number of white (Hispanic/Non-Hispanic) having a black (Hispanic/Non-Hispanic) of 9.9 and Hispanic under 99.5? ### Response:
SELECT COUNT(white__both_hispanic_and_non_hispanic_) FROM table_name_77 WHERE black__both_hispanic_and_non_hispanic_ = 9.9 AND hispanic__of_any_race_ < 99.5
### Instruction: what was the name of the drug that on this hospital visit patient 021-95970 was allergic to? ### Response:
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-95970' AND patient.hospitaldischargetime IS NULL))
### Instruction: What are the names of the customers who bought product 'food' at least once? ### Response:
SELECT T1.customer_name FROM customers AS T1 JOIN orders AS T2 JOIN order_items AS T3 JOIN products AS T4 ON T1.customer_id = T2.customer_id AND T2.order_id = T3.order_id AND T3.product_id = T4.product_id WHERE T4.product_name = "food" GROUP BY T1.customer_id HAVING COUNT(*) >= 1
### Instruction: what is the first care unit of patient 73713 during this year? ### Response:
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713) 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 LIMIT 1
### Instruction: What is the highest w plyf with a first yr before 1960, a G plyf greater than 0, a G > .500 less than 43, and a w-l% less than 0.578? ### Response:
SELECT MAX(w_plyf) FROM table_name_99 WHERE first_yr < 1960 AND g_plyf > 0 AND g_ > _500 < 43 AND w_l_percentage < 0.578
### Instruction: provide me with the top three most common intake since 2 years ago? ### Response:
SELECT t1.celllabel FROM (SELECT intakeoutput.celllabel, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM intakeoutput WHERE intakeoutput.cellpath LIKE '%intake%' AND DATETIME(intakeoutput.intakeoutputtime) >= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY intakeoutput.celllabel) AS t1 WHERE t1.c1 <= 3
### Instruction: whats the first height of patient 007-8317 during their first hospital encounter? ### Response:
SELECT patient.admissionheight FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-8317' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1) AND NOT patient.admissionheight IS NULL ORDER BY patient.unitadmittime LIMIT 1
### Instruction: how many patients whose diagnoses long title is malignant neoplasm of other sites of tongue and drug route is nu? ### 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 = "Malignant neoplasm of other sites of tongue" AND prescriptions.route = "NU"
### Instruction: hemoglobin < 11 grams ( g ) / dl ( < 110 g / l ) for male subjects and < 10 g / dl ( < 100 g / l ) for female subjects at screening ### Response:
SELECT * FROM table_train_252 WHERE (hemoglobin_a1c_hba1c < 11 AND gender = 'male') OR (hemoglobin_a1c_hba1c < 10 AND gender = 'female')
### Instruction: whats the unabbreviated version of tb lung cavity-exam unkn. ### Response:
SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'tb lung cavity-exam unkn' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'tb lung cavity-exam unkn'
### Instruction: what is the number of patients whose primary disease is brain mass;intracranial hemorrhage and lab test fluid is cerebrospinal fluid (csf)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "BRAIN MASS;INTRACRANIAL HEMORRHAGE" AND lab.fluid = "Cerebrospinal Fluid (CSF)"
### Instruction: what specimen tests were given to patient 031-4987 for the first time? ### Response:
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4987')) ORDER BY microlab.culturetakentime LIMIT 1
### Instruction: when was patient 10266 prescribed a medication via pr route the first time during their first hospital visit? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 10266 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND prescriptions.route = 'pr' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Find the enrollment date for all the tests that have 'Pass' result, and count them by a bar chart, and I want to display in asc by the Y. ### Response:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Student_Course_Enrolment AS T1 JOIN Student_Tests_Taken AS T2 ON T1.registration_id = T2.registration_id WHERE T2.test_result = "Pass" ORDER BY COUNT(date_of_enrolment)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find first_name and employee_id , and visualize them by a bar chart, order from low to high by the bars. ### Response:
SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY FIRST_NAME
### Instruction: What is the yield, neutrons per fission of the group with decay constants less than 0.301, a half-life of 22.72, and a group number larger than 2? ### Response:
SELECT SUM("Yield, Neutrons per Fission") FROM table_71216 WHERE "Decay Constant (s \u22121 )" < '0.301' AND "Half-Life (s)" = '22.72' AND "Group" > '2'
### Instruction: what is average age of patients whose primary disease is coronary artery disease\coronary artery bypass graft with mvr; ? maze and admission year is greater than or equal to 2115? ### Response:
SELECT AVG(demographic.age) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" AND demographic.admityear >= "2115"
### 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 phone_number and employee_id , and list in ascending by the x-axis. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY PHONE_NUMBER
### 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 phone_number and employee_id , and show y axis in desc order. ### Response:
SELECT PHONE_NUMBER, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID DESC
### Instruction: what is the number of patients that received a promyelocytes test since 2105? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT labevents.hadm_id FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'promyelocytes') AND STRFTIME('%y', labevents.charttime) >= '2105')
### 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 first_name and employee_id , and display by the total number in ascending. ### Response:
SELECT FIRST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID
### Instruction: what was the last dose of sodium chloride during their current hospital encounter given to patient 82132? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 82132 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'sodium chloride' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: give me the number of patients whose primary disease is aortic insufficiency\re-do sternotomy; aortic valve replacement and admission year is less than 2198? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT " AND demographic.admityear < "2198"
### Instruction: What film was the director william a. wellman, later than 1931 with a leading man of george brent, and a Role of joan gordon, aka francine la rue? ### Response:
SELECT "Film" FROM table_51411 WHERE "Director" = 'william a. wellman' AND "Year" > '1931' AND "Leading Man" = 'george brent' AND "Role" = 'joan gordon, aka francine la rue'
### Instruction: Average response time by tags. The average response time for most popular tags (with at least one vote) ### Response:
SELECT COUNT(DISTINCT Id) AS responses, AVG(CAST((JULIANDAY(ClosedDate) - JULIANDAY(CreationDate)) * 24.0 AS INT)) AS average_response_time_in_hours FROM Posts WHERE CreationDate >= '2020-09-2' AND ClosedDate <= '2020-09-28'
### Instruction: give me the number of patients whose year of death is less than or equal to 2168 and diagnoses long title is hyperosmolality and/or hypernatremia? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dod_year <= "2168.0" AND diagnoses.long_title = "Hyperosmolality and/or hypernatremia"
### Instruction: For the dates of transactions with amount smaller than 3000, bin the date into year interval, and draw a line chart to show the trend of the number of records in each bin, list by the x axis in ascending please. ### Response:
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Sales AS T1 JOIN Transactions AS T2 ON T1.sales_transaction_id = T2.transaction_id WHERE T2.amount_of_transaction < 3000 ORDER BY date_of_transaction
### Instruction: What is the lowest 2010 Employees (Total) when the 2007 Employees (Total) is see note, and the 2012 Employees (Total) is larger than 99,400? ### Response:
SELECT MIN("2010 Employees (Total)") FROM table_63079 WHERE "2007 Employees (Total)" = 'see note' AND "2012 Employees (Total)" > '99,400'
### Instruction: Which Thai restaurant has the most number of reviews ### Response:
SELECT business.name FROM business, category AS CATEGORY_0, category AS CATEGORY_1 WHERE CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'restaurant' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'Thai' ORDER BY business.review_count DESC LIMIT 1
### 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 hire_date and the sum of employee_id bin hire_date by weekday in a bar chart. ### Response:
SELECT HIRE_DATE, SUM(EMPLOYEE_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 marital status is widowed and lab test chart time is 2108-09-28 03:52:00? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "WIDOWED" AND lab.charttime = "2108-09-28 03:52:00"
### Instruction: what were the five drugs that were ordered the most frequently in this year? ### Response:
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
### Instruction: What grades have I received in courses that Prof. Papagerakis has taught ? ### Response:
SELECT DISTINCT student_record.grade FROM student_record INNER JOIN offering_instructor ON student_record.offering_id = offering_instructor.offering_id INNER JOIN instructor ON offering_instructor.instructor_id = instructor.instructor_id WHERE LOWER(instructor.name) LIKE '%Papagerakis%' AND student_record.student_id = 1
### Instruction: count the number of visits to the intensive care unit of patient 021-139760 in 2102. ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-139760') AND STRFTIME('%y', patient.unitadmittime) = '2102'
### Instruction: what is the number of patients on main type of drug prescription who have the diagnoses of other respiratory problems after birth? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Other respiratory problems after birth" AND prescriptions.drug_type = "MAIN"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the trend about department_id over hire_date , and could you display by the X-axis in ascending? ### Response:
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY HIRE_DATE
### Instruction: What is the sum of revenue in Hong Kong with a rank greater than 42, less than $3.46 billion in assets, and greater than $0.17 billion in profits? ### Response:
SELECT SUM("Revenue (Bn.$)") FROM table_47307 WHERE "Assets (Bn.$)" < '3.46' AND "Headquarters" = 'hong kong' AND "Profit (Bn.$)" > '0.17' AND "Rank" > '42'
### Instruction: what is the number of patients on main drug type prescription who are diagnosed with malignant neoplasm of descending colon? ### 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 = "Mal neo descend colon" AND prescriptions.drug_type = "MAIN"
### Instruction: What are the descriptions of the categories that products with product descriptions that contain the letter t are in, and count them by a bar chart, could you rank x axis from low to high order? ### Response:
SELECT product_category_description, COUNT(product_category_description) FROM Ref_Product_Categories AS T1 JOIN Products AS T2 ON T1.product_category_code = T2.product_category_code WHERE T2.product_description LIKE '%t%' GROUP BY product_category_description ORDER BY product_category_description
### Instruction: what is the listing for 2012 when 2004 is more than 0, 2008 is more than 1 1994 is 8 and 2005 is less than 11? ### Response:
SELECT MIN("2012") FROM table_67537 WHERE "2004" > '0' AND "2008" > '1' AND "1994" = '8' AND "2005" < '11'
### Instruction: count the number of patients whose diagnosis short title is mental disor nec oth dis and lab test category is blood gas. ### 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 = "Mental disor NEC oth dis" AND lab."CATEGORY" = "Blood Gas"
### Instruction: give me the number of patients whose diagnoses long title is infectious mononucleosis 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 = "Infectious mononucleosis" AND prescriptions.drug_type = "BASE"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, return a bar chart about the distribution of first_name and manager_id , sort FIRST_NAME in desc order. ### Response:
SELECT FIRST_NAME, MANAGER_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY FIRST_NAME DESC
### Instruction: how many patients whose diagnoses short title is glucocorticoid deficient 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 = "Glucocorticoid deficient" AND lab."CATEGORY" = "Hematology"
### 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 department_id , and I want to show in asc by the LAST_NAME. ### 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 LAST_NAME
### Instruction: what is the number of patients whose diagnoses short title is long-term use of insulin and lab test name is urobilinogen? ### 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 = "Long-term use of insulin" AND lab.label = "Urobilinogen"
### Instruction: When did qiang ma publish his MapReduce paper ? ### Response:
SELECT DISTINCT paper.year FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'qiang ma' AND keyphrase.keyphrasename = 'MapReduce' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: Show the ids and details of the investors who have at least two transactions with type code 'SALE' Plot them as bar chart, and list in desc by the Investor_details please. ### Response:
SELECT T1.Investor_details, T1.investor_id FROM Investors AS T1 JOIN Transactions AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" ORDER BY T1.Investor_details DESC
### Instruction: What is the name of the project that has a scientist assigned to it whose name contains 'Smith', and count them by a bar chart, and could you show bar in descending order? ### 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 T2.Name DESC
### Instruction: how many times has patient 9519 been prescribed bupropion (sustained release) until 8 months ago. ### Response:
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9519) AND prescriptions.drug = 'bupropion (sustained release)' AND DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-8 month')
### Instruction: A user's posts, non-paged (non-Community Wiki). A way around paging for a user's posts, questions and answers. A view count of zero means it is an answer. ### Response:
SELECT p.Id AS "post_link", Score AS "votes", ViewCount AS "views", p.CommunityOwnedDate AS "cw" FROM Posts AS p WHERE p.OwnerUserId = '##UserId##' AND p.CommunityOwnedDate IS NULL ORDER BY ViewCount DESC
### Instruction: calculate patient 15119's length of stay in the icu for the last time. ### Response:
SELECT STRFTIME('%j', icustays.outtime) - STRFTIME('%j', icustays.intime) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 15119) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1
### Instruction: count the number of patients whose diagnoses short title is poisoning-opiates nec 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 = "Poisoning-opiates NEC" AND prescriptions.drug_type = "MAIN"
### Instruction: What are the distinct ids of products ordered between 1975-01-01 and 1976-01-01?? ### Response:
SELECT DISTINCT T2.product_id FROM orders AS T1 JOIN order_items AS T2 ON T1.order_id = T2.order_id WHERE T1.date_order_placed >= "1975-01-01" AND T1.date_order_placed <= "1976-01-01"
### Instruction: Questions and Answers by Day of Week. ### Response:
SELECT TIME_TO_STR(CreationDate, '%A') AS "date", PostTypeId, COUNT(*) AS "posted" FROM Posts WHERE DeletionDate IS NULL AND ClosedDate IS NULL AND AnswerCount > 0 AND CreationDate >= '2020-01-01T00:00:00' GROUP BY TIME_TO_STR(CreationDate, '%A'), PostTypeId ORDER BY PostTypeId, Posted
### Instruction: What is the area in km2 for Cape Agulhas, whose density is larger than 9.4 inhabitants/km2 and whose population in 2011 was less than 33,038? ### Response:
SELECT MAX("Area (km 2 )") FROM table_8973 WHERE "Density (inhabitants/km 2 )" > '9.4' AND "Name" = 'cape agulhas' AND "Population (2011)" < '33,038'
### Instruction: top 200 french users using nodejs. ### Response:
SELECT Id AS "user_link", Reputation, WebsiteUrl, Location FROM Users AS usrr JOIN (SELECT usr.Id AS userId FROM Users AS usr JOIN Posts AS post ON usr.Id = post.OwnerUserId WHERE usr.Location LIKE '%India%' AND post.Tags LIKE '%node.js%' GROUP BY usr.Id) AS sub ON usrr.Id = sub.userId ORDER BY usrr.Reputation DESC LIMIT 200
### Instruction: how may patients below 83 years of age are diagnosed with personal history of malignant neoplasm of gastrointestinal tract, unspecified? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.age < "83" AND diagnoses.long_title = "Personal history of malignant neoplasm of gastrointestinal tract, unspecified"
### Instruction: A bar chart for what are the number of the completion dates of all the tests that have result 'Fail'?, and I want to sort in ascending by the y-axis. ### 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)
### Instruction: how many patients are primary diagnosed for femoral artery thrombosis and used sodium chloride 0.9% flush? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.diagnosis = "FEMORAL ARTERY THROMBOSIS" AND prescriptions.drug = "Sodium Chloride 0.9% Flush"
### Instruction: give me the number of patients whose diagnoses long title is acute pancreatitis and drug type is additive? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE diagnoses.long_title = "Acute pancreatitis" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: questions tagged qt over the years. ### Response:
SELECT YEAR(CreationDate) AS "year", SUM(CASE WHEN PostHistoryTypeId = 3 THEN 1 ELSE 0 END) AS InitialTags, SUM(CASE WHEN PostHistoryTypeId = 6 THEN 1 ELSE 0 END) AS EditedTags, SUM(1) AS TotalQuestionsWithTag FROM PostHistory WHERE PostHistoryTypeId IN (3, 6) AND 'text' LIKE '%<##tag##>%' GROUP BY YEAR(CreationDate)
### Instruction: calculate the length of the hospital stay of patient 16248's first icu stay. ### Response:
SELECT STRFTIME('%j', icustays.outtime) - STRFTIME('%j', icustays.intime) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16248) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1
### Instruction: A pie chart for finding the number of the names of stadiums that some Australian swimmers have been to. ### Response:
SELECT T4.Name, COUNT(T4.Name) FROM swimmer AS t1 JOIN record AS t2 ON t1.ID = t2.Swimmer_ID JOIN event AS t3 ON t2.Event_ID = t3.ID JOIN stadium AS t4 ON t4.ID = t3.Stadium_ID WHERE t1.Nationality = 'Australia' GROUP BY T4.Name
### 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 the trend about department_id over hire_date with a line chart. ### Response:
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: give me the number of patients whose diagnoses icd9 code is v4364 and drug route is ivpca? ### 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 = "V4364" AND prescriptions.route = "IVPCA"
### Instruction: what is the number of patients whose diagnoses icd9 code is 75732 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.icd9_code = "75732" AND prescriptions.drug_type = "BASE"
### Instruction: What is the first name of the student whose last name starting with the letter S and is taking ACCT-211 class? ### Response:
SELECT T1.stu_fname FROM student AS T1 JOIN enroll AS T2 ON T1.stu_num = T2.stu_num JOIN CLASS AS T3 ON T2.class_code = T3.class_code WHERE T3.crs_code = 'ACCT-211' AND T1.stu_lname LIKE 'S%'
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about employee_id over the email , and I want to display in ascending by the y axis. ### Response:
SELECT EMAIL, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMPLOYEE_ID
### Instruction: please list all the takeoffs and landings for MKE ### Response:
SELECT DISTINCT flight.flight_id FROM airport AS AIRPORT_0, airport AS AIRPORT_1, flight WHERE (flight.to_airport = AIRPORT_0.airport_code AND AIRPORT_0.airport_code = 'MKE') OR (flight.from_airport = AIRPORT_1.airport_code AND AIRPORT_1.airport_code = 'MKE')
### Instruction: provide me the number of patients taking medication via inhalation who have diagnoses icd9 code 1418. ### 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 = "1418" AND prescriptions.route = "INHALATION"
### Instruction: how many times until 1 year ago patient 006-47961 had visited the intensive care unit? ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-47961') AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-1 year')
### Instruction: For those employees who did not have any job in the past, visualize a bar chart about the distribution of job_id and the sum of employee_id , and group by attribute job_id, and could you rank in ascending by the y-axis? ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY SUM(EMPLOYEE_ID)