instruction
stringlengths
53
549
output
stringlengths
30
2.33k
### Instruction: For those employees who was hired before 2002-06-21, show me about the distribution of hire_date and the average of manager_id bin hire_date by time in a bar chart, and sort by the total number in desc please. ### Response:
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(MANAGER_ID) DESC
### Instruction: how many patients used the drug code lido5t and tested with joint fluid 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 = "LIDO5T" AND lab.fluid = "Joint Fluid"
### Instruction: When Alberto Contador Kanstantsin Sivtsov was the general classification and Alessandro Petacchi was the points classification at the same time while Mark Cavendish is the winner, who was the mountain classification? ### Response:
SELECT mountains_classification FROM table_28538368_2 WHERE general_classification = "Alberto Contador Kanstantsin Sivtsov" AND points_classification = "Alessandro Petacchi" AND winner = "Mark Cavendish"
### Instruction: what did patient 027-178495 receive for his or her first procedure? ### Response:
SELECT treatment.treatmentname FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '027-178495')) ORDER BY treatment.treatmenttime LIMIT 1
### Instruction: For those records from the products and each product's manufacturer, a bar chart shows the distribution of headquarter and the average of code , and group by attribute headquarter, and I want to rank from high to low by the Headquarter. ### 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 T2.Headquarter DESC
### 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 manager_id , and group by attribute job_id, could you rank total number of manager id in ascending order please? ### Response:
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' GROUP BY JOB_ID ORDER BY SUM(MANAGER_ID)
### Instruction: what is the number of patients whose diagnoses short title is hyperpotassemia 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 = "Hyperpotassemia" AND prescriptions.drug_type = "MAIN"
### Instruction: For those employees who did not have any job in the past, give me the comparison about the amount of job_id over the job_id , and group by attribute job_id by a bar chart, and list how many job id from low to high order. ### Response:
SELECT JOB_ID, COUNT(JOB_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY COUNT(JOB_ID)
### Instruction: when was the last time for patient 49036 procedure when they visited the hospital last time? ### Response:
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 49036 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY procedures_icd.charttime DESC LIMIT 1
### Instruction: let me know the number of patients admitted before 2115 who had injection or infusion of oxazolidinone class of antibiotics. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2115" AND procedures.long_title = "Injection or infusion of oxazolidinone class of antibiotics"
### Instruction: provide the number of patients whose procedure icd9 code is 4576 and drug route is iv bolus ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "4576" AND prescriptions.route = "IV BOLUS"
### Instruction: What volume number has the ISBN of 978-1-59582-712-8 (hc) 978-1-59582-713-5 (tpb)? ### Response:
SELECT volume FROM table_name_38 WHERE isbn = "978-1-59582-712-8 (hc) 978-1-59582-713-5 (tpb)"
### Instruction: how many patients with american indian/alaska native ethnicity have undergone the procedure closed bx skin/subq tiss? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND procedures.short_title = "Closed bx skin/subq tiss"
### Instruction: A bar chart for finding the number of the the date of enrollment of the 'Spanish' course, and sort Y-axis in asc order please. ### Response:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "Spanish" ORDER BY COUNT(date_of_enrolment)
### Instruction: provide the number of patients whose diagnosis icd9 code is v1272 and lab test fluid is ascites. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "V1272" AND lab.fluid = "Ascites"
### Instruction: Number of questions closed by close vote count.. Sceptics questions closed, by number of close votes. Useful to identify moderator-closed questions. ### Response:
SELECT 'close_votes', COUNT(*) FROM (SELECT COUNT(*) AS "close_votes" FROM Posts INNER JOIN Votes ON Posts.Id = Votes.PostId WHERE Votes.VoteTypeId = 6 AND NOT Posts.ClosedDate IS NULL GROUP BY Posts.Id) AS X GROUP BY 'close_votes'
### Instruction: return me the number of papers by ' H. V. Jagadish ' on VLDB conference after 2000 . ### Response:
SELECT COUNT(DISTINCT (publication.title)) FROM author, conference, publication, writes WHERE author.name = 'H. V. Jagadish' AND conference.name = 'VLDB' AND publication.cid = conference.cid AND publication.year > 2000 AND writes.aid = author.aid AND writes.pid = publication.pid
### Instruction: how many patients with residual foreign body in soft tissue had a lab test for 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.long_title = "Residual foreign body in soft tissue" AND lab."CATEGORY" = "Blood Gas"
### Instruction: What is the total number in the 1920s that has 0 in the 1960s, and less than 4 in the 2000s, and more than 3 in the 1930s? ### Response:
SELECT COUNT("1920s") FROM table_7584 WHERE "1960s" = '0' AND "2000s to date" < '4' AND "1930s" > '3'
### Instruction: give me the number of patients whose admission year is less than 2155 and diagnoses long title is other specified gastritis, with hemorrhage? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2155" AND diagnoses.long_title = "Other specified gastritis, with hemorrhage"
### Instruction: among patients diagnosed with critical illness myopthy, how many of them received drug via id route? ### 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 = "Critical illness myopthy" AND prescriptions.route = "ID"
### Instruction: how many of the patients with urin tract infection nos received additive therapy? ### 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 = "Urin tract infection NOS" AND prescriptions.drug_type = "ADDITIVE"
### Instruction: how many patients whose diagnoses icd9 code is 56212 and drug route is ed? ### 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 = "56212" AND prescriptions.route = "ED"
### Instruction: Last 3 months unanswered questions. ### Response:
SELECT * FROM Posts INNER JOIN Users ON Users.Id = OwnerUserId WHERE Posts.PostTypeId = 1 AND Posts.CreationDate BETWEEN DATEADD(MONTH, -3, CURRENT_TIMESTAMP()) AND CURRENT_TIMESTAMP() AND AcceptedAnswerId IS NULL AND AnswerCount = 0 AND Score > -1 AND CommentCount = 0 AND Users.Reputation > 100
### Instruction: What is the highest 2007 value with a 1985 value greater than 52, a 1987 value greater than 130, and a 1990 less than 1990? ### Response:
SELECT MAX("2007") FROM table_40320 WHERE "1985" > '52' AND "1987" > '130' AND "1990" < '1990'
### Instruction: For those employees who was hired before 2002-06-21, find hire_date and the amount of hire_date bin hire_date by time, and visualize them by a bar chart, sort by the how many hire date in descending please. ### Response:
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY COUNT(HIRE_DATE) DESC
### Instruction: provide the number of patients whose procedure long title is other partial resection of small intestine and lab test fluid is pleural? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE procedures.long_title = "Other partial resection of small intestine" AND lab.fluid = "Pleural"
### Instruction: What is the number of Jianshu when the total is more than 19.16, for Nguyen Huy Thanh ( vie ), and Qiangshu is more than 9.66? ### Response:
SELECT COUNT("Jianshu") FROM table_12362 WHERE "Total" > '19.16' AND "Athlete" = 'nguyen huy thanh ( vie )' AND "Qiangshu" > '9.66'
### Instruction: Which film is rented at a fee of 0.99 and has less than 3 in the inventory? List the film title and id. ### Response:
SELECT title, film_id FROM film WHERE rental_rate = 0.99 INTERSECT SELECT T1.title, T1.film_id FROM film AS T1 JOIN inventory AS T2 ON T1.film_id = T2.film_id GROUP BY T1.film_id HAVING COUNT(*) < 3
### Instruction: Which Multi 1 has a Frequency of 2300mhz, and a Release date of q3 2008 and a Model number of turion x2 ultra zm-84? ### Response:
SELECT "Multi 1" FROM table_7400 WHERE "Frequency" = '2300mhz' AND "Release date" = 'q3 2008' AND "Model number" = 'turion x2 ultra zm-84'
### Instruction: what was patient 13536's last ward identification on their first hospital encounter? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 13536 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime LIMIT 1) AND NOT transfers.wardid IS NULL ORDER BY transfers.intime DESC LIMIT 1
### Instruction: provide the number of patients categorized under hematology lab test who were diagnosed with hip pressure ulcer. ### 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 = "Pressure ulcer, hip" AND lab."CATEGORY" = "Hematology"
### Instruction: when was the first time that patient 31854 was prescribed medication via an pb route in their current hospital encounter? ### Response:
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 31854 AND admissions.dischtime IS NULL) AND prescriptions.route = 'pb' ORDER BY prescriptions.startdate LIMIT 1
### Instruction: For all employees who have the letters D or S in their first name, draw a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by time, could you order in ascending by the y-axis? ### Response:
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(EMPLOYEE_ID)
### Instruction: Which channels broadcast both in the morning and at night? Give me the channel names. ### Response:
SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Morning' INTERSECT SELECT t1.name FROM channel AS t1 JOIN broadcast AS t2 ON t1.channel_id = t2.channel_id WHERE t2.time_of_day = 'Night'
### Instruction: what is the declination (j2000) that has a constellation of hydra and a right ascension (j2000) of 10h46m44.9s? ### Response:
SELECT "Declination ( J2000 )" FROM table_55074 WHERE "Constellation" = 'hydra' AND "Right ascension ( J2000 )" = '10h46m44.9s'
### Instruction: A bar chart for what are the number of the first names of all students in Smith Hall?, and rank by the total number in desc. ### Response:
SELECT Fname, COUNT(Fname) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' GROUP BY Fname ORDER BY COUNT(Fname) DESC
### Instruction: what is the number of patients whose admission location is clinic referral/premature and procedure short title is endosc retro cholangiopa? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND procedures.short_title = "Endosc retro cholangiopa"
### Instruction: provide the number of patients with a diagnoses of personal history of other malignant neoplasm of rectum, rectosigmoid junction and anus and are still alive. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.expire_flag = "0" AND diagnoses.short_title = "Hx-rectal & anal malign"
### Instruction: give me the number of patients with diagnoses icd9 code 34590 who had abnormal lab test status. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "34590" AND lab.flag = "abnormal"
### Instruction: For those employees who was hired before 2002-06-21, find job_id and the average of salary , and group by attribute job_id, and visualize them by a bar chart, I want to list in ascending by the X-axis. ### Response:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: what is the unabbreviated version of the necator americanus? ### Response:
SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'necator americanus' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'necator americanus'
### Instruction: count the number of patients who have diagnoses icd9 code 45182 along with abnormal lab test status. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "45182" AND lab.flag = "abnormal"
### Instruction: Show my answers to R tag. Show my answers to R tag ### Response:
SELECT a.Score, a.Body, q.Tags, q.Title FROM Posts AS q INNER JOIN Posts AS a ON q.Id = a.ParentId AND a.PostTypeId = 2 AND q.PostTypeId = 1 WHERE a.CommunityOwnedDate IS NULL AND a.OwnerUserId = '##UserId##' AND q.Tags LIKE '%<r>%' ORDER BY a.Score DESC
### Instruction: List the hardware model name for the phones that have screen mode type 'Text' or RAM size greater than 32. ### Response:
SELECT T2.Hardware_Model_name FROM chip_model AS T1 JOIN phone AS T2 ON T1.Model_name = T2.chip_model JOIN screen_mode AS T3 ON T2.screen_mode = T3.Graphics_mode WHERE T3.Type = "Text" OR T1.RAM_MiB > 32
### Instruction: Find the number of the the date of enrollment of the 'Spanish' course, I want to show in desc by the y-axis. ### Response:
SELECT date_of_enrolment, COUNT(date_of_enrolment) FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id WHERE T1.course_name = "Spanish" ORDER BY COUNT(date_of_enrolment) DESC
### Instruction: provide the number of patients whose drug code is vitb1 and lab test fluid is pleural? ### 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 = "VITB1" AND lab.fluid = "Pleural"
### Instruction: have terazosin ever been prescribed to patient 16572 until 2100? ### Response:
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16572) AND prescriptions.drug = 'terazosin' AND STRFTIME('%y', prescriptions.startdate) <= '2100'
### Instruction: What is the position for the player from the Alba Berlin club who is taller than 1.96 and whose ear born (Age) is july 23, 1985 (age28)? ### Response:
SELECT "Position" FROM table_12125 WHERE "Current Club" = 'alba berlin' AND "Height" > '1.96' AND "Year born (Age)" = 'july 23, 1985 (age28)'
### Instruction: provide the number of patients whose diagnoses icd9 code is 4928 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.icd9_code = "4928" AND lab.flag = "abnormal"
### Instruction: Find the number of the name of the project for which a scientist whose name contains Smith is assigned to, display X-axis from low to high 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
### Instruction: how many patients whose diagnoses short title is perforation of intestine 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 = "Perforation of intestine" AND prescriptions.route = "SL"
### Instruction: what was patient 12568's first ward identification since 2100? ### Response:
SELECT transfers.wardid FROM transfers WHERE transfers.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 12568) AND NOT transfers.wardid IS NULL AND STRFTIME('%y', transfers.intime) >= '2100' ORDER BY transfers.intime LIMIT 1
### Instruction: What is the total 2008 value with a 2006 value greater than 322.7, a 353.9 in 2011, and a 2009 less than 392? ### Response:
SELECT COUNT(2008) FROM table_name_53 WHERE 2006 > 322.7 AND 2011 = 353.9 AND 2009 < 392
### Instruction: what is the number of patients with procedure icd9 code 3897 and drug route buccal? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "3897" AND prescriptions.route = "BUCCAL"
### Instruction: provide the number of patients whose diagnoses icd9 code is 78820 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.icd9_code = "78820" AND lab.flag = "delta"
### Instruction: return me the author who has the most number of papers containing keyword ' Relational Database ' . ### Response:
SELECT author.name FROM author, keyword, publication, publication_keyword, writes WHERE keyword.keyword = 'Relational Database' AND publication_keyword.kid = keyword.kid AND publication.pid = publication_keyword.pid AND writes.aid = author.aid AND writes.pid = publication.pid GROUP BY author.name ORDER BY COUNT(DISTINCT (publication.title)) DESC LIMIT 1
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of hire_date and the average of department_id bin hire_date by weekday, I want to order y axis in ascending order. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(DEPARTMENT_ID)
### Instruction: Pending suggested edits on a single site. ### Response:
SELECT 'site://suggested-edits/' + CAST(se.Id AS TEXT), se.OwnerUserId AS "user_link", se.CreationDate, se.PostId AS "post_link" FROM SuggestedEdits AS se WHERE se.OwnerUserId = '##UserId:int##' AND se.ApprovalDate IS NULL AND se.RejectionDate IS NULL ORDER BY se.CreationDate DESC
### Instruction: What is the average age for each dorm and what are the names of each dorm Plot them as bar chart, and list names from low to high order. ### Response:
SELECT dorm_name, AVG(T1.Age) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name ORDER BY dorm_name
### Instruction: how many patients whose procedure icd9 code is 8968 have been prescribed main drug type? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE procedures.icd9_code = "8968" AND prescriptions.drug_type = "MAIN"
### Instruction: give the number of patients under diagnosed under icd9 code 2764 and had lab test abnomal 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.icd9_code = "2764" AND lab.flag = "delta"
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about department_id over the email , could you list Y in descending order? ### Response:
SELECT EMAIL, 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 patients with blood gas lab test category had persistent postoperative fistula diagnoses? ### 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 = "Persistent postoperative fistula" AND lab."CATEGORY" = "Blood Gas"
### Instruction: Average Flags Count based on Comments Count on Question. ### Response:
SELECT p.CommentCount, COUNT(*) AS rCount, COUNT(DISTINCT p.Id) AS pCount, CAST(COUNT(*) AS FLOAT) / CAST(COUNT(DISTINCT p.Id) AS FLOAT) AS AvgFlag FROM Posts AS p INNER JOIN ReviewTasks AS r ON r.PostId = p.Id WHERE p.PostTypeId = 1 GROUP BY CommentCount ORDER BY CommentCount
### Instruction: How many patients with a blood gas lab test category have diagnoses icd9 code v053? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "V053" AND lab."CATEGORY" = "Blood Gas"
### Instruction: give me the number of elective hospital admission patients who are diagnosed with other and unspecified open wound of head without mention of complication. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND diagnoses.long_title = "Other and unspecified open wound of head without mention of complication"
### 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 I want to list y axis from high to low order please. ### 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) DESC
### Instruction: For those employees who was hired before 2002-06-21, a bar chart shows the distribution of job_id and the average of department_id , and group by attribute job_id, I want to sort in asc by the X-axis. ### Response:
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: How many students taking a course who received an A or C? Group by students' last name with a bar chart. ### Response:
SELECT STU_LNAME, COUNT(STU_LNAME) FROM STUDENT AS T1 JOIN ENROLL AS T2 ON T1.STU_NUM = T2.STU_NUM WHERE T2.ENROLL_GRADE = 'C' OR T2.ENROLL_GRADE = 'A' GROUP BY STU_LNAME
### Instruction: In which season and which stadium did any player have an injury of 'Foot injury' or 'Knee problem'? ### Response:
SELECT T1.season, T2.name FROM game AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.id JOIN injury_accident AS T3 ON T1.id = T3.game_id WHERE T3.injury = 'Foot injury' OR T3.injury = 'Knee problem'
### 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, display JOB_ID in ascending order. ### Response:
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
### Instruction: provide the number of patients whose admission type is emergency and diagnoses is other pulmonary insufficiency, not elsewhere classfied. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND diagnoses.long_title = "Other pulmonary insufficiency, not elsewhere classified"
### Instruction: Which players won awards in both 1960 and 1961? Return their first names and last names. ### Response:
SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1960 INTERSECT SELECT T1.name_first, T1.name_last FROM player AS T1 JOIN player_award AS T2 WHERE T2.year = 1961
### Instruction: did the hall of fame player awarded the year after tony coton earn more goals than he did ? ### Response:
SELECT (SELECT "goals" FROM table_204_340 WHERE "year inducted" = (SELECT "year inducted" FROM table_204_340 WHERE "name" = 'tony coton') + 1) > (SELECT "goals" FROM table_204_340 WHERE "name" = 'tony coton')
### Instruction: How many states that have some college students playing in the mid position but not in the goalie position. ### Response:
SELECT COUNT(*) FROM (SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie')
### Instruction: For those employees who did not have any job in the past, find job_id and the average of salary , and group by attribute job_id, and visualize them by a bar chart, and sort from high to low by the Y. ### Response:
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY AVG(SALARY) DESC
### Instruction: For those employees who did not have any job in the past, give me the comparison about the sum of manager_id over the hire_date bin hire_date by time by a bar chart, I want to show y axis from high to low order. ### Response:
SELECT HIRE_DATE, SUM(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY SUM(MANAGER_ID) DESC
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, and order by the y-axis in desc. ### Response:
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(DEPARTMENT_ID) DESC
### Instruction: I want the sum of number of seasons in top division for position in 2012-13 of 009 9th and number of seasons in premier league less than 3 ### Response:
SELECT SUM(number_of_seasons_in_top_division) FROM table_name_48 WHERE position_in_2012_13 = "009 9th" AND number_of_seasons_in_the_premier_league < 3
### Instruction: For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of job_id and the sum of salary , and group by attribute job_id, and I want to list Y from high to low order. ### Response:
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY SUM(SALARY) DESC
### Instruction: serious hepatorenal dysfunction [atl >= 5 uln ( upper limit of normal ) , cr > 134 umol / l ( 2 mg % ) or egfr < 45 ml / min / 1.73 m2]; ### Response:
SELECT * FROM table_test_14 WHERE renal_disease = 1 OR cr > 134 OR estimated_glomerular_filtration_rate_egfr < 45
### Instruction: give me the number of patients whose year of death is less than or equal to 2155 and diagnoses icd9 code is 43491? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dod_year <= "2155.0" AND diagnoses.icd9_code = "43491"
### Instruction: how many patients whose diagnoses short title is intestinal abscess 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 = "Intestinal abscess" AND prescriptions.drug_type = "MAIN"
### Instruction: give me the number of patients whose admission year is less than 2176 and diagnoses short title is late ef-hemplga side nos? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2176" AND diagnoses.short_title = "Late ef-hemplga side NOS"
### Instruction: keyphrases used by Magdalena Balazinska ### Response:
SELECT DISTINCT keyphrase.keyphraseid FROM author, keyphrase, paper, paperkeyphrase, writes WHERE author.authorname = 'Magdalena Balazinska' AND paperkeyphrase.keyphraseid = keyphrase.keyphraseid AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
### Instruction: what is the amount of patient 030-57574's hospital bill during their stay on their first hospital visit? ### Response:
SELECT SUM(cost.cost) FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-57574' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)
### Instruction: how many patients whose diagnoses icd9 code is 2767 and drug route is pr? ### 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 = "2767" AND prescriptions.route = "PR"
### Instruction: What is the highest Win #, when Winner is 'Knoxville Cherokees', when Playoff Result is 'Lost 1st Round ( LOU )', and when Points is less than 94? ### Response:
SELECT MAX("Win #") FROM table_76170 WHERE "Winner" = 'knoxville cherokees' AND "Playoff result" = 'lost 1st round ( lou )' AND "Points" < '94'
### Instruction: provide the number of patients whose death status is 0 and primary disease is aortic insufficiency/re-do sternotomy; aortic valve replacement. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.expire_flag = "0" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
### Instruction: How many students taking a course who received an A or C? Group by students' first name with a bar chart. ### Response:
SELECT STU_FNAME, COUNT(STU_FNAME) FROM STUDENT AS T1 JOIN ENROLL AS T2 ON T1.STU_NUM = T2.STU_NUM WHERE T2.ENROLL_GRADE = 'C' OR T2.ENROLL_GRADE = 'A' GROUP BY STU_FNAME
### Instruction: What is the Birthplace, when the Jersey # is less than 18, when the Height (cm) is higher than 185, and when the Birthdate is March 3, 1980? ### Response:
SELECT "Birthplace" FROM table_42275 WHERE "Jersey #" < '18' AND "Height (cm)" > '185' AND "Birthdate" = 'march 3, 1980'
### Instruction: What is the lowest 1988-89, when Points is greater than 130, when 1987-88 is '37', and when Played is less than 114? ### Response:
SELECT MIN("1988-89") FROM table_61250 WHERE "Points" > '130' AND "1987-88" = '37' AND "Played" < '114'
### Instruction: provide the number of patients whose diagnoses icd9 code is v452 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.icd9_code = "V452" AND lab.fluid = "Pleural"
### Instruction: how many patients who primarily diagnosed for coronary artery disease or coronary artery bypass graft /sda died in or before the year 2112? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT /SDA" AND demographic.dod_year <= "2112.0"
### Instruction: Downvoted answers of answerers own questions. ### Response:
SELECT a.Id AS "post_link", a.Score AS "score", a.CreationDate AS "date" FROM Posts AS a INNER JOIN Posts AS q ON a.ParentId = q.Id AND a.OwnerUserId = q.OwnerUserId WHERE a.PostTypeId = 2 AND a.Score < 0 AND a.Id != q.AcceptedAnswerId ORDER BY a.Score, a.CreationDate
### Instruction: What kind of Modern equivalent has a Post-1009 province of gyeongsang -do, and a Administrative district of jinju -mok, and a Province of Silla of gangju? ### Response:
SELECT "Modern equivalent" FROM table_7759 WHERE "Post-1009 province" = 'gyeongsang -do' AND "Administrative district" = 'jinju -mok' AND "Province of Silla" = 'gangju'
### Instruction: A bar chart for finding the number of the first name of students who are living in the Smith Hall, and show by the Fname in asc please. ### Response:
SELECT Fname, COUNT(Fname) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' GROUP BY Fname ORDER BY Fname
### Instruction: What is the lowest Postion, when Bike No is greater than 10, when Driver / Passenger is Nicky Pulinx / Ondrej Cermak, and when Points is greater than 244? ### Response:
SELECT MIN("Position") FROM table_48573 WHERE "Bike No" > '10' AND "Driver / Passenger" = 'nicky pulinx / ondrej cermak' AND "Points" > '244'
### Instruction: Get count of users with <10k and >=10k reputation points. ### Response:
SELECT u1."less_than_10k", u2."10k_or_more" FROM (SELECT COUNT(Id) AS "less_than_10k" FROM Users WHERE Reputation < 10000) AS u1, (SELECT COUNT(Id) AS "10k_or_more" FROM Users WHERE Reputation >= 10000) AS u2