instruction
stringlengths
37
754
output
stringlengths
9
3.43k
### 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: Which Partial thromboplastin time has a Prothrombin time of prolonged, and a Bleeding time of unaffected, and a Condition of vitamin k deficiency or warfarin? Question 6 ### Response:
SELECT partial_thromboplastin_time FROM table_name_1 WHERE prothrombin_time = "prolonged" AND bleeding_time = "unaffected" AND condition = "vitamin k deficiency or warfarin"
### 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: count the number of patients whose diagnoses icd9 code is 5768 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 = "5768" AND lab.flag = "abnormal"
### Instruction: mv traff acc-anim rider what does it stand for? ### Response:
SELECT d_icd_diagnoses.long_title FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'mv traff acc-anim rider' UNION SELECT d_icd_procedures.long_title FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'mv traff acc-anim rider'
### 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 me the number of single liveborn, born in hospital, delivered without mention of cesarean section patients who were admitted in hospital before the year 2174. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2174" AND diagnoses.short_title = "Single lb in-hosp w/o cs"
### 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: Count the number of patients on base type drug prescription who have hispanic or latino-puerto rican ethnic background. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN" AND prescriptions.drug_type = "BASE"
### 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: keyphrases used by Luke S Zettlemoyer for each year ### Response:
SELECT DISTINCT paperkeyphrase.keyphraseid, paper.year FROM author, paper, paperkeyphrase, writes WHERE author.authorname = 'Luke S Zettlemoyer' AND paper.paperid = paperkeyphrase.paperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid ORDER BY paper.year, paperkeyphrase.keyphraseid
### 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: when did patient 025-37141 come into the hospital for the last time in 2103 via the floor? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '025-37141' AND patient.hospitaladmitsource = 'floor' AND STRFTIME('%y', patient.hospitaladmittime) = '2103' ORDER BY patient.hospitaladmittime DESC LIMIT 1
### 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: Posts recently migrated from MathOverflow to Mathematics Stack Exchange. ### Response:
SELECT PostHistory.PostId AS "post_link", Posts.CreationDate AS "Asked on", PostHistory.CreationDate AS "Migrated on" FROM PostHistory JOIN Posts ON PostHistory.PostId = Posts.Id WHERE PostHistory.PostHistoryTypeId = 35 AND PostHistory.Comment LIKE '%math.stackexchange.com%' ORDER BY PostHistory.CreationDate DESC LIMIT 50
### 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: count the number of patients whose diagnoses short title is norml pressure hydroceph and lab test fluid is urine? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.short_title = "Norml pressure hydroceph" AND lab.fluid = "Urine"
### Instruction: provide the number of patients whose procedure icd9 code is 4610 and drug type is main? ### 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 = "4610" AND prescriptions.drug_type = "MAIN"
### Instruction: what is the number of patients whose insurance is medicare and primary disease is aortic insufficiency\re-do sternotomy; aortic valve replacement ? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.insurance = "Medicare" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
### Instruction: give me the number of patients whose admission location is phys referral/normal deli and drug name is glycerin (ped)? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND prescriptions.drug = "Glycerin (Ped)"
### Instruction: count the number of patients whose diagnoses icd9 code is 25002 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 = "25002" AND lab.flag = "delta"
### Instruction: how many patients diagnosed with short title cellulitis of hand have been prescribed main drug type? ### 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 = "Cellulitis of hand" AND prescriptions.drug_type = "MAIN"
### Instruction: when was patient 025-42426 given a procedure for the last time? ### Response:
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-42426')) ORDER BY treatment.treatmenttime DESC LIMIT 1
### Instruction: old good posts with absent authors. ### Response:
SELECT Id AS "post_link" FROM Posts AS p WHERE PostTypeId = 2 AND CommunityOwnedDate IS NULL AND Score > 0 AND LastEditDate < (SELECT MAX(CreationDate) FROM Comments WHERE PostId = p.Id) AND (SELECT LastAccessDate FROM Users WHERE Id = p.OwnerUserId) < (SELECT MAX(CreationDate) FROM Comments WHERE PostId = p.Id) ORDER BY Score DESC
### 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: show me all flights from BOSTON to DFW ### Response:
SELECT DISTINCT flight.flight_id FROM airport, airport_service, city, flight WHERE airport.airport_code = 'DFW' AND city.city_code = airport_service.city_code AND city.city_name = 'BOSTON' AND flight.from_airport = airport_service.airport_code AND flight.to_airport = airport.airport_code
### 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: provide the nuber of patients whose admission year is before 2184 and diagnosis long title is thrombocytopenia, unspecified. ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2184" AND diagnoses.long_title = "Thrombocytopenia, unspecified"
### Instruction: what is the number of patients whose admission location is emergency room admit and procedure short title is coronar arteriogr-1 cath? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_location = "EMERGENCY ROOM ADMIT" AND procedures.short_title = "Coronar arteriogr-1 cath"
### Instruction: Title of Posts and Acceptance. ### Response:
SELECT p.AcceptedAnswerId, p.Id, p.Title, tg.TagName FROM Posts AS p WITH (nolock) INNER JOIN PostTypes AS pt WITH (nolock) ON pt.Id = p.PostTypeId INNER JOIN PostTags AS ptg WITH (nolock) ON ptg.PostId = p.Id INNER JOIN Tags AS tg WITH (nolock) ON ptg.PostId = tg.Id
### Instruction: how many patients whose diagnoses long title is paralytic ileus and drug route is im? ### 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 = "Paralytic ileus" AND prescriptions.route = "IM"
### Instruction: A bar chart for finding the number of the the date of enrollment of the 'Spanish' course, list by the total number in desc. ### 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: View and Answer count for Habib. ### Response:
SELECT DISTINCT (p1.Id) AS "Answer Id", p2.ViewCount FROM Posts AS p1 JOIN Posts AS p2 ON p1.ParentId = p2.Id WHERE p1.OwnerUserId = 961113 AND (p1.LastEditDate >= '2016-04-01' OR p1.CreationDate > '2016-04-01')
### Instruction: Show the ids and details of the investors who have at least two transactions with type code 'SALE'. ### Response:
SELECT T2.investor_id, T1.Investor_details FROM INVESTORS AS T1 JOIN TRANSACTIONS AS T2 ON T1.investor_id = T2.investor_id WHERE T2.transaction_type_code = "SALE" GROUP BY T2.investor_id HAVING COUNT(*) >= 2
### Instruction: count the number of patients whose admission location is clinic referral/premature and diagnoses icd9 code is 1550? ### 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 = "1550"
### Instruction: Who is favorizing you or bountied your question. ### Response:
SELECT Votes.CreationDate, VoteTypes.Name, Votes.UserId AS "user_link", Posts.Id AS "post_link" FROM Votes LEFT JOIN VoteTypes ON Votes.VoteTypeId = VoteTypes.Id LEFT JOIN Posts ON Votes.PostId = Posts.Id WHERE NOT Votes.UserId IS NULL AND Posts.OwnerUserId = '##UserId##'
### 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 employee_id , and group by attribute job_id, and show bars from high to low order please. ### Response:
SELECT JOB_ID, SUM(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
### Instruction: provide the number of patients whose diagnoses short title is wheelchair dependence 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 = "Wheelchair dependence" AND prescriptions.drug_type = "MAIN"
### Instruction: Count the number of patients who had blood tests done and undergone the procedure angiocardiography of right heart structures. ### 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 = "Angiocardiography of right heart structures" AND lab.fluid = "Blood"
### Instruction: give me the number of patients on dwell route of drug administration who have primary apnea of newborn. ### 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 = "Primary apnea of newborn" AND prescriptions.route = "DWELL"
### Instruction: What is the most noteworthy 2006 that has 2008 littler than 5,330, and a Country of Peru, and 2009 littler than 1,260? ### Response:
SELECT MAX("2006") FROM table_50455 WHERE "2008" < '5,330' AND "Country" = 'peru' AND "2009" < '1,260'
### Instruction: diagnosed with type ii diabetes defined as a glycohemoglobin between 7.5 % and 10.5 % , and fasting insulin level < 40 ( iu / ml ) . ### Response:
SELECT * FROM table_dev_24 WHERE diabetic = 'ii' OR (glycohemoglobin >= 7.5 AND glycohemoglobin <= 10.5 AND fasting_insulin < 40)
### Instruction: For those employees who did not have any job in the past, return a bar chart about the distribution of job_id and the sum of manager_id , and group by attribute job_id, show in ascending by the y-axis please. ### Response:
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY SUM(MANAGER_ID)
### Instruction: how many patients were tested since 3 years ago for sputum, expectorated? ### Response:
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT microlab.patientunitstayid FROM microlab WHERE microlab.culturesite = 'sputum, expectorated' AND DATETIME(microlab.culturetakentime) >= DATETIME(CURRENT_TIME(), '-3 year'))
### Instruction: List the number of enginners and group by last name in a bar chart, and sort in desc by the y axis. ### 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 last_name ORDER BY COUNT(last_name) 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 salary , and sort from low to high by the Y. ### Response:
SELECT FIRST_NAME, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SALARY
### Instruction: what was the three most common diagnosis since 6 years ago? ### Response:
SELECT t1.diagnosisname FROM (SELECT diagnosis.diagnosisname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM diagnosis WHERE DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-6 year') GROUP BY diagnosis.diagnosisname) AS t1 WHERE t1.c1 <= 3
### Instruction: What is the lowest played 2 number with less than 83 losses and less than 65 draws with Chernomorets Novorossiysk in season 8? ### Response:
SELECT MIN("Played 2") FROM table_53854 WHERE "Lost" > '83' AND "Seasons" = '8' AND "Club 1" = 'chernomorets novorossiysk' AND "Drawn" < '65'
### Instruction: average score of popular questions. prints the average score and view count of questions that have been awarded the popular question badge but not the notable question badge (between 1000 and 2500 views) ### Response:
SELECT AVG(Score + 0.0) AS "average score", AVG(ViewCount + 0.0) AS "average view count" FROM Posts WHERE ParentId IS NULL AND ViewCount >= 1000 AND ViewCount < 2500
### Instruction: For those employees who do not work in departments with managers that have ids between 100 and 200, give me the comparison about salary over the first_name , order by the y-axis in descending. ### Response:
SELECT FIRST_NAME, SALARY FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SALARY DESC
### Instruction: provide the number of patients whose diagnoses short title is anxiety state nos and drug route is oral? ### 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 = "Anxiety state NOS" AND prescriptions.route = "ORAL"
### Instruction: when did patient 11322 get a lab test for the first time since 111 months ago? ### Response:
SELECT labevents.charttime FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 11322) AND DATETIME(labevents.charttime) >= DATETIME(CURRENT_TIME(), '-111 month') ORDER BY labevents.charttime LIMIT 1
### Instruction: What is the number of patients who were transfered to a cancer/chlidren hospital who had icd9 code 8604? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "DISC-TRAN CANCER/CHLDRN H" AND procedures.icd9_code = "8604"
### Instruction: For those employees who was hired before 2002-06-21, give me the comparison about the sum of employee_id over the hire_date bin hire_date by time, and order by the sum employee id in descending. ### Response:
SELECT HIRE_DATE, SUM(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY SUM(EMPLOYEE_ID) 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, what is the relationship between employee_id and salary ? ### Response:
SELECT EMPLOYEE_ID, SALARY FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
### Instruction: which UA flights go through DENVER ### Response:
SELECT DISTINCT flight.flight_id FROM airport_service, city, flight, flight_stop WHERE city.city_code = airport_service.city_code AND city.city_name = 'DENVER' AND flight_stop.stop_airport = airport_service.airport_code AND flight.airline_code = 'UA' AND flight.flight_id = flight_stop.flight_id
### Instruction: What 's the number of DESCI classes being offered next semester ? ### Response:
SELECT COUNT(DISTINCT course_offering.course_id) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'DESCI' AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
### Instruction: For those employees who did not have any job in the past, draw a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by time, display by the Y-axis in desc. ### 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's the sum of Gold with a Bronze that's larger than 15, Silver that's smaller than 197, the Nation of Saint Lucia, and has a Total that is larger than 50? ### Response:
SELECT SUM("Gold") FROM table_79484 WHERE "Bronze" > '15' AND "Silver" < '197' AND "Nation" = 'saint lucia' AND "Total" > '50'
### Instruction: how many patients are admitted under urgent type and procedured with endoscopic insertion of stent (tube) into bile duct? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "URGENT" AND procedures.long_title = "Endoscopic insertion of stent (tube) into bile duct"
### Instruction: how many patients' primary disease is hypertension but not coronary artery disease/cardiac cath and their year of death is in or before 2115? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "HYPERTENSION;RULE OUT CORONARY ARTERY DISEASE\CARDIAC CATH" AND demographic.dod_year <= "2115.0"
### Instruction: Show the dates of performances with attending members whose roles are 'Violin', and count them by a bar chart, sort in descending by the X please. ### Response:
SELECT Date, COUNT(Date) FROM member_attendance AS T1 JOIN member AS T2 ON T1.Member_ID = T2.Member_ID JOIN performance AS T3 ON T1.Performance_ID = T3.Performance_ID WHERE T2.Role = "Violin" GROUP BY Date ORDER BY Date DESC
### Instruction: provide the number of patient with replaced route of drug administration who have procedure icd9 code 8105. ### 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 = "8105" AND prescriptions.route = "REPLACE"
### Instruction: What is the Original Beechwood Bunny Tale/Source material that has an Official # larger than 38, and a TF1 # larger than 50, and an English title of 'sweet fabiola'? ### Response:
SELECT "Original Beechwood Bunny Tale / Source material" FROM table_43549 WHERE "Official #" > '38' AND "TF1 #" > '50' AND "English title" = 'sweet fabiola'
### Instruction: HOW MUCH IS THE PERCENTAGE OF GLOBAL TOTAL EMISSIONS IN THE COUNTRY THAT PRODUCED 4.9 TONS PER PERSON IN 2007? ### Response:
SELECT percentage_of_global_total FROM table_11251601_2 WHERE carbon_dioxide_emissions_per_year__tons_per_person___2007_ = "4.9"
### Instruction: For those employees who did not have any job in the past, find hire_date and the sum of manager_id bin hire_date by weekday, and visualize them by a bar chart, and rank by the total number of manager id in asc please. ### 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)
### 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 average of department_id , and group by attribute job_id, display by the total number in asc. ### 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)
### Instruction: how many patients having diagnosis icd9 code 7756 have blood gas lab test category? ### 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 = "7756" AND lab."CATEGORY" = "Blood Gas"
### Instruction: provide the number of patients whose primary disease is left internal jugular vein thrombosis;left arm edema and year of death is less than or equal to 2183? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "LEFT INTERNAL JUGULAR VEIN THROMBOSIS;LEFT ARM EDEMA" AND demographic.dod_year <= "2183.0"
### Instruction: how many patients have procedure icd9 code 4105 and 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 = "4105" AND prescriptions.drug_type = "MAIN"
### Instruction: Find names of trains that run through stations for the local authority Chiltern, compare the total number of name in a bar graph, and display by the Y from high to low. ### Response:
SELECT name, COUNT(name) FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id JOIN train AS t3 ON t2.train_id = t3.id WHERE t1.local_authority = "Chiltern" GROUP BY name ORDER BY COUNT(name) DESC
### Instruction: How many patients who were diagnosed under icd9 code 481 have pb as drug 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.icd9_code = "481" AND prescriptions.route = "PB"
### Instruction: what is the number of patients whose primary disease is coronary artery disease\coronary artery bypass graft /sda and year of birth is less than 2071? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT /SDA" AND demographic.dob_year < "2071"
### Instruction: when was the last hospital visit since 2 years ago that patient 035-4428 was admitted via floor? ### Response:
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '035-4428' AND patient.hospitaladmitsource = 'floor' AND DATETIME(patient.hospitaladmittime) >= DATETIME(CURRENT_TIME(), '-2 year') ORDER BY patient.hospitaladmittime DESC LIMIT 1
### Instruction: how many patients whose marital status is single and diagnoses long title is hemochromatosis due to repeated red blood cell transfusions? ### Response:
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.marital_status = "SINGLE" AND diagnoses.long_title = "Hemochromatosis due to repeated red blood cell transfusions"
### Instruction: how many patients are diagnosed with icd9 code 43820 and lab tested with 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.icd9_code = "43820" AND lab.fluid = "Pleural"
### Instruction: how many patients whose diagnoses short title is pure hyperglyceridemia 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 = "Pure hyperglyceridemia" AND lab.fluid = "Pleural"