instruction
stringlengths
11
446
input
stringlengths
195
2.3k
response
stringlengths
26
460
display job title and average salary of employees.
CREATE TABLE jobs ( job_id text, job_title text, min_salary number, max_salary number ) CREATE TABLE regions ( region_id number, region_name text ) CREATE TABLE locations ( location_id number, street_address text, postal_code text, city text, state_province text, country_id text ) CREATE TABLE employees ( employee_id number, first_name text, last_name text, email text, phone_number text, hire_date time, job_id text, salary number, commission_pct number, manager_id number, department_id number ) CREATE TABLE job_history ( employee_id number, start_date time, end_date time, job_id text, department_id number ) CREATE TABLE countries ( country_id text, country_name text, region_id number ) CREATE TABLE departments ( department_id number, department_name text, manager_id number, location_id number )
SELECT job_title, AVG(salary) FROM employees AS T1 JOIN jobs AS T2 ON T1.job_id = T2.job_id GROUP BY T2.job_title
what is date of birth of subject name shawn green?
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT demographic.dob FROM demographic WHERE demographic.name = "Shawn Green"
what is the drug route of the drug code dones?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT prescriptions.route FROM prescriptions WHERE prescriptions.formulary_drug_cd = "DONE5"
how many patients are discharged to home with age below 62?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "HOME" AND demographic.age < "62"
provide the number of patients whose admission location is transfer from hosp/extram and primary disease is bladder cancer/sda?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND demographic.diagnosis = "BLADDER CANCER/SDA"
calculate the number of patients with unspecified opioid type dependence who received drug via ivpca route
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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 = "Opioid type dependence, unspecified" AND prescriptions.route = "IVPCA"
For each record in schedule, show sum of price for each day in a bar chart, and could you list y-axis in desc order?
CREATE TABLE schedule ( Cinema_ID int, Film_ID int, Date text, Show_times_per_day int, Price float ) CREATE TABLE cinema ( Cinema_ID int, Name text, Openning_year int, Capacity int, Location text ) CREATE TABLE film ( Film_ID int, Rank_in_series int, Number_in_season int, Title text, Directed_by text, Original_air_date text, Production_code text )
SELECT Date, SUM(Price) FROM schedule AS T1 JOIN film AS T2 ON T1.Film_ID = T2.Film_ID JOIN cinema AS T3 ON T1.Cinema_ID = T3.Cinema_ID GROUP BY Date ORDER BY SUM(Price) DESC
Find the number of settlements each claim corresponds to. Show the number together with the claim id.
CREATE TABLE customers ( customer_id number, customer_details text ) CREATE TABLE claims ( claim_id number, policy_id number, date_claim_made time, date_claim_settled time, amount_claimed number, amount_settled number ) CREATE TABLE customer_policies ( policy_id number, customer_id number, policy_type_code text, start_date time, end_date time ) CREATE TABLE settlements ( settlement_id number, claim_id number, date_claim_made time, date_claim_settled time, amount_claimed number, amount_settled number, customer_policy_id number ) CREATE TABLE payments ( payment_id number, settlement_id number, payment_method_code text, date_payment_made time, amount_payment number )
SELECT T1.claim_id, COUNT(*) FROM claims AS T1 JOIN settlements AS T2 ON T1.claim_id = T2.claim_id GROUP BY T1.claim_id
what is the maximum age of patients whose admission type is elective and year of death is before 2183?
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT MAX(demographic.age) FROM demographic WHERE demographic.admission_type = "ELECTIVE" AND demographic.dod_year < "2183.0"
For all employees who have the letters D or S in their first name, return a bar chart about the distribution of hire_date and the sum of department_id bin hire_date by weekday, show by the Y from low to high.
CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) )
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY SUM(DEPARTMENT_ID)
For those employees who was hired before 2002-06-21, draw a scatter chart about the correlation between employee_id and department_id .
CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) )
SELECT EMPLOYEE_ID, DEPARTMENT_ID FROM employees WHERE HIRE_DATE < '2002-06-21'
what is maximum age of patients whose marital status is widowed and days of hospital stay is 29?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT MAX(demographic.age) FROM demographic WHERE demographic.marital_status = "WIDOWED" AND demographic.days_stay = "29"
Show the number of documents for each location code in a bar chart, and I want to rank by the y axis in desc.
CREATE TABLE Document_Locations ( Document_ID INTEGER, Location_Code CHAR(15), Date_in_Location_From DATETIME, Date_in_Locaton_To DATETIME ) CREATE TABLE All_Documents ( Document_ID INTEGER, Date_Stored DATETIME, Document_Type_Code CHAR(15), Document_Name CHAR(255), Document_Description CHAR(255), Other_Details VARCHAR(255) ) CREATE TABLE Roles ( Role_Code CHAR(15), Role_Name VARCHAR(255), Role_Description VARCHAR(255) ) CREATE TABLE Ref_Locations ( Location_Code CHAR(15), Location_Name VARCHAR(255), Location_Description VARCHAR(255) ) CREATE TABLE Ref_Calendar ( Calendar_Date DATETIME, Day_Number INTEGER ) CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15), Document_Type_Name VARCHAR(255), Document_Type_Description VARCHAR(255) ) CREATE TABLE Employees ( Employee_ID INTEGER, Role_Code CHAR(15), Employee_Name VARCHAR(255), Gender_MFU CHAR(1), Date_of_Birth DATETIME, Other_Details VARCHAR(255) ) CREATE TABLE Documents_to_be_Destroyed ( Document_ID INTEGER, Destruction_Authorised_by_Employee_ID INTEGER, Destroyed_by_Employee_ID INTEGER, Planned_Destruction_Date DATETIME, Actual_Destruction_Date DATETIME, Other_Details VARCHAR(255) )
SELECT Location_Code, COUNT(Location_Code) FROM Document_Locations GROUP BY Location_Code ORDER BY COUNT(Location_Code) DESC
What are the number of the dates of the orders made by the customer named 'Jeramie'?
CREATE TABLE Order_Items ( order_item_id INTEGER, product_id INTEGER, order_id INTEGER, order_item_status VARCHAR(10), order_item_details VARCHAR(255) ) CREATE TABLE Customers ( customer_id INTEGER, customer_name VARCHAR(80), customer_details VARCHAR(255) ) CREATE TABLE Shipments ( shipment_id INTEGER, order_id INTEGER, invoice_number INTEGER, shipment_tracking_number VARCHAR(80), shipment_date DATETIME, other_shipment_details VARCHAR(255) ) CREATE TABLE Orders ( order_id INTEGER, customer_id INTEGER, order_status VARCHAR(10), date_order_placed DATETIME, order_details VARCHAR(255) ) CREATE TABLE Shipment_Items ( shipment_id INTEGER, order_item_id INTEGER ) CREATE TABLE Invoices ( invoice_number INTEGER, invoice_date DATETIME, invoice_details VARCHAR(255) ) CREATE TABLE Products ( product_id INTEGER, product_name VARCHAR(80), product_details VARCHAR(255) )
SELECT date_order_placed, COUNT(date_order_placed) FROM Customers AS T1 JOIN Orders AS T2 ON T1.customer_id = T2.customer_id WHERE T1.customer_name = "Jeramie"
Out of the total number of patients admitted before the year 2131, calculate the number of those who remained admitted in hospital for more than 23 days.
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.days_stay > "23" AND demographic.admityear < "2131"
What are the name and description for role code 'MG'?
CREATE TABLE document_locations ( document_id number, location_code text, date_in_location_from time, date_in_locaton_to time ) CREATE TABLE roles ( role_code text, role_name text, role_description text ) CREATE TABLE all_documents ( document_id number, date_stored time, document_type_code text, document_name text, document_description text, other_details text ) CREATE TABLE employees ( employee_id number, role_code text, employee_name text, gender_mfu text, date_of_birth time, other_details text ) CREATE TABLE ref_calendar ( calendar_date time, day_number number ) CREATE TABLE documents_to_be_destroyed ( document_id number, destruction_authorised_by_employee_id number, destroyed_by_employee_id number, planned_destruction_date time, actual_destruction_date time, other_details text ) CREATE TABLE ref_locations ( location_code text, location_name text, location_description text ) CREATE TABLE ref_document_types ( document_type_code text, document_type_name text, document_type_description text )
SELECT role_name, role_description FROM roles WHERE role_code = "MG"
what is the number of patients whose admission location is trsf within this facility and drug name is levothyroxine sodium?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
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.drug = "Levothyroxine Sodium"
list the number of patients who were admitted before the year 2107.
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admityear < "2107"
how many patients with lab test item id 51501 were born before 2107?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2107" AND lab.itemid = "51501"
Find the number of the latest logon date of the students whose family name is 'Jaskolski' or 'Langosh', and could you list y axis in ascending order?
CREATE TABLE Course_Authors_and_Tutors ( author_id INTEGER, author_tutor_ATB VARCHAR(3), login_name VARCHAR(40), password VARCHAR(40), personal_name VARCHAR(80), middle_name VARCHAR(80), family_name VARCHAR(80), gender_mf VARCHAR(1), address_line_1 VARCHAR(80) ) CREATE TABLE Subjects ( subject_id INTEGER, subject_name VARCHAR(120) ) CREATE TABLE Student_Course_Enrolment ( registration_id INTEGER, student_id INTEGER, course_id INTEGER, date_of_enrolment DATETIME, date_of_completion DATETIME ) CREATE TABLE Courses ( course_id INTEGER, author_id INTEGER, subject_id INTEGER, course_name VARCHAR(120), course_description VARCHAR(255) ) CREATE TABLE Student_Tests_Taken ( registration_id INTEGER, date_test_taken DATETIME, test_result VARCHAR(255) ) CREATE TABLE Students ( student_id INTEGER, date_of_registration DATETIME, date_of_latest_logon DATETIME, login_name VARCHAR(40), password VARCHAR(10), personal_name VARCHAR(40), middle_name VARCHAR(40), family_name VARCHAR(40) )
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)
Count those days and in which zip code was the min dew point lower than any day in zip code 94107 using a bar graph, could you order X in desc order?
CREATE TABLE trip ( id INTEGER, duration INTEGER, start_date TEXT, start_station_name TEXT, start_station_id INTEGER, end_date TEXT, end_station_name TEXT, end_station_id INTEGER, bike_id INTEGER, subscription_type TEXT, zip_code INTEGER ) CREATE TABLE weather ( date TEXT, max_temperature_f INTEGER, mean_temperature_f INTEGER, min_temperature_f INTEGER, max_dew_point_f INTEGER, mean_dew_point_f INTEGER, min_dew_point_f INTEGER, max_humidity INTEGER, mean_humidity INTEGER, min_humidity INTEGER, max_sea_level_pressure_inches NUMERIC, mean_sea_level_pressure_inches NUMERIC, min_sea_level_pressure_inches NUMERIC, max_visibility_miles INTEGER, mean_visibility_miles INTEGER, min_visibility_miles INTEGER, max_wind_Speed_mph INTEGER, mean_wind_speed_mph INTEGER, max_gust_speed_mph INTEGER, precipitation_inches INTEGER, cloud_cover INTEGER, events TEXT, wind_dir_degrees INTEGER, zip_code INTEGER ) CREATE TABLE status ( station_id INTEGER, bikes_available INTEGER, docks_available INTEGER, time TEXT ) CREATE TABLE station ( id INTEGER, name TEXT, lat NUMERIC, long NUMERIC, dock_count INTEGER, city TEXT, installation_date TEXT )
SELECT date, COUNT(date) FROM weather WHERE min_dew_point_f < (SELECT MIN(min_dew_point_f) FROM weather WHERE zip_code = 94107) GROUP BY date ORDER BY date DESC
Among patients with coronary artery disease or coronary artery bypass graft with mvr maze as their primary disease, calculate the number of those born before 2056
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "CORONARY ARTERY DISEASE\CORONARY ARTERY BYPASS GRAFT WITH MVR; ? MAZE" AND demographic.dob_year < "2056"
Show me a bar chart for how many total credits are offered by each department?, and order by the names from low to high.
CREATE TABLE teaches ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0) ) CREATE TABLE section ( course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_slot_id varchar(4) ) CREATE TABLE instructor ( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(8,2) ) CREATE TABLE prereq ( course_id varchar(8), prereq_id varchar(8) ) CREATE TABLE time_slot ( time_slot_id varchar(4), day varchar(1), start_hr numeric(2), start_min numeric(2), end_hr numeric(2), end_min numeric(2) ) CREATE TABLE student ( ID varchar(5), name varchar(20), dept_name varchar(20), tot_cred numeric(3,0) ) CREATE TABLE department ( dept_name varchar(20), building varchar(15), budget numeric(12,2) ) CREATE TABLE course ( course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) ) CREATE TABLE advisor ( s_ID varchar(5), i_ID varchar(5) ) CREATE TABLE takes ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2) ) CREATE TABLE classroom ( building varchar(15), room_number varchar(7), capacity numeric(4,0) )
SELECT dept_name, SUM(credits) FROM course GROUP BY dept_name ORDER BY dept_name
provide the number of patients whose days of hospital stay is greater than 13 and procedure icd9 code is 4105?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "13" AND procedures.icd9_code = "4105"
give the number of patients whose admission location is clinic referral/premature and drug name is clindamycin.
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND prescriptions.drug = "Clindamycin"
Show me a bar chart for what are the draft pick numbers and draft classes for players who play the Defender position?, display in descending by the Draft_Class.
CREATE TABLE match_season ( Season real, Player text, Position text, Country int, Team int, Draft_Pick_Number int, Draft_Class text, College text ) CREATE TABLE player ( Player_ID int, Player text, Years_Played text, Total_WL text, Singles_WL text, Doubles_WL text, Team int ) CREATE TABLE team ( Team_id int, Name text ) CREATE TABLE country ( Country_id int, Country_name text, Capital text, Official_native_language text )
SELECT Draft_Class, Draft_Pick_Number FROM match_season WHERE Position = "Defender" ORDER BY Draft_Class DESC
find the drug type and dose for oxacillin.
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT prescriptions.drug_type, prescriptions.drug_dose FROM prescriptions WHERE prescriptions.drug = "Oxacillin"
How many of the christian scientist patients had a hyaline casts lab test?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.religion = "CHRISTIAN SCIENTIST" AND lab.label = "Hyaline Casts"
Bar chart of sum crs credit from each dept code, I want to order from low to high by the bars.
CREATE TABLE ENROLL ( CLASS_CODE varchar(5), STU_NUM int, ENROLL_GRADE varchar(50) ) CREATE TABLE DEPARTMENT ( DEPT_CODE varchar(10), DEPT_NAME varchar(30), SCHOOL_CODE varchar(8), EMP_NUM int, DEPT_ADDRESS varchar(20), DEPT_EXTENSION varchar(4) ) CREATE TABLE COURSE ( CRS_CODE varchar(10), DEPT_CODE varchar(10), CRS_DESCRIPTION varchar(35), CRS_CREDIT float(8) ) CREATE TABLE EMPLOYEE ( EMP_NUM int, EMP_LNAME varchar(15), EMP_FNAME varchar(12), EMP_INITIAL varchar(1), EMP_JOBCODE varchar(5), EMP_HIREDATE datetime, EMP_DOB datetime ) CREATE TABLE CLASS ( CLASS_CODE varchar(5), CRS_CODE varchar(10), CLASS_SECTION varchar(2), CLASS_TIME varchar(20), CLASS_ROOM varchar(8), PROF_NUM int ) CREATE TABLE PROFESSOR ( EMP_NUM int, DEPT_CODE varchar(10), PROF_OFFICE varchar(50), PROF_EXTENSION varchar(4), PROF_HIGH_DEGREE varchar(5) ) CREATE TABLE STUDENT ( STU_NUM int, STU_LNAME varchar(15), STU_FNAME varchar(15), STU_INIT varchar(1), STU_DOB datetime, STU_HRS int, STU_CLASS varchar(2), STU_GPA float(8), STU_TRANSFER numeric, DEPT_CODE varchar(18), STU_PHONE varchar(4), PROF_NUM int )
SELECT DEPT_CODE, SUM(CRS_CREDIT) FROM COURSE GROUP BY DEPT_CODE ORDER BY DEPT_CODE
how many black/cape verdean patients had guillain barre syndrome as a primary disease?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "BLACK/CAPE VERDEAN" AND demographic.diagnosis = "GUILLAIN BARRE SYNDROME"
how many patients posses self insurance and are tested for creatinine kinase mb isoenzyme in lab?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.insurance = "Self Pay" AND lab.label = "Creatine Kinase, MB Isoenzyme"
Show me a scatter plot of avg(stu gpa) and minimal stu gpa for .
CREATE TABLE PROFESSOR ( EMP_NUM int, DEPT_CODE varchar(10), PROF_OFFICE varchar(50), PROF_EXTENSION varchar(4), PROF_HIGH_DEGREE varchar(5) ) CREATE TABLE COURSE ( CRS_CODE varchar(10), DEPT_CODE varchar(10), CRS_DESCRIPTION varchar(35), CRS_CREDIT float(8) ) CREATE TABLE DEPARTMENT ( DEPT_CODE varchar(10), DEPT_NAME varchar(30), SCHOOL_CODE varchar(8), EMP_NUM int, DEPT_ADDRESS varchar(20), DEPT_EXTENSION varchar(4) ) CREATE TABLE ENROLL ( CLASS_CODE varchar(5), STU_NUM int, ENROLL_GRADE varchar(50) ) CREATE TABLE STUDENT ( STU_NUM int, STU_LNAME varchar(15), STU_FNAME varchar(15), STU_INIT varchar(1), STU_DOB datetime, STU_HRS int, STU_CLASS varchar(2), STU_GPA float(8), STU_TRANSFER numeric, DEPT_CODE varchar(18), STU_PHONE varchar(4), PROF_NUM int ) CREATE TABLE CLASS ( CLASS_CODE varchar(5), CRS_CODE varchar(10), CLASS_SECTION varchar(2), CLASS_TIME varchar(20), CLASS_ROOM varchar(8), PROF_NUM int ) CREATE TABLE EMPLOYEE ( EMP_NUM int, EMP_LNAME varchar(15), EMP_FNAME varchar(12), EMP_INITIAL varchar(1), EMP_JOBCODE varchar(5), EMP_HIREDATE datetime, EMP_DOB datetime )
SELECT AVG(STU_GPA), MIN(STU_GPA) FROM STUDENT GROUP BY DEPT_CODE
how many patients are admitted before the year 2158 and followed the procedure inject ca chemother nec?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admityear < "2158" AND procedures.short_title = "Inject ca chemother NEC"
Find the total number of students for each department with a bar chart, and could you list y axis in descending order?
CREATE TABLE classroom ( building varchar(15), room_number varchar(7), capacity numeric(4,0) ) CREATE TABLE advisor ( s_ID varchar(5), i_ID varchar(5) ) CREATE TABLE instructor ( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(8,2) ) CREATE TABLE prereq ( course_id varchar(8), prereq_id varchar(8) ) CREATE TABLE teaches ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0) ) CREATE TABLE section ( course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_slot_id varchar(4) ) CREATE TABLE takes ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2) ) CREATE TABLE department ( dept_name varchar(20), building varchar(15), budget numeric(12,2) ) CREATE TABLE course ( course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) ) CREATE TABLE student ( ID varchar(5), name varchar(20), dept_name varchar(20), tot_cred numeric(3,0) ) CREATE TABLE time_slot ( time_slot_id varchar(4), day varchar(1), start_hr numeric(2), start_min numeric(2), end_hr numeric(2), end_min numeric(2) )
SELECT T1.dept_name, COUNT(DISTINCT T2.ID) FROM department AS T1 JOIN student AS T2 ON T1.dept_name = T2.dept_name JOIN instructor AS T3 ON T1.dept_name = T3.dept_name ORDER BY COUNT(DISTINCT T2.ID) DESC
what is minimum age of patients whose primary disease is pituitary bleed and days of hospital stay is 69?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT MIN(demographic.age) FROM demographic WHERE demographic.diagnosis = "PITUITARY BLEED" AND demographic.days_stay = "69"
out of total number of patients who had a lab test for other cells, calculate the number of divorcees
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.marital_status = "DIVORCED" AND lab.label = "Other Cells"
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 salary bin hire_date by time, and show by the y-axis in desc.
CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) )
SELECT HIRE_DATE, AVG(SALARY) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(SALARY) DESC
Show all role codes and the number of employees in each role with a pie chart.
CREATE TABLE All_Documents ( Document_ID INTEGER, Date_Stored DATETIME, Document_Type_Code CHAR(15), Document_Name CHAR(255), Document_Description CHAR(255), Other_Details VARCHAR(255) ) CREATE TABLE Ref_Locations ( Location_Code CHAR(15), Location_Name VARCHAR(255), Location_Description VARCHAR(255) ) CREATE TABLE Documents_to_be_Destroyed ( Document_ID INTEGER, Destruction_Authorised_by_Employee_ID INTEGER, Destroyed_by_Employee_ID INTEGER, Planned_Destruction_Date DATETIME, Actual_Destruction_Date DATETIME, Other_Details VARCHAR(255) ) CREATE TABLE Ref_Calendar ( Calendar_Date DATETIME, Day_Number INTEGER ) CREATE TABLE Employees ( Employee_ID INTEGER, Role_Code CHAR(15), Employee_Name VARCHAR(255), Gender_MFU CHAR(1), Date_of_Birth DATETIME, Other_Details VARCHAR(255) ) CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15), Document_Type_Name VARCHAR(255), Document_Type_Description VARCHAR(255) ) CREATE TABLE Document_Locations ( Document_ID INTEGER, Location_Code CHAR(15), Date_in_Location_From DATETIME, Date_in_Locaton_To DATETIME ) CREATE TABLE Roles ( Role_Code CHAR(15), Role_Name VARCHAR(255), Role_Description VARCHAR(255) )
SELECT Role_Code, COUNT(*) FROM Employees GROUP BY Role_Code
find the minimum age of patients with primary disease as chest pain and admission location as clinic referral/premature.
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT MIN(demographic.age) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.diagnosis = "CHEST PAIN"
Find the department name and room of the course INTRODUCTION TO COMPUTER SCIENCE.
CREATE TABLE enrolled_in ( stuid number, cid text, grade text ) CREATE TABLE member_of ( facid number, dno number, appt_type text ) CREATE TABLE student ( stuid number, lname text, fname text, age number, sex text, major number, advisor number, city_code text ) CREATE TABLE minor_in ( stuid number, dno number ) CREATE TABLE course ( cid text, cname text, credits number, instructor number, days text, hours text, dno number ) CREATE TABLE gradeconversion ( lettergrade text, gradepoint number ) CREATE TABLE department ( dno number, division text, dname text, room text, building text, dphone number ) CREATE TABLE faculty ( facid number, lname text, fname text, rank text, sex text, phone number, room text, building text )
SELECT T2.dname, T2.room FROM course AS T1 JOIN department AS T2 ON T1.dno = T2.dno WHERE T1.cname = "INTRODUCTION TO COMPUTER SCIENCE"
For the transaction dates if share count is smaller than 10, bin the dates into the year interval, and count them using a line chart, could you sort X from high to low order?
CREATE TABLE Sales ( sales_transaction_id INTEGER, sales_details VARCHAR(255) ) CREATE TABLE Ref_Transaction_Types ( transaction_type_code VARCHAR(10), transaction_type_description VARCHAR(80) ) CREATE TABLE Purchases ( purchase_transaction_id INTEGER, purchase_details VARCHAR(255) ) CREATE TABLE Investors ( investor_id INTEGER, Investor_details VARCHAR(255) ) CREATE TABLE Transactions_Lots ( transaction_id INTEGER, lot_id INTEGER ) CREATE TABLE Lots ( lot_id INTEGER, investor_id INTEGER, lot_details VARCHAR(255) ) CREATE TABLE Transactions ( transaction_id INTEGER, investor_id INTEGER, transaction_type_code VARCHAR(10), date_of_transaction DATETIME, amount_of_transaction DECIMAL(19,4), share_count VARCHAR(40), other_details VARCHAR(255) )
SELECT date_of_transaction, COUNT(date_of_transaction) FROM Transactions WHERE share_count < 10 ORDER BY date_of_transaction DESC
count the number of patients whose admission type is elective and procedure icd9 code is 17?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND procedures.icd9_code = "17"
find out the number of patients with procedure icd9 code 9961 who have been discharged to skilled nursing facility.
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.discharge_location = "SNF" AND procedures.icd9_code = "9961"
return me the paper after 2000 with more than 200 citations .
CREATE TABLE journal ( homepage varchar, jid int, name varchar ) CREATE TABLE domain ( did int, name varchar ) CREATE TABLE domain_author ( aid int, did int ) CREATE TABLE author ( aid int, homepage varchar, name varchar, oid int ) CREATE TABLE writes ( aid int, pid int ) CREATE TABLE conference ( cid int, homepage varchar, name varchar ) CREATE TABLE organization ( continent varchar, homepage varchar, name varchar, oid int ) CREATE TABLE domain_publication ( did int, pid int ) CREATE TABLE publication_keyword ( kid int, pid int ) CREATE TABLE keyword ( keyword varchar, kid int ) CREATE TABLE domain_journal ( did int, jid int ) CREATE TABLE publication ( abstract varchar, cid int, citation_num int, jid int, pid int, reference_num int, title varchar, year int ) CREATE TABLE cite ( cited int, citing int ) CREATE TABLE domain_conference ( cid int, did int ) CREATE TABLE domain_keyword ( did int, kid int )
SELECT title FROM publication WHERE citation_num > 200 AND year > 2000
how many patients admitted before the year 2155 had the drug name bismuth subsalicylate?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2155" AND prescriptions.drug = "Bismuth Subsalicylate"
provide me the number of black/haitian patients who were admitted before the year 2124.
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "BLACK/HAITIAN" AND demographic.admityear < "2124"
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, return a bar chart about the distribution of job_id and the average of department_id , and group by attribute job_id, rank by the total number from low to high.
CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) )
SELECT JOB_ID, AVG(DEPARTMENT_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(DEPARTMENT_ID)
what is the number of patients under the age of 70 who were admitted in emergency?
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.age < "70"
Show the start dates and end dates of all the apartment bookings made by guests with gender code 'Female'.
CREATE TABLE apartment_facilities ( apt_id number, facility_code text ) CREATE TABLE view_unit_status ( apt_id number, apt_booking_id number, status_date time, available_yn others ) CREATE TABLE guests ( guest_id number, gender_code text, guest_first_name text, guest_last_name text, date_of_birth time ) CREATE TABLE apartment_bookings ( apt_booking_id number, apt_id number, guest_id number, booking_status_code text, booking_start_date time, booking_end_date time ) CREATE TABLE apartment_buildings ( building_id number, building_short_name text, building_full_name text, building_description text, building_address text, building_manager text, building_phone text ) CREATE TABLE apartments ( apt_id number, building_id number, apt_type_code text, apt_number text, bathroom_count number, bedroom_count number, room_count text )
SELECT T1.booking_start_date, T1.booking_start_date FROM apartment_bookings AS T1 JOIN guests AS T2 ON T1.guest_id = T2.guest_id WHERE T2.gender_code = "Female"
For those employees who do not work in departments with managers that have ids between 100 and 200, visualize a bar chart about the distribution of hire_date and the sum of salary bin hire_date by weekday, could you show from low to high by the Y please?
CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) )
SELECT HIRE_DATE, SUM(SALARY) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(SALARY)
what is minimum age of patients whose discharge location is disch-tran to psych hosp and primary disease is brain mass;intracranial hemorrhage?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT MIN(demographic.age) FROM demographic WHERE demographic.discharge_location = "DISCH-TRAN TO PSYCH HOSP" AND demographic.diagnosis = "BRAIN MASS;INTRACRANIAL HEMORRHAGE"
Return a bar chart about the distribution of dept_name and the sum of salary , and group by attribute dept_name.
CREATE TABLE instructor ( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(8,2) ) CREATE TABLE department ( dept_name varchar(20), building varchar(15), budget numeric(12,2) ) CREATE TABLE teaches ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0) ) CREATE TABLE course ( course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) ) CREATE TABLE time_slot ( time_slot_id varchar(4), day varchar(1), start_hr numeric(2), start_min numeric(2), end_hr numeric(2), end_min numeric(2) ) CREATE TABLE advisor ( s_ID varchar(5), i_ID varchar(5) ) CREATE TABLE student ( ID varchar(5), name varchar(20), dept_name varchar(20), tot_cred numeric(3,0) ) CREATE TABLE takes ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2) ) CREATE TABLE prereq ( course_id varchar(8), prereq_id varchar(8) ) CREATE TABLE section ( course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_slot_id varchar(4) ) CREATE TABLE classroom ( building varchar(15), room_number varchar(7), capacity numeric(4,0) )
SELECT dept_name, SUM(salary) FROM instructor GROUP BY dept_name ORDER BY salary
Plot mean meter 100 by grouped by meter 200 as a bar graph, and order in ascending by the meter_200.
CREATE TABLE record ( ID int, Result text, Swimmer_ID int, Event_ID int ) CREATE TABLE event ( ID int, Name text, Stadium_ID int, Year text ) CREATE TABLE swimmer ( ID int, name text, Nationality text, meter_100 real, meter_200 text, meter_300 text, meter_400 text, meter_500 text, meter_600 text, meter_700 text, Time text ) CREATE TABLE stadium ( ID int, name text, Capacity int, City text, Country text, Opening_year int )
SELECT meter_200, AVG(meter_100) FROM swimmer GROUP BY meter_200 ORDER BY meter_200
what is the number of patients whose marital status is married and admission year is less than 2103?
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "MARRIED" AND demographic.admityear < "2103"
get me the number of female patients who were hospitalized for more than 7 days.
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.gender = "M" AND demographic.days_stay > "7"
how many patients whose admission year is less than 2154 and drug name is sw?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2154" AND prescriptions.drug = "SW"
Show the outcome code of mailshots along with the number of mailshots in each outcome code in a bar chart, and show y-axis in asc order.
CREATE TABLE Customers ( customer_id INTEGER, payment_method VARCHAR(15), customer_name VARCHAR(80), customer_phone VARCHAR(80), customer_email VARCHAR(80), customer_address VARCHAR(255), customer_login VARCHAR(80), customer_password VARCHAR(10) ) CREATE TABLE Premises ( premise_id INTEGER, premises_type VARCHAR(15), premise_details VARCHAR(255) ) CREATE TABLE Customer_Addresses ( customer_id INTEGER, premise_id INTEGER, date_address_from DATETIME, address_type_code VARCHAR(15), date_address_to DATETIME ) CREATE TABLE Order_Items ( item_id INTEGER, order_item_status_code VARCHAR(15), order_id INTEGER, product_id INTEGER, item_status_code VARCHAR(15), item_delivered_datetime DATETIME, item_order_quantity VARCHAR(80) ) CREATE TABLE Customer_Orders ( order_id INTEGER, customer_id INTEGER, order_status_code VARCHAR(15), shipping_method_code VARCHAR(15), order_placed_datetime DATETIME, order_delivered_datetime DATETIME, order_shipping_charges VARCHAR(255) ) CREATE TABLE Products ( product_id INTEGER, product_category VARCHAR(15), product_name VARCHAR(80) ) CREATE TABLE Mailshot_Customers ( mailshot_id INTEGER, customer_id INTEGER, outcome_code VARCHAR(15), mailshot_customer_date DATETIME ) CREATE TABLE Mailshot_Campaigns ( mailshot_id INTEGER, product_category VARCHAR(15), mailshot_name VARCHAR(80), mailshot_start_date DATETIME, mailshot_end_date DATETIME )
SELECT outcome_code, COUNT(*) FROM Mailshot_Customers GROUP BY outcome_code ORDER BY COUNT(*)
give the number of patients who were admitted before the year 2158 and whose diagnosis long title is unspecified pleural effusion.
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2158" AND diagnoses.long_title = "Unspecified pleural effusion"
give me the number of patients whose death status is 0 and procedure short title is arterial catheterization?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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.short_title = "Arterial catheterization"
What are the login names of the students with family name 'Ward'?
CREATE TABLE student_tests_taken ( registration_id number, date_test_taken time, test_result text ) CREATE TABLE student_course_enrolment ( registration_id number, student_id number, course_id number, date_of_enrolment time, date_of_completion time ) CREATE TABLE students ( student_id number, date_of_registration time, date_of_latest_logon time, login_name text, password text, personal_name text, middle_name text, family_name text ) CREATE TABLE courses ( course_id number, author_id number, subject_id number, course_name text, course_description text ) CREATE TABLE course_authors_and_tutors ( author_id number, author_tutor_atb text, login_name text, password text, personal_name text, middle_name text, family_name text, gender_mf text, address_line_1 text ) CREATE TABLE subjects ( subject_id number, subject_name text )
SELECT login_name FROM students WHERE family_name = "Ward"
Show me a bar chart for what is the total credit does each department offer?, and show total number in asc order.
CREATE TABLE STUDENT ( STU_NUM int, STU_LNAME varchar(15), STU_FNAME varchar(15), STU_INIT varchar(1), STU_DOB datetime, STU_HRS int, STU_CLASS varchar(2), STU_GPA float(8), STU_TRANSFER numeric, DEPT_CODE varchar(18), STU_PHONE varchar(4), PROF_NUM int ) CREATE TABLE EMPLOYEE ( EMP_NUM int, EMP_LNAME varchar(15), EMP_FNAME varchar(12), EMP_INITIAL varchar(1), EMP_JOBCODE varchar(5), EMP_HIREDATE datetime, EMP_DOB datetime ) CREATE TABLE PROFESSOR ( EMP_NUM int, DEPT_CODE varchar(10), PROF_OFFICE varchar(50), PROF_EXTENSION varchar(4), PROF_HIGH_DEGREE varchar(5) ) CREATE TABLE ENROLL ( CLASS_CODE varchar(5), STU_NUM int, ENROLL_GRADE varchar(50) ) CREATE TABLE DEPARTMENT ( DEPT_CODE varchar(10), DEPT_NAME varchar(30), SCHOOL_CODE varchar(8), EMP_NUM int, DEPT_ADDRESS varchar(20), DEPT_EXTENSION varchar(4) ) CREATE TABLE COURSE ( CRS_CODE varchar(10), DEPT_CODE varchar(10), CRS_DESCRIPTION varchar(35), CRS_CREDIT float(8) ) CREATE TABLE CLASS ( CLASS_CODE varchar(5), CRS_CODE varchar(10), CLASS_SECTION varchar(2), CLASS_TIME varchar(20), CLASS_ROOM varchar(8), PROF_NUM int )
SELECT DEPT_CODE, SUM(CRS_CREDIT) FROM COURSE GROUP BY DEPT_CODE ORDER BY SUM(CRS_CREDIT)
How many patients are diagnosed with icd9 code 7098 and have abnormal lab test status?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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 = "7098" AND lab.flag = "abnormal"
what is the number of patients whose marital status is married and ethnicity is white - russian?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "MARRIED" AND demographic.ethnicity = "WHITE - RUSSIAN"
Show the number of courses each instructor taught in a stacked bar chart The x-axis is the instructor's first name and group by course code, and show by the bars from low to high please.
CREATE TABLE STUDENT ( STU_NUM int, STU_LNAME varchar(15), STU_FNAME varchar(15), STU_INIT varchar(1), STU_DOB datetime, STU_HRS int, STU_CLASS varchar(2), STU_GPA float(8), STU_TRANSFER numeric, DEPT_CODE varchar(18), STU_PHONE varchar(4), PROF_NUM int ) CREATE TABLE CLASS ( CLASS_CODE varchar(5), CRS_CODE varchar(10), CLASS_SECTION varchar(2), CLASS_TIME varchar(20), CLASS_ROOM varchar(8), PROF_NUM int ) CREATE TABLE PROFESSOR ( EMP_NUM int, DEPT_CODE varchar(10), PROF_OFFICE varchar(50), PROF_EXTENSION varchar(4), PROF_HIGH_DEGREE varchar(5) ) CREATE TABLE COURSE ( CRS_CODE varchar(10), DEPT_CODE varchar(10), CRS_DESCRIPTION varchar(35), CRS_CREDIT float(8) ) CREATE TABLE EMPLOYEE ( EMP_NUM int, EMP_LNAME varchar(15), EMP_FNAME varchar(12), EMP_INITIAL varchar(1), EMP_JOBCODE varchar(5), EMP_HIREDATE datetime, EMP_DOB datetime ) CREATE TABLE ENROLL ( CLASS_CODE varchar(5), STU_NUM int, ENROLL_GRADE varchar(50) ) CREATE TABLE DEPARTMENT ( DEPT_CODE varchar(10), DEPT_NAME varchar(30), SCHOOL_CODE varchar(8), EMP_NUM int, DEPT_ADDRESS varchar(20), DEPT_EXTENSION varchar(4) )
SELECT EMP_FNAME, COUNT(EMP_FNAME) FROM CLASS AS T1 JOIN EMPLOYEE AS T2 ON T1.PROF_NUM = T2.EMP_NUM GROUP BY CRS_CODE, EMP_FNAME ORDER BY EMP_FNAME
Bar chart x axis occupation y axis how many occupation, and rank by the y-axis from low to high.
CREATE TABLE coach ( Coach_ID int, Coach_name text, Gender text, Club_ID int, Rank int ) CREATE TABLE player_coach ( Player_ID int, Coach_ID int, Starting_year int ) CREATE TABLE player ( Player_ID int, Sponsor_name text, Player_name text, Gender text, Residence text, Occupation text, Votes int, Rank text ) CREATE TABLE club ( Club_ID int, Club_name text, Region text, Start_year int ) CREATE TABLE match_result ( Rank int, Club_ID int, Gold int, Big_Silver int, Small_Silver int, Bronze int, Points int )
SELECT Occupation, COUNT(Occupation) FROM player GROUP BY Occupation ORDER BY COUNT(Occupation)
how many patients whose days of hospital stay is greater than 16 and drug route is po?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "16" AND prescriptions.route = "PO"
For those employees who do not work in departments with managers that have ids between 100 and 200, return a bar chart about the distribution of hire_date and the sum of department_id bin hire_date by weekday, order from low to high by the Y please.
CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) )
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY SUM(DEPARTMENT_ID)
what is the number of patients whose ethnicity is black/haitian and primary disease is aortic insufficiency\re-do sternotomy; aortic valve replacement ?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "BLACK/HAITIAN" AND demographic.diagnosis = "AORTIC INSUFFICIENCY\RE-DO STERNOTOMY; AORTIC VALVE REPLACEMENT "
how many patients whose ethnicity is american indian/alaska native and year of birth is less than 2134?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE" AND demographic.dob_year < "2134"
What are the first name, last name, and gender of all the good customers? Order by their last name.
CREATE TABLE view_product_availability ( product_id number, booking_id number, status_date time, available_yn text ) CREATE TABLE bookings ( booking_id number, customer_id number, booking_status_code text, returned_damaged_yn text, booking_start_date time, booking_end_date time, count_hired text, amount_payable number, amount_of_discount number, amount_outstanding number, amount_of_refund number ) CREATE TABLE customers ( customer_id number, coupon_id number, good_or_bad_customer text, first_name text, last_name text, gender_mf text, date_became_customer time, date_last_hire time ) CREATE TABLE payments ( payment_id number, booking_id number, customer_id number, payment_type_code text, amount_paid_in_full_yn text, payment_date time, amount_due number, amount_paid number ) CREATE TABLE products_for_hire ( product_id number, product_type_code text, daily_hire_cost number, product_name text, product_description text ) CREATE TABLE products_booked ( booking_id number, product_id number, returned_yn text, returned_late_yn text, booked_count number, booked_amount number ) CREATE TABLE discount_coupons ( coupon_id number, date_issued time, coupon_amount number )
SELECT first_name, last_name, gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name
Show each state and the number of addresses in each state Show bar chart, rank X in desc order.
CREATE TABLE Customer_Address_History ( customer_id INTEGER, address_id INTEGER, date_from DATETIME, date_to DATETIME ) CREATE TABLE Customers ( customer_id INTEGER, payment_method_code VARCHAR(15), customer_number VARCHAR(20), customer_name VARCHAR(80), customer_address VARCHAR(255), customer_phone VARCHAR(80), customer_email VARCHAR(80) ) CREATE TABLE Customer_Orders ( order_id INTEGER, customer_id INTEGER, order_date DATETIME, order_status_code VARCHAR(15) ) CREATE TABLE Addresses ( address_id INTEGER, line_1_number_building VARCHAR(80), city VARCHAR(50), zip_postcode VARCHAR(20), state_province_county VARCHAR(50), country VARCHAR(50) ) CREATE TABLE Order_Items ( order_item_id INTEGER, order_id INTEGER, product_id INTEGER, order_quantity VARCHAR(80) ) CREATE TABLE Products ( product_id INTEGER, product_type_code VARCHAR(15), product_name VARCHAR(80), product_price DOUBLE ) CREATE TABLE Contacts ( contact_id INTEGER, customer_id INTEGER, gender VARCHAR(1), first_name VARCHAR(80), last_name VARCHAR(50), contact_phone VARCHAR(80) )
SELECT state_province_county, COUNT(*) FROM Addresses GROUP BY state_province_county ORDER BY state_province_county DESC
For those employees who did not have any job in the past, for department_id, hire_date, visualize the trend, show x axis from high to low order please.
CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) )
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) ORDER BY HIRE_DATE DESC
how many patients are discharged to home health care?
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "HOME HEALTH CARE"
get me the number of patients on additive type drug prescription who have diagnoses icd9 code 45981.
CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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 = "45981" AND prescriptions.drug_type = "ADDITIVE"
what is religion and insurance of subject name kelly gallardo?
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT demographic.religion, demographic.insurance FROM demographic WHERE demographic.name = "Kelly Gallardo"
Find the average of credits of courses that have more than one prerequisite for each department with a bar chart, and sort in desc by the Y please.
CREATE TABLE instructor ( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(8,2) ) CREATE TABLE department ( dept_name varchar(20), building varchar(15), budget numeric(12,2) ) CREATE TABLE course ( course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) ) CREATE TABLE teaches ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0) ) CREATE TABLE time_slot ( time_slot_id varchar(4), day varchar(1), start_hr numeric(2), start_min numeric(2), end_hr numeric(2), end_min numeric(2) ) CREATE TABLE prereq ( course_id varchar(8), prereq_id varchar(8) ) CREATE TABLE takes ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2) ) CREATE TABLE section ( course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_slot_id varchar(4) ) CREATE TABLE classroom ( building varchar(15), room_number varchar(7), capacity numeric(4,0) ) CREATE TABLE student ( ID varchar(5), name varchar(20), dept_name varchar(20), tot_cred numeric(3,0) ) CREATE TABLE advisor ( s_ID varchar(5), i_ID varchar(5) )
SELECT dept_name, AVG(credits) FROM course AS T1 JOIN prereq AS T2 ON T1.course_id = T2.course_id GROUP BY dept_name ORDER BY AVG(credits) DESC
How many patients were admitted with pure hyperglyceridemia before 2187?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2187" AND diagnoses.long_title = "Pure hyperglyceridemia"
For all players, show the number of different club names they come from, order by the total number in asc please.
CREATE TABLE club_rank ( Rank real, Club_ID int, Gold real, Silver real, Bronze real, Total real ) CREATE TABLE competition_result ( Competition_ID int, Club_ID_1 int, Club_ID_2 int, Score text ) CREATE TABLE competition ( Competition_ID int, Year real, Competition_type text, Country text ) CREATE TABLE club ( Club_ID int, name text, Region text, Start_year text ) CREATE TABLE player ( Player_ID int, name text, Position text, Club_ID int, Apps real, Tries real, Goals text, Points real )
SELECT T1.name, COUNT(T1.name) FROM club AS T1 JOIN player AS T2 ON T1.Club_ID = T2.Club_ID GROUP BY T1.name ORDER BY COUNT(T1.name)
For those employees who do not work in departments with managers that have ids between 100 and 200, show me about the distribution of job_id and department_id in a bar chart, and rank by the DEPARTMENT_ID in descending.
CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) )
SELECT JOB_ID, DEPARTMENT_ID FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY DEPARTMENT_ID DESC
For those employees who was hired before 2002-06-21, draw a bar chart about the distribution of hire_date and the sum of department_id bin hire_date by time, and rank by the sum department id in descending please.
CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) )
SELECT HIRE_DATE, SUM(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY SUM(DEPARTMENT_ID) DESC
Get the list of patients with a lab test category of chemistry who have diagnoses icd9 code 2764.
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text )
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."CATEGORY" = "Chemistry"
count the number of patients whose diagnoses long title is cyst and pseudocyst of pancreas and drug type is main?
CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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 = "Cyst and pseudocyst of pancreas" AND prescriptions.drug_type = "MAIN"
count the number of patients whose ethnicity is black/haitian and procedure short title is dx ultrasound-heart?
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.ethnicity = "BLACK/HAITIAN" AND procedures.short_title = "Dx ultrasound-heart"
Bin all date of transactions into the weekday interval, and compute the average of the share count for each bin Return the result using a bar chart, and show by the Y in descending.
CREATE TABLE Ref_Transaction_Types ( transaction_type_code VARCHAR(10), transaction_type_description VARCHAR(80) ) CREATE TABLE Transactions_Lots ( transaction_id INTEGER, lot_id INTEGER ) CREATE TABLE Purchases ( purchase_transaction_id INTEGER, purchase_details VARCHAR(255) ) CREATE TABLE Lots ( lot_id INTEGER, investor_id INTEGER, lot_details VARCHAR(255) ) CREATE TABLE Sales ( sales_transaction_id INTEGER, sales_details VARCHAR(255) ) CREATE TABLE Transactions ( transaction_id INTEGER, investor_id INTEGER, transaction_type_code VARCHAR(10), date_of_transaction DATETIME, amount_of_transaction DECIMAL(19,4), share_count VARCHAR(40), other_details VARCHAR(255) ) CREATE TABLE Investors ( investor_id INTEGER, Investor_details VARCHAR(255) )
SELECT date_of_transaction, AVG(share_count) FROM Transactions ORDER BY AVG(share_count) DESC
Use a histogram to show the department's id and corresponding employees' first name, and order x axis in ascending order please.
CREATE TABLE employees ( EMPLOYEE_ID decimal(6,0), FIRST_NAME varchar(20), LAST_NAME varchar(25), EMAIL varchar(25), PHONE_NUMBER varchar(20), HIRE_DATE date, JOB_ID varchar(10), SALARY decimal(8,2), COMMISSION_PCT decimal(2,2), MANAGER_ID decimal(6,0), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0), START_DATE date, END_DATE date, JOB_ID varchar(10), DEPARTMENT_ID decimal(4,0) ) CREATE TABLE regions ( REGION_ID decimal(5,0), REGION_NAME varchar(25) ) CREATE TABLE departments ( DEPARTMENT_ID decimal(4,0), DEPARTMENT_NAME varchar(30), MANAGER_ID decimal(6,0), LOCATION_ID decimal(4,0) ) CREATE TABLE countries ( COUNTRY_ID varchar(2), COUNTRY_NAME varchar(40), REGION_ID decimal(10,0) ) CREATE TABLE locations ( LOCATION_ID decimal(4,0), STREET_ADDRESS varchar(40), POSTAL_CODE varchar(12), CITY varchar(30), STATE_PROVINCE varchar(25), COUNTRY_ID varchar(2) ) CREATE TABLE jobs ( JOB_ID varchar(10), JOB_TITLE varchar(35), MIN_SALARY decimal(6,0), MAX_SALARY decimal(6,0) )
SELECT FIRST_NAME, DEPARTMENT_ID FROM employees ORDER BY FIRST_NAME
give me the number of patients whose marital status is divorced and procedure short title is closed biopsy of tongue?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.marital_status = "DIVORCED" AND procedures.short_title = "Closed biopsy of tongue"
how many patients whose admission type is emergency and admission year is less than 2164?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.admityear < "2164"
list the number of patients admitted before the year2105.
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admityear < "2105"
A bar chart for what are the number of the names of photos taken with the lens brand 'Sigma' or 'Olympus'?, list in asc by the x-axis.
CREATE TABLE mountain ( id int, name text, Height real, Prominence real, Range text, Country text ) CREATE TABLE photos ( id int, camera_lens_id int, mountain_id int, color text, name text ) CREATE TABLE camera_lens ( id int, brand text, name text, focal_length_mm real, max_aperture real )
SELECT T1.name, COUNT(T1.name) FROM camera_lens AS T1 JOIN photos AS T2 ON T2.camera_lens_id = T1.id WHERE T1.brand = 'Sigma' OR T1.brand = 'Olympus' GROUP BY T1.name ORDER BY T1.name
On which day and in which zip code was the min dew point lower than any day in zip code 94107?
CREATE TABLE trip ( id number, duration number, start_date text, start_station_name text, start_station_id number, end_date text, end_station_name text, end_station_id number, bike_id number, subscription_type text, zip_code number ) CREATE TABLE status ( station_id number, bikes_available number, docks_available number, time text ) CREATE TABLE weather ( date text, max_temperature_f number, mean_temperature_f number, min_temperature_f number, max_dew_point_f number, mean_dew_point_f number, min_dew_point_f number, max_humidity number, mean_humidity number, min_humidity number, max_sea_level_pressure_inches number, mean_sea_level_pressure_inches number, min_sea_level_pressure_inches number, max_visibility_miles number, mean_visibility_miles number, min_visibility_miles number, max_wind_speed_mph number, mean_wind_speed_mph number, max_gust_speed_mph number, precipitation_inches number, cloud_cover number, events text, wind_dir_degrees number, zip_code number ) CREATE TABLE station ( id number, name text, lat number, long number, dock_count number, city text, installation_date text )
SELECT date, zip_code FROM weather WHERE min_dew_point_f < (SELECT MIN(min_dew_point_f) FROM weather WHERE zip_code = 94107)
what is the maximum age of patients who posses self pay insurance and diagnosed with primary disease gangrene?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT MAX(demographic.age) FROM demographic WHERE demographic.insurance = "Self Pay" AND demographic.diagnosis = "GANGRENE"
provide the number of patients whose diagnosis long title is osteoporosis, unspecified and lab test abnormal status is abnormal.
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
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 = "Osteoporosis, unspecified" AND lab.flag = "abnormal"
give the number of patients of hispanic/latino-puerto rican ethnicity who were admitted as newborn.
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "NEWBORN" AND demographic.ethnicity = "HISPANIC/LATINO - PUERTO RICAN"
how many patients whose age is less than 54 and drug name is succinylcholine?
CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "54" AND prescriptions.drug = "Succinylcholine"
how many patients whose age is less than 27 and drug name is meropenem?
CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "27" AND prescriptions.drug = "Meropenem"
What is the name of each course and the corresponding number of student enrollment?
CREATE TABLE student_tests_taken ( registration_id number, date_test_taken time, test_result text ) CREATE TABLE student_course_enrolment ( registration_id number, student_id number, course_id number, date_of_enrolment time, date_of_completion time ) CREATE TABLE students ( student_id number, date_of_registration time, date_of_latest_logon time, login_name text, password text, personal_name text, middle_name text, family_name text ) CREATE TABLE course_authors_and_tutors ( author_id number, author_tutor_atb text, login_name text, password text, personal_name text, middle_name text, family_name text, gender_mf text, address_line_1 text ) CREATE TABLE courses ( course_id number, author_id number, subject_id number, course_name text, course_description text ) CREATE TABLE subjects ( subject_id number, subject_name text )
SELECT T1.course_name, COUNT(*) FROM courses AS T1 JOIN student_course_enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name
Find the number of rooms with more than 50 capacity for each building Show bar chart, and could you sort by the the total number in desc?
CREATE TABLE takes ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), grade varchar(2) ) CREATE TABLE time_slot ( time_slot_id varchar(4), day varchar(1), start_hr numeric(2), start_min numeric(2), end_hr numeric(2), end_min numeric(2) ) CREATE TABLE section ( course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0), building varchar(15), room_number varchar(7), time_slot_id varchar(4) ) CREATE TABLE prereq ( course_id varchar(8), prereq_id varchar(8) ) CREATE TABLE course ( course_id varchar(8), title varchar(50), dept_name varchar(20), credits numeric(2,0) ) CREATE TABLE student ( ID varchar(5), name varchar(20), dept_name varchar(20), tot_cred numeric(3,0) ) CREATE TABLE classroom ( building varchar(15), room_number varchar(7), capacity numeric(4,0) ) CREATE TABLE teaches ( ID varchar(5), course_id varchar(8), sec_id varchar(8), semester varchar(6), year numeric(4,0) ) CREATE TABLE department ( dept_name varchar(20), building varchar(15), budget numeric(12,2) ) CREATE TABLE advisor ( s_ID varchar(5), i_ID varchar(5) ) CREATE TABLE instructor ( ID varchar(5), name varchar(20), dept_name varchar(20), salary numeric(8,2) )
SELECT building, COUNT(*) FROM classroom WHERE capacity > 50 GROUP BY building ORDER BY COUNT(*) DESC
What is the most effective extraction method in terms of pesticide residues detection?
CREATE TABLE resultsdata15 ( sample_pk number, commod text, commtype text, lab text, pestcode text, testclass text, concen number, lod number, conunit text, confmethod text, confmethod2 text, annotate text, quantitate text, mean text, extract text, determin text ) CREATE TABLE sampledata15 ( sample_pk number, state text, year text, month text, day text, site text, commod text, source_id text, variety text, origin text, country text, disttype text, commtype text, claim text, quantity number, growst text, packst text, distst text )
SELECT extract FROM resultsdata15 GROUP BY extract ORDER BY COUNT(*) DESC LIMIT 1
I want to know the proportion of employees for each role code.
CREATE TABLE Document_Locations ( Document_ID INTEGER, Location_Code CHAR(15), Date_in_Location_From DATETIME, Date_in_Locaton_To DATETIME ) CREATE TABLE Ref_Document_Types ( Document_Type_Code CHAR(15), Document_Type_Name VARCHAR(255), Document_Type_Description VARCHAR(255) ) CREATE TABLE Roles ( Role_Code CHAR(15), Role_Name VARCHAR(255), Role_Description VARCHAR(255) ) CREATE TABLE Ref_Calendar ( Calendar_Date DATETIME, Day_Number INTEGER ) CREATE TABLE Employees ( Employee_ID INTEGER, Role_Code CHAR(15), Employee_Name VARCHAR(255), Gender_MFU CHAR(1), Date_of_Birth DATETIME, Other_Details VARCHAR(255) ) CREATE TABLE Documents_to_be_Destroyed ( Document_ID INTEGER, Destruction_Authorised_by_Employee_ID INTEGER, Destroyed_by_Employee_ID INTEGER, Planned_Destruction_Date DATETIME, Actual_Destruction_Date DATETIME, Other_Details VARCHAR(255) ) CREATE TABLE Ref_Locations ( Location_Code CHAR(15), Location_Name VARCHAR(255), Location_Description VARCHAR(255) ) CREATE TABLE All_Documents ( Document_ID INTEGER, Date_Stored DATETIME, Document_Type_Code CHAR(15), Document_Name CHAR(255), Document_Description CHAR(255), Other_Details VARCHAR(255) )
SELECT Role_Code, COUNT(*) FROM Employees GROUP BY Role_Code
what is the number of patients with discharge location as snf diagnosed with primary disease hyperglycemia?
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE procedures ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE prescriptions ( subject_id text, hadm_id text, icustay_id text, drug_type text, drug text, formulary_drug_cd text, route text, drug_dose text ) CREATE TABLE demographic ( subject_id text, hadm_id text, name text, marital_status text, age text, dob text, gender text, language text, religion text, admission_type text, days_stay text, insurance text, ethnicity text, expire_flag text, admission_location text, discharge_location text, diagnosis text, dod text, dob_year text, dod_year text, admittime text, dischtime text, admityear text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text )
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "SNF" AND demographic.diagnosis = "HYPERGLYCEMIA"