instruction
stringlengths 37
754
| output
stringlengths 9
3.43k
|
---|---|
### Instruction:
out of the total number of patients diagnosed with icd9 code 42781, how many of them remained admitted in hospital for more than 13 days?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.days_stay > "13" AND diagnoses.icd9_code = "42781"
|
### Instruction:
Finding comments with specific keywords for specific user id.
### Response:
|
SELECT c.PostId AS "post_id", c.Id AS "comment_id", c.Id AS "comment_link", c.CreationDate AS "date_of_posting" FROM Users AS u INNER JOIN Comments AS c ON u.Id = c.UserId WHERE c.Text LIKE '%##Keyword##%' AND c.UserId = '##UserId##' ORDER BY c.CreationDate
|
### Instruction:
Find times of trains that run through stations for the local authority Chiltern, compare the total number of different times, I want to rank by the X from high to low.
### Response:
|
SELECT time, COUNT(time) 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 time ORDER BY time DESC
|
### Instruction:
Which match was the final score 7 6 (7 0) , 6 7 (5 7) , 4 6, 6 2, 6 7 (5 7)?
### Response:
|
SELECT "No." FROM table_3501 WHERE "Score in the final" = '7β6 (7β0) , 6β7 (5β7) , 4β6, 6β2, 6β7 (5β7)'
|
### Instruction:
when did patient 010-26737 enter for the last time in the hospital in this year?
### Response:
|
SELECT patient.hospitaladmittime FROM patient WHERE patient.uniquepid = '010-26737' AND DATETIME(patient.hospitaladmittime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') ORDER BY patient.hospitaladmittime DESC LIMIT 1
|
### Instruction:
What is the lowest code number for the remainder of the municipality that has an area bigger than 15.34 squared kilometers, a population greater than 762 and a language of xhosa spoken?
### Response:
|
SELECT MIN(code) FROM table_name_3 WHERE population > 762 AND most_spoken_language = "xhosa" AND area__km_2__ > 15.34 AND place = "remainder of the municipality"
|
### Instruction:
Posts edited by the user, excluding own posts.
### Response:
|
SELECT h.PostId AS "post_link", h.CreationDate AS "edit_date" FROM PostHistory AS h, Posts AS p WHERE h.UserId = '##UserID##' AND h.PostHistoryTypeId IN (4, 5, 6) AND p.Id = h.PostId AND p.OwnerUserId != '##UserID##' ORDER BY 'edit_date' DESC
|
### Instruction:
For all employees who have the letters D or S in their first name, a bar chart shows the distribution of job_id and the sum of employee_id , and group by attribute job_id, and sort x axis from high to low order please.
### 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 DESC
|
### Instruction:
Identifies tags without a tag wiki, or only a very short one (less than 35).. Identifies tags without a tag wiki, or only a very short one.
### Response:
|
SELECT t.TagName, p.Body FROM Posts AS p LEFT JOIN Tags AS t ON t.ExcerptPostId = p.Id WHERE t.Id > 0 AND p.PostTypeId = 4 AND LENGTH(p.Body) < 35 ORDER BY t.TagName
|
### Instruction:
Bug report score by day of week.
### Response:
|
SELECT MAX(100 * Score) / 100.0 AS AvgScore, TIME_TO_STR(CreationDate, '%A') AS DayOfWeek, COUNT(Id) AS NumPosts FROM Posts WHERE Tags LIKE '%##Tag##%' GROUP BY TIME_TO_STR(CreationDate, '%A') ORDER BY MAX(100 * Score) / 100.0 DESC
|
### Instruction:
provide the number of patients whose ethnicity is black/african american and drug name is collagenase ointment?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "BLACK/AFRICAN AMERICAN" AND prescriptions.drug = "Collagenase Ointment"
|
### Instruction:
For those records from the products and each product's manufacturer, give me the comparison about the amount of headquarter over the headquarter , and group by attribute headquarter, and I want to show by the Y-axis in asc please.
### Response:
|
SELECT Headquarter, COUNT(Headquarter) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY COUNT(Headquarter)
|
### Instruction:
accept answer under accepted answer.
### Response:
|
SELECT c.Id, c.Id AS "comment_link", c.CreationDate FROM Comments AS c INNER JOIN Posts AS q ON q.AcceptedAnswerId = c.PostId WHERE LENGTH(c.Text) <= 75 AND c.Score < 5 AND LOWER(c.Text) LIKE '%answer%' AND LOWER(c.Text) LIKE '%accept%' ORDER BY c.CreationDate DESC
|
### Instruction:
uncontrolled hypertension ( i.e., systolic blood pressure > 160 mm hg, or a diastolic blood pressure > 95 mmhg based on an average of 3 readings sitting )
### Response:
|
SELECT * FROM table_dev_51 WHERE hypertension = 1 OR systolic_blood_pressure_sbp > 160 OR diastolic_blood_pressure_dbp > 95
|
### Instruction:
provide the number of patients whose insurance is private and diagnosis long title is malignant neoplasm of other specified sites of bladder.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Private" AND diagnoses.long_title = "Malignant neoplasm of other specified sites of bladder"
|
### Instruction:
For those records from the products and each product's manufacturer, draw a bar chart about the distribution of headquarter and the average of code , and group by attribute headquarter, and order from low to high by the bar.
### 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
|
### Instruction:
uncontrolled hypertension with average systolic blood pressure of > 160 mmhg on two screening visits and diastolic blood pressure > 95 mmhg on two screening visit.
### Response:
|
SELECT * FROM table_dev_25 WHERE hypertension = 1 AND (systolic_blood_pressure_sbp > 160 AND diastolic_blood_pressure_dbp > 95)
|
### Instruction:
All questions with exactly two specified tags and no accepted answer.
### Response:
|
SELECT Id AS "post_link", CreationDate, Score, Tags FROM Posts WHERE Tags IN ('<' + '##tag1:string##' + '><' + '##tag2:string##' + '>', '<' + '##tag2:string##' + '><' + '##tag1:string##' + '>') AND AcceptedAnswerId IS NULL ORDER BY CreationDate DESC
|
### Instruction:
how many of the patients diagnosed with mv collision nos-driver received id 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 = "Mv collision NOS-driver" AND prescriptions.route = "ID"
|
### Instruction:
what are the three most frequent procedures performed since 2 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(), '-2 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
|
### Instruction:
How many professors whose office is located in DRE 102 are hired in each weekday? Return a bar chart.
### Response:
|
SELECT EMP_HIREDATE, COUNT(EMP_HIREDATE) FROM EMPLOYEE AS T1 JOIN PROFESSOR AS T2 ON T1.EMP_NUM = T2.EMP_NUM WHERE T2.PROF_OFFICE = 'DRE 102' GROUP BY EMP_LNAME
|
### Instruction:
Got the most badges on the same day.
### Response:
|
WITH Raw AS (SELECT UserId, DATEFROMPARTS(TIME_TO_STR(Date, '%Y'), TIME_TO_STR(Date, '%M'), TIME_TO_STR(Date, '%-d')) AS Date FROM Badges) SELECT UserId, UserId AS "user_link", Date, COUNT(*) AS N FROM Raw GROUP BY UserId, Date ORDER BY N DESC, UserId LIMIT 100
|
### Instruction:
how many patients whose discharge location is rehab/distinct part hosp and diagnoses long title is end stage renal disease?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "REHAB/DISTINCT PART HOSP" AND diagnoses.long_title = "End stage renal disease"
|
### Instruction:
For those employees who was hired before 2002-06-21, return a bar chart about the distribution of job_id and the average of salary , and group by attribute job_id, rank in ascending by the Y.
### Response:
|
SELECT JOB_ID, AVG(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY AVG(SALARY)
|
### Instruction:
Who wrote the episode directed by Jos Humphrey that had an original Canadian air date that was unknown and a United States original air date of August 27, 2011?
### Response:
|
SELECT written_by FROM table_29087004_2 WHERE directed_by = "Jos Humphrey" AND canada_original_airdate = "Unknown" AND united_states_original_airdate = "August 27, 2011"
|
### 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 department_id bin hire_date by time, sort by the y-axis in ascending.
### Response:
|
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY AVG(DEPARTMENT_ID)
|
### 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 show y axis in descending order.
### 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) DESC
|
### Instruction:
how many patients whose admission location is clinic referral/premature and diagnoses icd9 code is 431?
### 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 = "431"
|
### Instruction:
get the number of patients who had other and unspecified repair of atrial septal defect and were discharged to home health care.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "HOME HEALTH CARE" AND procedures.long_title = "Other and unspecified repair of atrial septal defect"
|
### Instruction:
how many patients in 2105 had ns bolus intake?
### Response:
|
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT intakeoutput.patientunitstayid FROM intakeoutput WHERE intakeoutput.celllabel = 'ns bolus' AND intakeoutput.cellpath LIKE '%input%' AND STRFTIME('%y', intakeoutput.intakeoutputtime) = '2105')
|
### Instruction:
What is the Chipset based on with a Digital/analog signal of analog, with an Available interface of agp, with Retail name with all-in-wonder 9800?
### Response:
|
SELECT "Chipset based on" FROM table_10487 WHERE "Digital/analog signal" = 'analog' AND "Available interface" = 'agp' AND "Retail name" = 'all-in-wonder 9800'
|
### Instruction:
did patient 45612 have propofol prescribed until 2101?
### Response:
|
SELECT COUNT(*) > 0 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 45612) AND prescriptions.drug = 'propofol' AND STRFTIME('%y', prescriptions.startdate) <= '2101'
|
### Instruction:
how many days have passed since patient 90663 was admitted to intensive care?
### Response:
|
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', icustays.intime)) FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 90663) AND icustays.outtime IS NULL
|
### Instruction:
have any microbiology test been performed since 07/2101 for patient 91004?
### Response:
|
SELECT COUNT(*) > 0 FROM microbiologyevents WHERE microbiologyevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 91004) AND STRFTIME('%y-%m', microbiologyevents.charttime) >= '2101-07'
|
### 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 manager_id , and group by attribute job_id, list from low to high by the names.
### Response:
|
SELECT JOB_ID, SUM(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID
|
### Instruction:
For those records from the products and each product's manufacturer, show me about the distribution of name and revenue , and group by attribute headquarter in a bar chart, and could you list by the Revenue in desc?
### 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 T2.Revenue DESC
|
### Instruction:
When the launch date is 14.09.2005, and the frequency is 900mhz and 1800mhz, how many carriers are there?
### Response:
|
SELECT COUNT(carrier) FROM table_19246_1 WHERE frequency = "900MHz and 1800MHz" AND launch_date__ddmmyyyy_ = "14.09.2005"
|
### Instruction:
For directors who had more than one movie, bin the year into Year interval and them compute the total number of movies in each year bucket, and group by title The result can be drawn as a trend line, display by the x-axis from high to low please.
### Response:
|
SELECT year, COUNT(year) FROM Movie AS T1 JOIN Movie AS T2 ON T1.director = T2.director WHERE T1.title <> T2.title GROUP BY title ORDER BY year DESC
|
### Instruction:
give me the number of patients whose ethnicity is white - russian and drug name is chloraseptic throat spray?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.ethnicity = "WHITE - RUSSIAN" AND prescriptions.drug = "Chloraseptic Throat Spray"
|
### Instruction:
provide the number of patients whose admission year is less than 2154 and diagnoses short title is abn reac-organ rem nec?
### 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 = "Abn reac-organ rem NEC"
|
### Instruction:
For each year, bin the year into day of the week interval, and return the average of the number of times the team Boston Red Stockings won in the postseasons using a line chart, order X in desc order please.
### Response:
|
SELECT year, AVG(COUNT(*)) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' ORDER BY year DESC
|
### Instruction:
Which Country has a To par smaller than 6, and a Money ($) larger than 700, and a Score of 69-73-70-71=283?
### Response:
|
SELECT "Country" FROM table_61033 WHERE "To par" < '6' AND "Money ( $ )" > '700' AND "Score" = '69-73-70-71=283'
|
### Instruction:
how many patients are married and diagnosed with primary disease coronary artery disease or coronary artery bypass graft with mvr maze?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "MARRIED" AND demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE"
|
### Instruction:
For those records from the products and each product's manufacturer, a bar chart shows the distribution of headquarter and the average of manufacturer , and group by attribute headquarter, could you order in asc by the y-axis please?
### Response:
|
SELECT Headquarter, AVG(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY AVG(Manufacturer)
|
### Instruction:
Users who accepted my answers.
### Response:
|
WITH Q AS (SELECT * FROM Posts WHERE NOT AcceptedAnswerId IS NULL AND NOT OwnerUserId IS NULL AND OwnerUserId != @UserId) SELECT Q.OwnerUserId AS "user_link", COUNT(*) AS Num FROM Posts INNER JOIN Q ON Q.Id = Posts.ParentId WHERE Posts.OwnerUserId = @UserId GROUP BY Q.OwnerUserId HAVING COUNT(*) > 1 ORDER BY Num DESC
|
### Instruction:
how many patients whose diagnoses short title is abnormal loss of weight 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.short_title = "Abnormal loss of weight" AND prescriptions.route = "PR"
|
### Instruction:
count the number of patients whose year of death is less than or equal to 2132 and diagnoses icd9 code is 7098?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dod_year <= "2132.0" AND diagnoses.icd9_code = "7098"
|
### Instruction:
until 02/2102 was there any microbiology test result for patient 76637?
### 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:
give me the number of patients whose days of hospital stay is greater than 17 and procedure long title is combined right and left heart cardiac catheterization?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "17" AND procedures.long_title = "Combined right and left heart cardiac catheterization"
|
### Instruction:
how many patients until 2104 had received a systemic antibiotics - vancomycin procedure?
### Response:
|
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT treatment.patientunitstayid FROM treatment WHERE treatment.treatmentname = 'systemic antibiotics - vancomycin' AND STRFTIME('%y', treatment.treatmenttime) <= '2104')
|
### Instruction:
Number and ratio of closed questions per day for the last three month.
### Response:
|
SELECT DATEPART(dayofyear, ClosedDate) AS "day", COUNT(*) AS "number_of_closed_questions" FROM Posts WHERE PostTypeId = 1 AND NOT ClosedDate IS NULL AND DATEDIFF(day, ClosedDate, GETDATE()) < 90 GROUP BY DATEPART(dayofyear, ClosedDate) ORDER BY DATEPART(dayofyear, ClosedDate)
|
### Instruction:
How many instructors are in each department? Show me a bar chart, and sort by the x axis from high to low.
### Response:
|
SELECT T1.dept_name, COUNT(DISTINCT T3.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:
how many patients whose diagnoses short title is ami inferior wall, init and lab test abnormal status is abnormal?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.short_title = "AMI inferior wall, init" AND lab.flag = "abnormal"
|
### Instruction:
How many appearances did the flamengo player who was with flamengo during the years 1989 1993 1996 1998 2004 2005 have?
### Response:
|
SELECT MAX("Appearances") FROM table_8115 WHERE "Flamengo career" = '1989β1993 1996β1998 2004β2005'
|
### Instruction:
did patient 48706 get any procedure a year before?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 48706) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year')
|
### Instruction:
Calculate the average age of patients with aortic insufficiency re-do sternotomy aortic valve replacement who stayed in hospital for 10 days.
### Response:
|
SELECT AVG(demographic.age) FROM demographic WHERE demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT " AND demographic.days_stay = "10"
|
### Instruction:
What is the 3rd runner-up of the country with more than 0 9th runner-up, an 11th runner-up of 0, and the 1st runner-up greater than 0?
### Response:
|
SELECT SUM("3rd runner-up") FROM table_75071 WHERE "9th runner-up" > '0' AND "11th runner-up" = '0' AND "1st runner-up" > '0'
|
### Instruction:
had patient 77586 received any procedure during this year?
### Response:
|
SELECT COUNT(*) > 0 FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 77586) AND DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
### Instruction:
What are the total number of credits offered by each department Show bar chart, I want to show from high to low by the crs credit please.
### Response:
|
SELECT DEPT_CODE, SUM(T1.CRS_CREDIT) FROM COURSE AS T1 JOIN CLASS AS T2 ON T1.CRS_CODE = T2.CRS_CODE GROUP BY T1.DEPT_CODE ORDER BY SUM(T1.CRS_CREDIT) DESC
|
### Instruction:
Can I take ENVIRON 102 for PreMajor ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, program, program_course WHERE course.department = 'ENVIRON' AND course.number = 102 AND program_course.category LIKE '%PreMajor%' AND program_course.course_id = course.course_id AND program.name LIKE '%CS-LSA%' AND program.program_id = program_course.program_id
|
### Instruction:
How many of the patients with sigmoid diverticulitis colovestical fistula/SDA as their primary disease had a hospital stay for more than 26 days?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "SIGMOID DIVERTICULITIS, COLOVESTICAL FISTULA/SDA" AND demographic.days_stay > "26"
|
### Instruction:
For those employees who was hired before 2002-06-21, show me about the distribution of job_id and the sum of salary , and group by attribute job_id in a bar chart, show in desc by the x-axis.
### Response:
|
SELECT JOB_ID, SUM(SALARY) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY JOB_ID DESC
|
### 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, and list from low to high by the JOB_ID please.
### 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 JOB_ID
|
### Instruction:
Find the latest logon date of the students whose family name is 'Jaskolski' or 'Langosh', and count them by a bar chart, I want to sort in ascending by the y axis.
### Response:
|
SELECT date_of_latest_logon, COUNT(date_of_latest_logon) FROM Students WHERE family_name = "Jaskolski" OR family_name = "Langosh" ORDER BY COUNT(date_of_latest_logon)
|
### Instruction:
how many patients born before the year 1837 had the drug named piperacillin-tazobactum na?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dob_year < "1837" AND prescriptions.drug = "Piperacillin-Tazobactam Na"
|
### Instruction:
count the number of patients whose discharge location is short term hospital and procedure long title is other endoscopy of small intestine?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "SHORT TERM HOSPITAL" AND procedures.long_title = "Other endoscopy of small intestine"
|
### Instruction:
how many patients were given a methemoglobin lab test in the previous year?
### Response:
|
SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'methemoglobin' AND DATETIME(lab.labresulttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year'))
|
### Instruction:
On what date did the event begin that had a steam traction type and used the system named HSM (1883 1910) GT (1915 1922)?
### Response:
|
SELECT "Date (From)" FROM table_66752 WHERE "Name of System" = 'hsm (1883β1910) gt (1915β1922)' AND "Traction Type" = 'steam'
|
### Instruction:
What is the highest glucose(mg/dl) with a solution of 2/3d & 1/3s and glucose(mmol/L) less than 185?
### Response:
|
SELECT MAX("[Glucose](mg/dl)") FROM table_44696 WHERE "Solution" = '2/3d & 1/3s' AND "[Glucose](mmol/L)" < '185'
|
### Instruction:
what is the number of self pay insurance patients who have had allogeneic hematopoietic stem cell transplant without purging?
### 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 = "Allogeneic hematopoietic stem cell transpant without purging"
|
### Instruction:
provide the number of patients whose year of birth is less than 2109 and procedure long title is coronary arteriography using two catheters?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2109" AND procedures.long_title = "Coronary arteriography using two catheters"
|
### Instruction:
what number of patients whose procedure icd9 code is 4131 have their admission location as clinic referral/premature?
### 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.icd9_code = "4131"
|
### Instruction:
what was the first drug being prescribed for patient 26262 during the last hospital visit?
### Response:
|
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26262 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY prescriptions.startdate LIMIT 1
|
### Instruction:
eiffel 65 had a top 100 hit of the 1990s , blue -lrb- da ba dee -rrb- , as well as one other 1990s top 100 hit single . what was that other hit single ?
### Response:
|
SELECT "single" FROM table_203_7 WHERE "artist" = 'eiffel 65' AND "single" <> '"blue (da ba dee)"'
|
### Instruction:
How many sections does MILSCI 499 include ?
### Response:
|
SELECT COUNT(*) FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'MILSCI' AND course.number = 499 AND semester.semester = 'WN' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
What is the sum of the [3 H]CFT with an N D less than 393.8 and a [3H] paroxetine of 1045 (45)?
### Response:
|
SELECT SUM("[ 3 H]CFT") FROM table_65228 WHERE "N \u00f7 D" < '393.8' AND "[ 3 H]Paroxetine" = '1045 (45)'
|
### Instruction:
count the number of patients whose ethnicity is asian and diagnosis long title is suicide and self-inflicted injury by hanging.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "ASIAN" AND diagnoses.long_title = "Suicide and self-inflicted injury by hanging"
|
### Instruction:
when did patient 90165 enter the hospital first time until 4 years ago via the emergency room admit?
### Response:
|
SELECT admissions.admittime FROM admissions WHERE admissions.subject_id = 90165 AND admissions.admission_location = 'emergency room admit' AND DATETIME(admissions.admittime) <= DATETIME(CURRENT_TIME(), '-4 year') ORDER BY admissions.admittime LIMIT 1
|
### Instruction:
Find the physicians who are trained in a procedure that costs more than 5000, and count them by a bar chart
### Response:
|
SELECT T1.Name, COUNT(T1.Name) FROM Physician AS T1 JOIN Trained_In AS T2 ON T1.EmployeeID = T2.Physician JOIN Procedures AS T3 ON T3.Code = T2.Treatment WHERE T3.Cost > 5000 GROUP BY T1.Name
|
### Instruction:
gRPC tagged questions in past year.
### Response:
|
SELECT COUNT(PostId) AS Rate FROM Tags, PostTags, Posts WHERE (TagName = 'grpc' OR TagName = 'grpc-java') AND Tags.Id = PostTags.TagId AND Posts.Id = PostId AND Posts.CreationDate < '2019-07-01' AND Posts.CreationDate > '2018-07-01'
|
### Instruction:
What's the fewest number of branches with more than 1 total congregations, a population of 1,033,381, and a membership smaller than 5,671?
### Response:
|
SELECT MIN("Branches") FROM table_77365 WHERE "Total Congregations" > '1' AND "Population" = '1,033,381' AND "Membership" < '5,671'
|
### Instruction:
Questions I've answered that involve 2012 but aren't tagged as such.
### Response:
|
SELECT 'http://dba.stackexchange.com/questions/' + RTRIM(Id) FROM dbo.Posts AS p WHERE NOT Tags LIKE '%2012%' AND EXISTS(SELECT 1 FROM dbo.Posts WHERE ParentId = p.Id AND OwnerUserId = 1186 AND Body LIKE '% 2012%') ORDER BY Id
|
### Instruction:
What is the highest Aug 2013 with a Nov 2011 smaller than 968, and a Jul 2012 with 31, and a Jun 2011 larger than 30?
### Response:
|
SELECT MAX(aug_2013) FROM table_name_27 WHERE nov_2011 < 968 AND jul_2012 = 31 AND jun_2011 > 30
|
### Instruction:
how many patients whose year of death is less than or equal to 2154 and diagnoses icd9 code is 70715?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.dod_year <= "2154.0" AND diagnoses.icd9_code = "70715"
|
### Instruction:
For all employees who have the letters D or S in their first name, a bar chart shows the distribution of hire_date and the average of manager_id bin hire_date by weekday, could you rank from low to high by the y axis?
### Response:
|
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(MANAGER_ID)
|
### Instruction:
count the number of patients whose death status is 0 and procedure long title is laparoscopic lysis of peritoneal adhesions?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.expire_flag = "0" AND procedures.long_title = "Laparoscopic lysis of peritoneal adhesions"
|
### Instruction:
how many office admitted patients have aortic valve insufficiency/aortic valve replacement/sda primary disease?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "AORTIC VALVE INSUFFIENCY\AORTIC VALVE REPLACEMENT /SDA"
|
### Instruction:
Give the number of each course name with at least five enrollments Return a bar chart, and list by the Y-axis in ascending.
### Response:
|
SELECT T1.CName, COUNT(T1.CName) FROM Course AS T1 JOIN Enrolled_in AS T2 ON T1.CID = T2.CID GROUP BY T1.CName, T2.CID HAVING COUNT(*) >= 5 ORDER BY COUNT(T1.CName)
|
### Instruction:
count the number of patients whose admission location is trsf within this facility and drug code is foli 1.
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "TRSF WITHIN THIS FACILITY" AND prescriptions.formulary_drug_cd = "FOLI1"
|
### Instruction:
how many patients whose procedure icd9 code is 8674 and drug route is nu?
### 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 = "8674" AND prescriptions.route = "NU"
|
### Instruction:
what is the date when saros is more than 124, the type is total, the magnitude is more than 1.0535 and the time (greatest) is 20:55:28?
### Response:
|
SELECT date FROM table_name_21 WHERE saros > 124 AND type = "total" AND magnitude > 1.0535 AND time__greatest_ = "20:55:28"
|
### Instruction:
Just show the first name and the manager id with a bar chart, and sort total number from high to low order.
### Response:
|
SELECT T1.FIRST_NAME, T1.MANAGER_ID FROM employees AS T1 JOIN departments AS T2 ON T1.DEPARTMENT_ID = T2.DEPARTMENT_ID WHERE T1.EMPLOYEE_ID = T2.MANAGER_ID ORDER BY T1.MANAGER_ID DESC
|
### Instruction:
For all employees who have the letters D or S in their first name, a bar chart shows the distribution of hire_date and the average of department_id bin hire_date by weekday, display by the the average of department id in asc.
### Response:
|
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(DEPARTMENT_ID)
|
### Instruction:
How many trips started from Mountain View city and ended at Palo Alto city?
### Response:
|
SELECT COUNT(*) FROM station AS T1 JOIN trip AS T2 JOIN station AS T3 JOIN trip AS T4 ON T1.id = T2.start_station_id AND T2.id = T4.id AND T3.id = T4.end_station_id WHERE T1.city = "Mountain View" AND T3.city = "Palo Alto"
|
### Instruction:
For those records from the products and each product's manufacturer, give me the comparison about the sum of price over the headquarter , and group by attribute headquarter by a bar chart, and I want to order from low to high by the y-axis.
### Response:
|
SELECT Headquarter, SUM(Price) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY SUM(Price)
|
### Instruction:
Can I take the 314 course next term ?
### Response:
|
SELECT COUNT(*) > 0 FROM course, course_offering, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND course.number = 314 AND semester.semester = 'FA' AND semester.semester_id = course_offering.semester AND semester.year = 2016
|
### Instruction:
how many patients whose diagnoses short title is physical restrain status and drug route is ng?
### 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 = "Physical restrain status" AND prescriptions.route = "NG"
|
### Instruction:
last time patient 16572 was prescribed a drug on the last hospital visit?
### Response:
|
SELECT prescriptions.startdate FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 16572 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) ORDER BY prescriptions.startdate DESC LIMIT 1
|
### Instruction:
Unanswered and uncommented questions for Worklight.
### Response:
|
SELECT pt.PostId AS "post_link", p.Score, p.ViewCount, p.CommentCount, p.CreationDate FROM Tags AS t, PostTags AS pt, Posts AS p WHERE pt.TagId = t.Id AND p.Id = pt.PostId AND t.TagName = 'worklight' AND p.AnswerCount IS NULL AND p.CommentCount IS NULL ORDER BY CreationDate
|
### Instruction:
what is the number of patients whose admission year is less than 2178 and procedure long title is continuous intra-arterial blood gas monitoring?
### Response:
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2178" AND procedures.long_title = "Continuous intra-arterial blood gas monitoring"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.