instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### 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, and display from high to low by the bars. ### 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 DESC
### 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: 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, return a scatter chart about the correlation between commission_pct and manager_id . ### Response:
SELECT COMMISSION_PCT, MANAGER_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### 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 , show X-axis in desc order please. ### 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: 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: tell me the length of time of patient 28484's last stay in icu. ### 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 = 28484) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, draw a line chart about the change of manager_id over hire_date , and show in descending by the X. ### 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: 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: what medication was prescribed for the last time in 11/2103 to patient 27739? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 27739) AND STRFTIME('%y-%m', prescriptions.startdate) = '2103-11' ORDER BY prescriptions.startdate DESC LIMIT 1
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find last_name and employee_id , and visualize them by a bar chart, could you show in desc by the X? ### Response:
SELECT LAST_NAME, EMPLOYEE_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY LAST_NAME 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: is there any record of the microbiology test in their current hospital encounter for patient 031-3355? ### Response:
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3355' AND patient.hospitaldischargetime IS NULL))
### Instruction: what were the top four medicines that were frequently prescribed a year before? ### 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', '-1 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 4
### Instruction: when did patient 18841 get admitted to the hospital for the first time the last year via emergency room admitting? ### Response:
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 18841 AND admissions.admission_location = 'emergency room admit' AND DATETIME(admissions.admittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY admissions.admittime LIMIT 1
### Instruction: what's patient 17944's length of stay in the last 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 = 17944) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime DESC LIMIT 1
### Instruction: what is the difference in percentage of lead shot at 25 yards between cylinder and skeet 1 barrels ? ### Response:
SELECT ABS((SELECT "percentage of lead shot in 30-inch circle at 40 yards" FROM table_203_112 WHERE "choke" = 'cylinder') - (SELECT "percentage of lead shot in 30-inch circle at 40 yards" FROM table_203_112 WHERE "choke" = 'skeet 1'))
### Instruction: tell me the top three most common output events until 2101? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT outputevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM outputevents WHERE STRFTIME('%y', outputevents.charttime) <= '2101' GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 3)
### 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 department_id , and sort DEPARTMENT_ID in descending order. ### 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: How many points does an entrant of Martini Racing, the engine of an Alfa Romeo flat-12 a chassis of brabham bt45, and the year 1976 have? ### Response:
SELECT COUNT("Points") FROM table_68926 WHERE "Entrant" = 'martini racing' AND "Engine" = 'alfa romeo flat-12' AND "Chassis" = 'brabham bt45' AND "Year" = '1976'
### Instruction: The teacher for PATH 643 is whom ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'PATH' AND course.number = 643 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: when was the first sputum microbiology test given to patient 12775 during the current hospital encounter? ### Response:
SELECT microbiologyevents.charttime FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12775 AND admissions.dischtime IS NULL) AND microbiologyevents.spec_type_desc = 'sputum' ORDER BY microbiologyevents.charttime LIMIT 1
### Instruction: Minimum, Maximum, and Average Number of Answers Per Post. The minimum, maximum, and average number of answers per post on Stack Overflow. ### Response:
SELECT MIN(Posts.AnswerCount) AS "minimum_#_of_answers", AVG(CAST(Posts.AnswerCount AS FLOAT)) AS "average_#_of_answers", MAX(Posts.AnswerCount) AS "maximum_#_of_answers" FROM Posts WHERE Posts.PostTypeId = 1
### Instruction: how many patients whose ethnicity is hispanic/latino - puerto rican and procedure long title is insertion of one vascular stent? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND procedures.long_title = "Insertion of one vascular stent"
### Instruction: what is the four most frequent specimen test that was taken in 2101? ### Response:
SELECT t1.spec_type_desc FROM (SELECT microbiologyevents.spec_type_desc, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM microbiologyevents WHERE STRFTIME('%y', microbiologyevents.charttime) = '2101' GROUP BY microbiologyevents.spec_type_desc) AS t1 WHERE t1.c1 <= 4
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a bar chart about the distribution of email and employee_id , order y-axis from high to low order. ### 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 DESC
### Instruction: What is the total number of olives of the governorate with less than 259,743 vegetables, more than 14,625 industrial crops, and 20,768 fruit trees? ### Response:
SELECT COUNT("Olives") FROM table_12848 WHERE "Vegetables" < '259,743' AND "Industrial crops" > '14,625' AND "Fruit Trees" = '20,768'
### Instruction: hyperlipidemia ( total cholesterol > 260 mg / dl, ldl > 130 mg / dl, and / or triglycerides > 300 mg / dl ) despite appropriate treatment. ### Response:
SELECT * FROM table_dev_19 WHERE hyperlipidemia = 1 OR (total_cholesterol > 260 AND ldl > 130 AND triglyceride_tg > 300) AND treatment = 1
### Instruction: Who instructs BCS 532 ? ### Response:
SELECT DISTINCT instructor.name FROM course, course_offering, instructor, offering_instructor WHERE course.course_id = course_offering.course_id AND course.department = 'BCS' AND course.number = 532 AND offering_instructor.instructor_id = instructor.instructor_id AND offering_instructor.offering_id = course_offering.offering_id
### Instruction: What rank is an airport coded CLJ/LRCL, with a value larger than 32,561 and more than 1,028,907 in 2010? ### Response:
SELECT MIN("Rank") FROM table_13910 WHERE "2009" > '32,561' AND "Code (IATA/ICAO)" = 'clj/lrcl' AND "2010" > '1,028,907'
### 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 manager_id , list by the Y from high to low. ### Response:
SELECT PHONE_NUMBER, 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 the name of the first medication prescribed to patient 12402 in 05/2105? ### Response:
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12402) AND STRFTIME('%y-%m', prescriptions.startdate) = '2105-05' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: What is the sum of 1872(s), when 1866 is greater than 856, when 1861 is greater than 1906, and when 1876 is greater than 1990? ### Response:
SELECT SUM("1872") FROM table_42565 WHERE "1866" > '856' AND "1861" > '1906' AND "1876" > '1990'
### Instruction: when was a medication prescribed for the first time for patient 94316 in 03/2103? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 94316) AND STRFTIME('%y-%m', prescriptions.startdate) = '2103-03' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: how many patients of hispanic, or latino/puerto rican ethnicity are diagnosed with icd9 code 51889? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND diagnoses.icd9_code = "51889"
### Instruction: when did patient 43052 get a procedure for the last time since 1 year ago? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 43052) AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: provide the number of patients whose diagnoses short title is adv eff antifung antbiot 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.short_title = "Adv eff antifung antbiot" AND prescriptions.drug_type = "BASE"
### Instruction: I need to know AIDS and Other Health Crises courses with no prerequisites . ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id WHERE (area.area LIKE '%AIDS and Other Health Crises%' OR course.description LIKE '%AIDS and Other Health Crises%' OR course.name LIKE '%AIDS and Other Health Crises%') AND course.enforced_requirement = 'N / A'
### Instruction: provide the number of patients whose diagnoses short title is crbl art ocl nos w infrc 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 = "Crbl art ocl NOS w infrc" AND lab.flag = "abnormal"
### Instruction: -- How many upvotes do I have for each tag? -- how long before I get tag badges? DECLARE @UserId in. ### Response:
SELECT TagName, COUNT(*) AS UpVotes 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 WHERE Posts.OwnerUserId = @UserId GROUP BY TagName ORDER BY UpVotes DESC
### Instruction: count the number of patients whose primary disease is aortic valve insufficiency/aortic valve replacement/sda and lab test fluid is blood. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "AORTIC VALVE INSUFFIENCY\AORTIC VALVE REPLACEMENT /SDA" AND lab.fluid = "Blood"
### Instruction: Find question in the past month that have links to JSFiddle or CodePen but no code in the question. ### Response:
SELECT CONCAT('http://stackoverflow.com/questions/', Id) AS "Link", Score FROM Posts WHERE CreationDate > DATEADD(MONTH, -1, GETDATE()) AND PostTypeId = 1 AND (Body LIKE '%jsfiddle.net%' OR Body LIKE '%codepen.io%') AND NOT (Body LIKE '% %' OR Body LIKE '%<pre>%' OR Body LIKE '%<code>%')
### Instruction: Which Basin's Continent is South America, has a Basin Area km 2 larger than 6,144,727, and a Basin Area mi 2 of 238,539? ### Response:
SELECT "Basin" FROM table_32415 WHERE "Continent" = 'south america' AND "Basin Area km 2" > '6,144,727' AND "Basin Area mi 2" = '238,539'
### Instruction: was there any microbiology tests for the tissue of patient 20165 when they came to the hospital last time? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 20165 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND microbiologyevents.spec_type_desc = 'tissue'
### Instruction: What is the 2011 total with a 2008 value greater than 346.5, a 2009 value of 392, and a 2010 value bigger than 354.6? ### Response:
SELECT COUNT("2011") FROM table_34882 WHERE "2008" > '346.5' AND "2009" = '392' AND "2010" > '354.6'
### Instruction: What are some papers dealing with Semantic Data in YAGO ? ### Response:
SELECT DISTINCT paperkeyphrase.paperid FROM dataset, keyphrase, paperdataset, paperkeyphrase WHERE dataset.datasetname = 'YAGO' AND keyphrase.keyphrasename = 'Semantic Data' AND paperdataset.datasetid = dataset.datasetid AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paperkeyphrase.paperid = paperdataset.paperid
### Instruction: count the number of patients who have undergone a bands lab test until 2 years ago. ### 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 = 'bands') AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-2 year'))
### Instruction: Answers Accepted By Users - Count. ### Response:
SELECT Users.Id, Users.DisplayName, COUNT(ans.Id) FROM Users AS users JOIN Posts AS qtns ON qtns.PostTypeId = 1 AND Users.Id = qtns.OwnerUserId JOIN Posts AS ans ON ans.PostTypeId = 2 AND qtns.AcceptedAnswerId = ans.Id WHERE ans.OwnerUserId = @UserId GROUP BY Users.Id, Users.DisplayName ORDER BY COUNT(ans.Id) DESC
### Instruction: Search for users by rep and location. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Id AS "user_id", (CASE WHEN DisplayName LIKE '%arbar%zha%' THEN '|_' + DisplayName + '_|' ELSE DisplayName END) AS DisplayName, Reputation, Location FROM Users WHERE (LOWER(Location) LIKE '%portland, or%' OR LOWER(Location) LIKE '%porlland, oregon%') ORDER BY Reputation DESC LIMIT 250
### 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 employee_id , rank from high to low by the total number please. ### 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 DESC
### Instruction: what was patient 012-63427's first id of the ward until 1 year ago? ### Response:
SELECT patient.wardid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '012-63427') AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-1 year') ORDER BY patient.unitadmittime LIMIT 1
### Instruction: in 2103 what is the top four most frequent output event? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT outputevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM outputevents WHERE STRFTIME('%y', outputevents.charttime) = '2103' GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 4)
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of hire_date and the average of employee_id bin hire_date by time in a bar chart. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200)
### Instruction: last month, when did patient 21110 receive the first prescribed prescription? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 21110) AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-1 month') ORDER BY prescriptions.startdate LIMIT 1
### Instruction: Posts closed since 01/2012 by month. ### Response:
SELECT CAST(YEAR(p.CreationDate) AS TEXT(10)) + '/' + CAST(MONTH(p.CreationDate) AS TEXT(19)) AS dt, COUNT(p.Id) AS pcount FROM Posts AS p WHERE p.CreationDate > '2012-01-01' GROUP BY YEAR(p.CreationDate), MONTH(p.CreationDate)
### Instruction: Show the number of courses for each instructor in a bar chart. ### Response:
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM JOIN COURSE AS T3 ON T1.CRS_CODE = T3.CRS_CODE JOIN PROFESSOR AS T4 ON T2.EMP_NUM = T4.EMP_NUM GROUP BY EMP_FNAME
### Instruction: what is the highest region when the population is less than 4,797, the name is l'ascension-de-notre-seigneur and the area (km 2) is more than 131.83? ### Response:
SELECT MAX("Region") FROM table_11045 WHERE "Population" < '4,797' AND "Name" = 'l''ascension-de-notre-seigneur' AND "Area (km 2 )" > '131.83'
### Instruction: Percentage of good votes (up, accept, fav), by year. ### Response:
SELECT (1.0 * (SELECT COUNT(*) FROM Votes WHERE CreationDate >= @startdt AND CreationDate < @enddt AND (VoteTypeId <= 2 OR VoteTypeId = 5))) / (1.0 * (SELECT COUNT(*) FROM Votes WHERE CreationDate >= @startdt AND CreationDate < @enddt AND (VoteTypeId != 8 AND VoteTypeId != 9))) * 100
### Instruction: what were the five frequent output events that happened in 2101? ### Response:
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT outputevents.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM outputevents WHERE STRFTIME('%y', outputevents.charttime) = '2101' GROUP BY outputevents.itemid) AS t1 WHERE t1.c1 <= 5)
### Instruction: A bar chart for returning the number of the completion date for all the tests that have 'Fail' result, and I want to order in asc by the X. ### 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" GROUP BY date_of_completion ORDER BY date_of_completion
### Instruction: when was patient 77177 first prescribed the medication via the ou route in the first hospital encounter? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77177 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND prescriptions.route = 'ou' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: provide the number of patients whose primary disease is aortic valve insuffiency\aortic valve replacement /sda and lab test abnormal status is abnormal? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "AORTIC VALVE INSUFFIENCY\AORTIC VALVE REPLACEMENT /SDA" AND lab.flag = "abnormal"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about commission_pct over the job_id , and order in ascending by the total number. ### 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: Find all Pet Hospice in Pittsburgh ### Response:
SELECT business.name FROM business, category AS CATEGORY_0, category AS CATEGORY_1 WHERE business.city = 'Pittsburgh' AND CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'Hospice' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'Pet'
### Instruction: What is the possibility of being able to take ACC 990 in Winter of 2014 ? ### Response:
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'ACC' AND course.number = 990 AND semester.semester = 'Winter' AND semester.semester_id = course_offering.semester AND semester.year = 2014
### Instruction: For those employees who did not have any job in the past, give me the comparison about the average of department_id over the job_id , and group by attribute job_id by a bar chart, and I want to display y axis from high to low order please. ### Response:
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: how many times has patient 022-20829 been at the intensive care unit until 3 years ago? ### Response:
SELECT COUNT(DISTINCT patient.patientunitstayid) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '022-20829') AND DATETIME(patient.unitadmittime) <= DATETIME(CURRENT_TIME(), '-3 year')
### Instruction: List the number of enginners in a stacked bar chart The x-axis is last name and group by skill description, rank bars from low to high order. ### Response:
SELECT last_name, COUNT(last_name) FROM Maintenance_Engineers AS T1 JOIN Engineer_Skills AS T2 ON T1.engineer_id = T2.engineer_id JOIN Skills AS T3 ON T2.skill_id = T3.skill_id GROUP BY skill_description, last_name ORDER BY last_name
### Instruction: For those employees who was hired before 2002-06-21, return a bar chart about the distribution of job_id and the average of employee_id , and group by attribute job_id, and show Y-axis in descending order. ### Response:
SELECT JOB_ID, AVG(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID 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, a bar chart shows the distribution of first_name and commission_pct , display by the y axis in asc. ### 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: For those employees who do not work in departments with managers that have ids between 100 and 200, find job_id and department_id , and visualize them by a bar chart, could you show in ascending by the x-axis? ### Response:
SELECT JOB_ID, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY JOB_ID
### Instruction: For those employees who was hired before 2002-06-21, find job_id and the average of employee_id , and group by attribute job_id, and visualize them by a bar chart, and display y-axis in asc order. ### Response:
SELECT JOB_ID, AVG(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY AVG(EMPLOYEE_ID)
### Instruction: Provide the number of patients who have been diagnosed with subarachnoid hemorrhage and were ordered a pleural 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.short_title = "Subarachnoid hemorrhage" AND lab.fluid = "Pleural"
### Instruction: Answers that were deleted after being accepted. ### Response:
SELECT e.PostId AS "post_link", v.CreationDate AS "acceptance_time", e.CreationDate AS "deletion_time" FROM PostHistory AS e INNER JOIN Votes AS v ON v.PostId = e.PostId WHERE e.PostHistoryTypeId = 13 AND v.VoteTypeId = 1 AND DATEDIFF(day, v.CreationDate, CreationDate) > 1 ORDER BY e.CreationDate DESC
### Instruction: find the number of patients whose diagnoses title is b12 defic anemia 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 = "B12 defic anemia NEC" AND prescriptions.drug_type = "MAIN"
### Instruction: What is the average Year that has a Quantity of 10, and a GWR Numbers of 409, 290, 315, 317 321, 324, 333? ### Response:
SELECT AVG(year) FROM table_name_49 WHERE quantity = 10 AND gwr_numbers = "409, 290, 315, 317–321, 324, 333"
### Instruction: Will MEDEDUC 599 be having class 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 = 'MEDEDUC' AND course.number = 599 AND semester.semester = 'WN' AND semester.year = 2016
### Instruction: what are the four most common diagnoses during this year. ### Response:
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE DATETIME(diagnosis.diagnosistime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 4
### Instruction: Give me all the Moroccan restaurant in Texas ### Response:
SELECT business.name FROM business, category AS CATEGORY_0, category AS CATEGORY_1 WHERE business.state = 'Texas' AND CATEGORY_0.business_id = business.business_id AND CATEGORY_0.category_name = 'Moroccan' AND CATEGORY_1.business_id = business.business_id AND CATEGORY_1.category_name = 'restaurant'
### Instruction: what is in the current hospital encounter maximum vancomycin value of patient 57050? ### Response:
SELECT MAX(labevents.valuenum) FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 57050 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'vancomycin')
### 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, draw a line chart about the change of commission_pct over hire_date . ### Response:
SELECT HIRE_DATE, COMMISSION_PCT FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: how many patients have had a proximal gastrectomy procedure? ### Response:
SELECT COUNT(DISTINCT admissions.subject_id) FROM admissions WHERE admissions.hadm_id IN (SELECT procedures_icd.hadm_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 = 'proximal gastrectomy'))
### 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')