instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: Duplicate 'Duplicate' post notices (Thanks to Samuel Liew for a good basis). ### Response:
SELECT p.CreationDate, p.Id AS "post_link", p.Score, p.ViewCount, p.AnswerCount FROM Posts AS p WHERE p.PostTypeId = 1 AND p.ClosedDate IS NULL AND p.DeletionDate IS NULL AND p.Body LIKE '%Possible Duplicate:%' ORDER BY p.ViewCount DESC LIMIT 1000
### Instruction: How many students are older than 20 in each dorm Visualize by bar chart, and display in descending by the bar. ### Response:
SELECT dorm_name, COUNT(*) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.Age > 20 GROUP BY T3.dorm_name ORDER BY dorm_name DESC
### Instruction: What is the name of the ship sunk on 5 May 1943 from the United Kingdom sunk by an u-266 with 0 casualties? ### Response:
SELECT "Name" FROM table_11435 WHERE "Date" = '5 may 1943' AND "Nationality" = 'united kingdom' AND "Sunk by\u2026" = 'u-266' AND "Casualties" = '0'
### Instruction: give me the number of patients whose diagnoses short title is abnormal loss of weight and lab test fluid is pleural? ### 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 = "Abnormal loss of weight" AND lab.fluid = "Pleural"
### Instruction: What is the smallest amount of freight carried on the road that closed on March 31 and reached super B capacity on February 17 after 2011? ### Response:
SELECT MIN("Freight Carried s Tonne") FROM table_80057 WHERE "Road Closed" = 'march 31' AND "Super B Capacity Reached [ citation needed ]" = 'february 17' AND "Year" > '2011'
### Instruction: provide the number of patients whose ethnicity is black/cape verdean and drug code is docu100? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "BLACK/CAPE VERDEAN" AND prescriptions.formulary_drug_cd = "DOCU100"
### Instruction: Out of total number of patients admitted before the year 2150, how many of them were treated with dabigatran etexilate? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2150" AND prescriptions.drug = "Dabigatran Etexilate"
### Instruction: Find the dates of assessment notes for students with first name 'Fanny', and count them by a bar chart, and I want to display by the y axis from low to high. ### Response:
SELECT date_of_notes, COUNT(date_of_notes) FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.first_name = "Fanny" ORDER BY COUNT(date_of_notes)
### Instruction: provide the number of patients who have the admission location as transfer from hosp/extram and diagnosis icd9 code as 4820. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND diagnoses.icd9_code = "4820"
### Instruction: A pie chart showing the number of browsers for each accelerator in the descending order of compatible year. ### Response:
SELECT T3.name, COUNT(T3.name) FROM accelerator_compatible_browser AS T1 JOIN browser AS T2 ON T1.browser_id = T2.id JOIN Web_client_accelerator AS T3 ON T1.accelerator_id = T3.id GROUP BY T3.name ORDER BY T1.compatible_since_year DESC
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, find email and salary , and visualize them by a bar chart, and list in ascending by the bars. ### Response:
SELECT EMAIL, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY EMAIL
### Instruction: What was the average number of people born in other EU states in millions, when the total number of foreign-born people in millions was 0.5, and when the total population in millions was less than 5.534? ### Response:
SELECT AVG(born_in_other_eu_state__millions_) FROM table_name_57 WHERE total_foreign_born__millions_ = 0.5 AND total_population__millions_ < 5.534
### Instruction: For those employees who did not have any job in the past, a bar chart shows the distribution of hire_date and the sum of department_id bin hire_date by weekday, and could you order from low to high by the sum department id? ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(DEPARTMENT_ID)
### Instruction: what topics does Luke Zettlemoyer publish in ### Response:
SELECT DISTINCT keyphrase.keyphraseid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'Luke Zettlemoyer' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: What rider has laps less than 20, a ducati 1098 rs 08 as the bike, with accident as the time, and a grid less than 14? ### Response:
SELECT "Rider" FROM table_64321 WHERE "Laps" < '20' AND "Bike" = 'ducati 1098 rs 08' AND "Time" = 'accident' AND "Grid" < '14'
### Instruction: what is the number of patients whose admission location is clinic referral/premature and lab test name is reticulocyte count, manual? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND lab.label = "Reticulocyte Count, Manual"
### Instruction: Which Torque Nm@rpm has a Power kW@rpm equal to 184 @ 2500 and a GVM (kg) Technical Capacity of 16000? ### Response:
SELECT "Torque Nm@rpm" FROM table_54074 WHERE "Power kW@rpm" = '184 @ 2500' AND "GVM (kg) Technical Capacity" = '16000'
### Instruction: how many patients whose diagnoses short title is pyelonephritis nos 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.short_title = "Pyelonephritis NOS" AND lab.flag = "delta"
### Instruction: count the number of patients whose admission type is emergency and drug name is sulfameth/trimethoprim suspension? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND prescriptions.drug = "Sulfameth/Trimethoprim Suspension"
### Instruction: Name the courses in Digital Studio that satisfy the MDE requirement . ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN program_course ON program_course.course_id = course.course_id WHERE (area.area LIKE '%Digital Studio%' OR course.description LIKE '%Digital Studio%' OR course.name LIKE '%Digital Studio%') AND program_course.category LIKE '%MDE%'
### Instruction: provide the number of patients whose insurance is self pay and procedure long title is initial insertion of transvenous lead [electrode] into ventricle? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.insurance = "Self Pay" AND procedures.long_title = "Initial insertion of transvenous lead [electrode] into ventricle"
### Instruction: Which tourist attractions does the visitor with detail 'Vincent' visit? ### Response:
SELECT T1.Name FROM Tourist_Attractions AS T1 JOIN VISITS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID JOIN VISITORS AS T3 ON T2.Tourist_ID = T3.Tourist_ID WHERE T3.Tourist_Details = "Vincent"
### Instruction: How many surfaces were played on in 2005 where the score was 6 7 (4 7) , 3 6, 7 6 (7 2) , 3 6? ### Response:
SELECT COUNT("Surface") FROM table_2082 WHERE "Year" = '2005' AND "Score" = '6–7 (4–7) , 3–6, 7–6 (7–2) , 3–6'
### Instruction: when first patient 006-21143 was discharged from the hospital in the last year? ### Response:
SELECT patient.hospitaldischargetime FROM patient WHERE patient.uniquepid = '006-21143' AND DATETIME(patient.hospitaldischargetime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY patient.hospitaldischargetime LIMIT 1
### Instruction: Which courses are there this semester ? ### Response:
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016 ORDER BY course.department
### Instruction: what is the total number of patients who had brain mass, intracranial hemorrhage as primary disease and had a lab test for ascites? ### 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 = "Ascites"
### Instruction: Dropping fast: Lowest question score per thousand views among questions with score -5 or worse. ### Response:
SELECT Posts.Id AS "post_link", Posts.OwnerUserId AS "user_link", Score, ViewCount, Score * 1000 / ViewCount AS "Score per Thousand Views" FROM Posts WHERE Score <= -5 AND PostTypeId = 1 ORDER BY Score * 1000 / ViewCount LIMIT 1000
### Instruction: Which smallest interview number had a swimsuit stat of less than 9.322, an evening gown score of more than 9.259, and an average number of 9.321? ### Response:
SELECT MIN("Interview") FROM table_11395 WHERE "Swimsuit" < '9.322' AND "Evening Gown" > '9.259' AND "Average" = '9.321'
### Instruction: For those employees who did not have any job in the past, return a bar chart about the distribution of hire_date and the average of manager_id bin hire_date by time, and could you sort total number from low to high order? ### Response:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(MANAGER_ID)
### Instruction: Users with most Edits per Post. ### Response:
WITH Edits AS (SELECT RANK() OVER (ORDER BY COUNT(*) DESC) AS Rank, UserId AS "user_link", COUNT(*) AS NumRevisions FROM PostHistory WHERE PostHistoryTypeId BETWEEN 4 AND 9 GROUP BY UserId) SELECT Rank, 'user_link', NumRevisions FROM Edits WHERE Rank < 100 OR 'user_link' = '##UserID##' ORDER BY Rank
### Instruction: For those employees who was hired before 2002-06-21, find job_id and the sum of department_id , and group by attribute job_id, and visualize them by a bar chart, rank by the bars in desc please. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: What are the names of the enzymes used in the medicine Amisulpride that acts as inhibitors? ### Response:
SELECT T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id JOIN medicine AS T3 ON T2.medicine_id = T3.id WHERE T3.name = 'Amisulpride' AND T2.interaction_type = 'inhibitor'
### Instruction: For those employees who did not have any job in the past, a bar chart shows the distribution of hire_date and the average of employee_id bin hire_date by time, rank in desc by the total number. ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(EMPLOYEE_ID) DESC
### Instruction: What is the transmission when the engine is 2.0l, and acceleration 0 100km/h (0 62mph) is 10.5 s? ### Response:
SELECT "Transmission" FROM table_63235 WHERE "Engine" = '2.0l' AND "Acceleration 0\u2013100km/h (0\u201362mph)" = '10.5 s'
### Instruction: how many patients whose admission location is clinic referral/premature and diagnoses icd9 code is 2800? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND diagnoses.icd9_code = "2800"
### Instruction: provide the number of patients whose age is less than 77 and procedure long title is excision or destruction of other lesion or tissue of heart, open approach? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.age < "77" AND procedures.long_title = "Excision or destruction of other lesion or tissue of heart, open approach"
### Instruction: London based Python Bronze Badge. ### Response:
SELECT ROW_NUMBER() OVER (ORDER BY Reputation DESC) AS "#", Users.Id AS "user_link", Reputation, Location FROM Users, Badges WHERE Users.Id = Badges.UserId AND Badges.Class = 3 AND Badges.TagBased = 1 AND Badges.Name = 'python' AND LOWER(Users.Location) LIKE LOWER('%London%') ORDER BY Reputation DESC
### Instruction: Return a bar chart on how many students are older than 20 in each dorm?, list bar from low to high order. ### Response:
SELECT dorm_name, COUNT(*) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.Age > 20 GROUP BY T3.dorm_name ORDER BY dorm_name
### Instruction: count the number of patients whose year of death is less than or equal to 2115 and drug code is glyb5? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2115.0" AND prescriptions.formulary_drug_cd = "GLYB5"
### Instruction: Questions with low score and high viewcounts. ### Response:
SELECT Posts.Id AS "post_link", Posts.CreationDate, Posts.Score, Posts.ViewCount, PostHistory.CreationDate AS "ProtectedDate" FROM Posts LEFT JOIN PostHistory ON Posts.Id = PostHistory.PostId AND PostHistory.PostHistoryTypeId = 19 WHERE Posts.Score <= 2 ORDER BY Posts.ViewCount DESC LIMIT 100
### Instruction: For those records from the products and each product's manufacturer, find headquarter and the average of code , and group by attribute headquarter, and visualize them by a bar chart, and rank by the total number from low to high. ### Response:
SELECT T2.Headquarter, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Headquarter ORDER BY T1.Code
### Instruction: in 2105 what was the first care unit of patient 4900? ### Response:
SELECT transfers.careunit FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 4900) AND NOT transfers.careunit IS NULL AND STRFTIME('%y', transfers.intime) = '2105' ORDER BY transfers.intime LIMIT 1
### Instruction: how is patient 027-100528 last admitted into a hospital in the previous year? ### Response:
SELECT patient.hospitaladmitsource FROM patient WHERE patient.uniquepid = '027-100528' AND DATETIME(patient.hospitaladmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') ORDER BY patient.hospitaladmittime DESC LIMIT 1
### Instruction: Find the parties associated with the delegates from district 1 or 2 Who served as comptrollers of the parties, and count them by a bar chart, and rank in asc by the x axis. ### Response:
SELECT Comptroller, COUNT(Comptroller) FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID WHERE T1.District = 1 OR T1.District = 2 GROUP BY Comptroller ORDER BY Comptroller
### Instruction: what number of patients who died in or before 2131 had been prescribed the drug with code cepacol1? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2131.0" AND prescriptions.formulary_drug_cd = "CEPACOL1"
### Instruction: Give the title and credits for the course that is taught in the classroom with the greatest capacity. ### Response:
SELECT T3.title, T3.credits FROM classroom AS T1 JOIN section AS T2 ON T1.building = T2.building AND T1.room_number = T2.room_number JOIN course AS T3 ON T2.course_id = T3.course_id WHERE T1.capacity = (SELECT MAX(capacity) FROM classroom)
### Instruction: how many patients use the drug code rosi8 and tested with urine in lab? ### 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 = "ROSI8" AND lab.fluid = "Urine"
### Instruction: For those records from the products and each product's manufacturer, return a bar chart about the distribution of name and revenue , and group by attribute headquarter, and could you show from high to low by the X-axis please? ### Response:
SELECT T1.Name, T2.Revenue FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter, T1.Name ORDER BY T1.Name DESC
### Instruction: count the number of patients whose year of death is less than or equal to 2138 and procedure long title is other diagnostic procedures on nasal sinuses? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dod_year <= "2138.0" AND procedures.long_title = "Other diagnostic procedures on nasal sinuses"
### 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 salary , and group by attribute job_id, and could you sort x-axis in descending order please? ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: Not so hidden gems: Highest score for questions with less than 10,000 views. ### Response:
SELECT Posts.Id AS "post_link", Posts.OwnerUserId AS "user_link", Score, ViewCount, Score * 1000 / ViewCount AS "Score per Thousand Views" FROM Posts WHERE ViewCount < 10000 AND PostTypeId = 1 ORDER BY Score DESC LIMIT 1000
### Instruction: which championship had helena sukov tom nijssen as opponents in the final and nicole provis as partner, the surface was hard and the outcome was winner ### Response:
SELECT "Championship" FROM table_22879 WHERE "Outcome" = 'Winner' AND "Surface" = 'Hard' AND "Partner" = 'Nicole Provis' AND "Opponents in the final" = 'Helena Suková Tom Nijssen'
### Instruction: what was the first amount of artificial tear ointment that was prescribed to patient 7375? ### Response:
SELECT prescriptions.dose_val_rx FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7375) AND prescriptions.drug = 'artificial tear ointment' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: For those employees who did not have any job in the past, find job_id and the sum of salary , and group by attribute job_id, and visualize them by a bar chart, could you rank sum salary in desc order? ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY SUM(SALARY) DESC
### Instruction: For all employees who have the letters D or S in their first name, show me about the distribution of hire_date and the sum of department_id bin hire_date by time in a bar chart, I want to list by the sum department id in ascending. ### Response:
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY SUM(DEPARTMENT_ID)
### Instruction: give the number of patients whose death status is 1 and diagnosis long title is contusion of face, scalp, and neck except eye(s). ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "1" AND diagnoses.long_title = "Contusion of face, scalp, and neck except eye(s)"
### Instruction: Give the number of patients who were diagnosed with polycethemia vera and have delta as the lab test result. ### 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 = "Polycythemia vera" AND lab.flag = "delta"
### Instruction: What Globalizing Consumer Cultures classes have 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 '%Globalizing Consumer Cultures%' OR course.description LIKE '%Globalizing Consumer Cultures%' OR course.name LIKE '%Globalizing Consumer Cultures%') AND course.enforced_requirement = 'N / A'
### Instruction: Who is the h.h. principal with Jim Haught as h.s. principal, Charlie Taylor as maplemere principal, and Rich Auerbach as w.r. principal? ### Response:
SELECT "H.H. Principal" FROM table_66897 WHERE "H.S. Principal" = 'jim haught' AND "Maplemere Principal" = 'charlie taylor' AND "W.R. Principal" = 'rich auerbach'
### Instruction: Yearly average questions per day. ### Response:
SELECT YEAR(CreationDate) * 12 + MONTH(CreationDate) AS MonthNumber, CAST(COUNT(*) AS FLOAT) / 30 AS "Approximate Questions Per Day" FROM Posts WHERE PostTypeId = 1 GROUP BY YEAR(CreationDate), MONTH(CreationDate) ORDER BY YEAR(CreationDate) DESC, MONTH(CreationDate) DESC
### Instruction: Which september 26 28, 2011 polling firm had a Link of html, less than 36 liberals, and less than 8 green? ### Response:
SELECT "Polling Firm" FROM table_35786 WHERE "Link" = 'html' AND "Liberal" < '36' AND "Green" < '8' AND "Date of Polling" = 'september 26–28, 2011'
### Instruction: Calculate the average age of home discharged patients who have aortic insufficiency re-do sternotomy aortic valve replacement as their primary disease. ### Response:
SELECT AVG(demographic.age) FROM demographic WHERE demographic.discharge_location = "HOME" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
### Instruction: what are the three top most commonly prescribed drugs until 4 years ago? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE DATETIME(prescriptions.startdate) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 3
### Instruction: count the number of patients whose year of death is less than or equal to 2126 and drug code is ggac5l? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2126.0" AND prescriptions.formulary_drug_cd = "GGAC5L"
### Instruction: among patients with other preterm infants 1,750-1,999 grams how many of them were male? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.gender = "M" AND diagnoses.long_title = "Other preterm infants, 1,750-1,999 grams"
### Instruction: what is the number of patients whose discharge location is dead/expired and procedure short title is exc/des hrt les,endovasc? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DEAD/EXPIRED" AND procedures.short_title = "Exc/des hrt les,endovasc"
### Instruction: Which Type has a Date smaller than 1943, and a Builder of alco schenectady, and a Number larger than 822, and Works number of 59867? ### Response:
SELECT "Type" FROM table_5556 WHERE "Date" < '1943' AND "Builder" = 'alco schenectady' AND "Number" > '822' AND "Works number" = '59867'
### Instruction: provide the number of patients who had hydromorphone (dilaudid) prescription and stayed in hospital for more than 30 days. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "30" AND prescriptions.drug = "HYDROmorphone (Dilaudid)"
### Instruction: People helped - By user and date range. ### Response:
SELECT COUNT(a.ParentId) AS AnswerCount, SUM(q.ViewCount) FROM Posts AS a JOIN Posts AS q ON a.ParentId = q.Id WHERE a.PostTypeId = 2 AND a.CreationDate >= '##StartDate##' AND a.CreationDate <= '##EndDate##' AND a.DeletionDate IS NULL AND a.OwnerUserId = '##UserId##'
### Instruction: list airports in ARIZONA NEVADA and CALIFORNIA please ### Response:
SELECT DISTINCT airport_code FROM airport WHERE state_code IN (SELECT STATEalias0.state_code FROM state AS STATEalias0 WHERE ((STATEalias0.state_name = 'CALIFORNIA' OR STATEalias0.state_name = 'NEVADA') OR STATEalias0.state_name = 'ARIZONA'))
### Instruction: Which CO 2 has an Output of ps (kw; hp) @4000 rpm, and a 0 100km/h, s smaller than 11.1? ### Response:
SELECT "CO 2" FROM table_60127 WHERE "Output" = 'ps (kw; hp) @4000 rpm' AND "0\u2013100km/h,s" < '11.1'
### Instruction: what is the number of patients whose primary disease is squamous cell carcinoma oral tongue/sda and year of death is less than or equal to 2131? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "SQUAMOUS CELL CARCINOMA ORAL TONGUE/SDA" AND demographic.dod_year <= "2131.0"
### Instruction: when patient 3403 first got surgery in 2105. ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3403) AND STRFTIME('%y', procedures_icd.charttime) = '2105' ORDER BY procedures_icd.charttime LIMIT 1
### Instruction: A bar chart for returning the number of the lot details of lots that belong to investors with details 'l'?, could you sort by the x-axis from high to low? ### Response:
SELECT lot_details, COUNT(lot_details) FROM Investors AS T1 JOIN Lots AS T2 ON T1.investor_id = T2.investor_id WHERE T1.Investor_details = "l" GROUP BY lot_details ORDER BY lot_details DESC
### Instruction: For all employees who have the letters D or S in their first name, return a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, show from high to low by the total number please. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: How much Population (2011) has a Land area (km ) larger than 15.69, and a Population density (per km ) larger than 57.3? ### Response:
SELECT SUM("Population (2011)") FROM table_62793 WHERE "Land area (km\u00b2)" > '15.69' AND "Population density (per km\u00b2)" > '57.3'
### Instruction: For those records from the products and each product's manufacturer, give me the comparison about the sum of manufacturer over the headquarter , and group by attribute headquarter by a bar chart, could you list by the total number in ascending? ### Response:
SELECT Headquarter, SUM(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY SUM(Manufacturer)
### Instruction: what is the number of patients whose admission type is urgent and diagnoses long title is ostium secundum type atrial septal defect? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "URGENT" AND diagnoses.long_title = "Ostium secundum type atrial septal defect"
### Instruction: For all employees who have the letters D or S in their first name, return a bar chart about the distribution of job_id and the sum of employee_id , and group by attribute job_id, and list in asc by the JOB_ID. ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the average of manager_id over the job_id , and group by attribute job_id, and could you rank X-axis from high to low order? ### Response:
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: WHAT CANDIDATE HAD A MARGIN OF ERROR OF 4.5%, WHEN PAT TOOMEY WAS 45% AND JOE SESTAK WAS 38%? ### Response:
SELECT "Other" FROM table_50753 WHERE "Margin of error" = '± 4.5%' AND "Pat Toomey (R)" = '45%' AND "Joe Sestak (D)" = '38%'
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the average of salary over the job_id , and group by attribute job_id by a bar chart, and rank by the Y-axis in asc. ### Response:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY AVG(SALARY)
### Instruction: Find all members of 'Bootup Baltimore' whose major is '600'. Show the first name and last name. ### Response:
SELECT t3.fname, t3.lname FROM club AS t1 JOIN member_of_club AS t2 ON t1.clubid = t2.clubid JOIN student AS t3 ON t2.stuid = t3.stuid WHERE t1.clubname = "Bootup Baltimore" AND t3.major = "600"
### Instruction: How many students are in each department? Show me a bar chart, and rank by the X-axis from high to low. ### Response:
SELECT T1.dept_name, COUNT(DISTINCT T2.ID) FROM department AS T1 JOIN student AS T2 ON T1.dept_name = T2.dept_name JOIN instructor AS T3 ON T1.dept_name = T3.dept_name ORDER BY T1.dept_name DESC
### Instruction: Display a bar chart for what are the names and ids of the tourist attractions that are visited at most once?, rank in asc by the y-axis. ### Response:
SELECT T1.Name, T1.Tourist_Attraction_ID FROM Tourist_Attractions AS T1 JOIN Visits AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID ORDER BY T1.Tourist_Attraction_ID
### Instruction: what is the number of patients whose admission location is phys referral/normal deli and procedure icd9 code is 9955? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND procedures.icd9_code = "9955"
### Instruction: what were the top three most common procedures until 4 years ago? ### Response:
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
### Instruction: find the number of patients with dehydration diagnoses who were discharged to psychiatric facility-partial hospitalization. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "DISCH-TRAN TO PSYCH HOSP" AND diagnoses.long_title = "Dehydration"
### Instruction: Out of the total number of patients admitted before 2154, caluclate the number of those who had urinary incontinence nos. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2154" AND diagnoses.short_title = "Urinary incontinence NOS"
### Instruction: retrieve the top three most common diagnostics until 2102? ### Response:
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE STRFTIME('%y', diagnosis.diagnosistime) <= '2102' GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 3
### Instruction: Comments as answers via disclaimer. ### Response:
SELECT P.Id AS "post_link", P.Score, P.Body FROM Posts AS P WHERE P.Body LIKE '%comment%' AND (P.Body LIKE '% rep %' OR P.Body LIKE '%points%') AND P.PostTypeId = 2 AND LEN(P.Body) <= 500 AND P.CreationDate > DATEADD(month, -6, CURRENT_TIMESTAMP())
### Instruction: what are the five most frequently prescribed medicines since 4 years ago? ### Response:
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-4 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
### Instruction: how many patients with ventricular fibrillation had a lab test for pleural fluid? ### 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 = "Ventricular fibrillation" AND lab.fluid = "Pleural"
### Instruction: provide the number of patients whose days of hospital stay is greater than 2 and procedure long title is ventriculopuncture through previously implanted catheter? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "2" AND procedures.long_title = "Ventriculopuncture through previously implanted catheter"
### Instruction: How many faculty lines are there in the university that conferred the least number of degrees in year 2001? ### Response:
SELECT T2.faculty FROM campuses AS T1 JOIN faculty AS T2 ON T1.id = t2.campus JOIN degrees AS T3 ON T1.id = t3.campus AND t2.year = t3.year WHERE t2.year = 2001 ORDER BY t3.degrees LIMIT 1
### Instruction: has any microbiology test been performed on patient 76637 until 02/2102? ### Response:
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 76637) AND STRFTIME('%y-%m', microbiologyevents.charttime) <= '2102-02'
### Instruction: For all employees who have the letters D or S in their first name, draw a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, and I want to list by the bar from low to high. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: For all employees who have the letters D or S in their first name, give me the comparison about the amount of job_id over the job_id , and group by attribute job_id, and show from high to low by the y axis please. ### Response:
SELECT JOB_ID, COUNT(JOB_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY COUNT(JOB_ID) DESC
### Instruction: which has a limiting magnitude higher than coast visible , chara array or coast infrared ? ### Response:
SELECT "interferometer and observing mode" FROM table_203_279 WHERE "limiting magnitude" > (SELECT "limiting magnitude" FROM table_203_279 WHERE "interferometer and observing mode" = 'coast visible') AND "interferometer and observing mode" IN ('chara array', 'coast infrared')
### Instruction: Find images not on imgur by active date. Finds all posts that have embedded images, but do not contain 'imgur.com'. Useful for finding old posts with images that may need uploading to imgur or are already broken. Sorted by last activity because of the Archaeologist badge. ### Response:
SELECT Score, Id AS "post_link" FROM Posts AS Q WHERE Body LIKE '%<img src%' AND NOT Body LIKE '%imgur.com/%' ORDER BY LastActivityDate DESC