schema
stringlengths
29
5.42k
question
stringlengths
0
752
rejected
stringlengths
2
4.44k
chosen
stringlengths
4
8.94k
weight
float64
0
8.73
CREATE TABLE projects (project_id NUMBER, project_details CLOB) CREATE TABLE documents (document_id NUMBER, document_type_code CLOB, project_id NUMBER, document_date TIME, document_name CLOB, document_description CLOB, other_details CLOB) CREATE TABLE statements (statement_id NUMBER, statement_details CLOB) CREATE TABLE ref_budget_codes (budget_type_code CLOB, budget_type_description CLOB) CREATE TABLE ref_document_types (document_type_code CLOB, document_type_name CLOB, document_type_description CLOB) CREATE TABLE documents_with_expenses (document_id NUMBER, budget_type_code CLOB, document_details CLOB) CREATE TABLE accounts (account_id NUMBER, statement_id NUMBER, account_details CLOB)
Show the statement detail and the corresponding document name for the statement with detail 'Private Project'.
SELECT T1.statement_details, T2.document_name FROM statements AS T1 JOIN documents AS T2 ON T1.statement_id = T2.document_id WHERE T1.statement_details = 'Private Project'
SELECT "T1"."statement_details", "T2"."document_name" FROM "statements" "T1" JOIN "documents" "T2" ON "T1"."statement_id" = "T2"."document_id" WHERE "T1"."statement_details" = 'Private Project'
0.188477
CREATE TABLE table_name_80 (result VARCHAR2, score VARCHAR2, couple VARCHAR2)
What was the result for Steve & Anna when the score was 21 (7, 7, 7)?
SELECT result FROM table_name_80 WHERE score = "21 (7, 7, 7)" AND couple = "steve & anna"
SELECT "result" FROM "table_name_80" WHERE "21 (7, 7, 7)" = "score" AND "couple" = "steve & anna"
0.094727
CREATE TABLE table_name_15 (date VARCHAR2, motogp_winner VARCHAR2, grand_prix VARCHAR2)
Name the date for motogp winner of casey stoner and grand prix of valencian grand prix
SELECT date FROM table_name_15 WHERE motogp_winner = "casey stoner" AND grand_prix = "valencian grand prix"
SELECT "date" FROM "table_name_15" WHERE "casey stoner" = "motogp_winner" AND "grand_prix" = "valencian grand prix"
0.112305
CREATE TABLE party_events (event_id NUMBER, event_name CLOB, party_id NUMBER, member_in_charge_id NUMBER) CREATE TABLE party (party_id NUMBER, minister CLOB, took_office CLOB, left_office CLOB, region_id NUMBER, party_name CLOB) CREATE TABLE region (region_id NUMBER, region_name CLOB, date CLOB, label CLOB, format CLOB, catalogue CLOB) CREATE TABLE member (member_id NUMBER, member_name CLOB, party_id CLOB, in_office CLOB)
How many parties do we have?
SELECT COUNT(DISTINCT party_name) FROM party
SELECT COUNT(DISTINCT "party_name") FROM "party"
0.046875
CREATE TABLE table_204_130 (id NUMBER, "#" NUMBER, "date" CLOB, "venue" CLOB, "opponent" CLOB, "score" CLOB, "result" CLOB, "competition" CLOB)
who is the opponent listed after japan ?
SELECT "opponent" FROM table_204_130 WHERE id = (SELECT id FROM table_204_130 WHERE "opponent" = 'japan') + 1
SELECT "opponent" FROM "table_204_130" WHERE "id" = (SELECT "id" FROM "table_204_130" WHERE "opponent" = 'japan') + 1
0.114258
CREATE TABLE table_name_26 (points_for VARCHAR2, try_bonus VARCHAR2)
What Points for has a Try bonus of 140?
SELECT points_for FROM table_name_26 WHERE try_bonus = "140"
SELECT "points_for" FROM "table_name_26" WHERE "140" = "try_bonus"
0.064453
CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME)
had patient 029-16737 receive a surgery consultation procedure until 3 years ago?
SELECT COUNT(*) > 0 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '029-16737')) AND treatment.treatmentname = 'surgery consultation' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-3 year')
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '029-16737' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid") SELECT COUNT(*) > 0 FROM "treatment" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "treatment"."patientunitstayid" WHERE "treatment"."treatmentname" = 'surgery consultation' AND DATETIME("treatment"."treatmenttime") <= DATETIME(CURRENT_TIME(), '-3 year') AND NOT "_u_1"."" IS NULL
0.613281
CREATE TABLE table_57793 ("Driver" CLOB, "Constructor" CLOB, "Laps" FLOAT, "Time/Retired" CLOB, "Grid" FLOAT)
How many laps for a grid of over 18 and retired due to electrical failure?
SELECT SUM("Laps") FROM table_57793 WHERE "Grid" > '18' AND "Time/Retired" = 'electrical'
SELECT SUM("Laps") FROM "table_57793" WHERE "Grid" > '18' AND "Time/Retired" = 'electrical'
0.088867
CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2) CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2) CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE employees (EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2, LAST_NAME VARCHAR2, EMAIL VARCHAR2, PHONE_NUMBER VARCHAR2, HIRE_DATE DATE, JOB_ID VARCHAR2, SALARY NUMBER, COMMISSION_PCT NUMBER, MANAGER_ID NUMBER, DEPARTMENT_ID NUMBER) CREATE TABLE departments (DEPARTMENT_ID NUMBER, DEPARTMENT_NAME VARCHAR2, MANAGER_ID NUMBER, LOCATION_ID NUMBER) CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID NUMBER)
For all employees who have the letters D or S in their first name, give me the comparison about the amount of hire_date over the hire_date bin hire_date by weekday by a bar chart, show by the how many hire date in ascending.
SELECT HIRE_DATE, COUNT(HIRE_DATE) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY COUNT(HIRE_DATE)
SELECT "HIRE_DATE", COUNT("HIRE_DATE") FROM "employees" WHERE "FIRST_NAME" LIKE '%D%' OR "FIRST_NAME" LIKE '%S%' ORDER BY COUNT("HIRE_DATE")
0.136719
CREATE TABLE table_name_83 (title VARCHAR2, year VARCHAR2, genre VARCHAR2)
What was the title of Ashanti's 2003 rap song?
SELECT title FROM table_name_83 WHERE year = 2003 AND genre = "rap"
SELECT "title" FROM "table_name_83" WHERE "genre" = "rap" AND "year" = 2003
0.073242
CREATE TABLE table_name_2 (_m__best_ VARCHAR2, _fairest VARCHAR2, president VARCHAR2, _m__coach VARCHAR2)
Who was the (M) Best & Fairest when ray kaduck was president and richard keane was coach?
SELECT _m__best_ & _fairest FROM table_name_2 WHERE president = "ray kaduck" AND _m__coach = "richard keane"
SELECT "_m__best_" & "_fairest" FROM "table_name_2" WHERE "_m__coach" = "richard keane" AND "president" = "ray kaduck"
0.115234
CREATE TABLE Movie (mID NUMBER, title CLOB, year NUMBER, director CLOB) CREATE TABLE Reviewer (rID NUMBER, name CLOB) CREATE TABLE Rating (rID NUMBER, mID NUMBER, stars NUMBER, ratingDate DATE)
Ignore movies whose director is NULL For each director, what are the titles and the highest rating among all of their movies they reviewed? Draw the result by a bar chart, and show stars in descending order.
SELECT title, MAX(T1.stars) FROM Rating AS T1 JOIN Movie AS T2 ON T1.mID = T2.mID WHERE director <> "null" GROUP BY title ORDER BY MAX(T1.stars) DESC
SELECT "title", MAX("T1"."stars") FROM "Rating" "T1" JOIN "Movie" "T2" ON "T1"."mID" = "T2"."mID" WHERE "director" <> "null" GROUP BY "title" ORDER BY MAX("T1"."stars") DESC
0.168945
CREATE TABLE table_204_938 (id NUMBER, "year" NUMBER, "edmonton\ hundred" NUMBER, "elthorne\ hundred" NUMBER, "gore\ hundred" NUMBER, "isleworth\ hundred" NUMBER, "ossulstone\ hundred\ holborn\ division" NUMBER, "ossulstone\ hundred\ finsbury\ division" NUMBER, "ossulstone\ hundred\ kensington\ division" NUMBER, "ossulstone\ hundred\ tower\ division" NUMBER, "spelthorne\ hundred" NUMBER, "london city\ within\ the walls" NUMBER, "london city\ without\ the walls" NUMBER, "inns of court\ and\ chancery" NUMBER, "westminster\ city and\ liberty" NUMBER, "total" NUMBER)
what is the difference between the elthorne hundred and the gore hundred in 1831 ?
SELECT ABS("elthorne\nhundred" - "gore\nhundred") FROM table_204_938 WHERE "year" = 1831
SELECT ABS("elthorne\nhundred" - "gore\nhundred") FROM "table_204_938" WHERE "year" = 1831
0.087891
CREATE TABLE member (Member_ID CLOB, Name CLOB, Nationality CLOB, Role CLOB) CREATE TABLE member_attendance (Member_ID NUMBER, Performance_ID NUMBER, Num_of_Pieces NUMBER) CREATE TABLE performance (Performance_ID FLOAT, Date CLOB, Host CLOB, Location CLOB, Attendance NUMBER)
Bar chart x axis location y axis how many location
SELECT Location, COUNT(Location) FROM performance GROUP BY Location
SELECT "Location", COUNT("Location") FROM "performance" GROUP BY "Location"
0.073242
CREATE TABLE table_name_43 (club VARCHAR2, season VARCHAR2, goals VARCHAR2, apps VARCHAR2)
In the 2010 season what club has 0 goals and more than 0 Apps?
SELECT club FROM table_name_43 WHERE goals = 0 AND apps > 0 AND season = "2010"
SELECT "club" FROM "table_name_43" WHERE "2010" = "season" AND "apps" > 0 AND "goals" = 0
0.086914
CREATE TABLE table_name_31 (elected VARCHAR2, party VARCHAR2, incumbent VARCHAR2)
What was the year Elected of Republican Incumbent Dave Reichert?
SELECT elected FROM table_name_31 WHERE party = "republican" AND incumbent = "dave reichert"
SELECT "elected" FROM "table_name_31" WHERE "dave reichert" = "incumbent" AND "party" = "republican"
0.097656
CREATE TABLE stadium (ID NUMBER, name CLOB, Capacity NUMBER, City CLOB, Country CLOB, Opening_year NUMBER) CREATE TABLE swimmer (ID NUMBER, name CLOB, Nationality CLOB, meter_100 FLOAT, meter_200 CLOB, meter_300 CLOB, meter_400 CLOB, meter_500 CLOB, meter_600 CLOB, meter_700 CLOB, Time CLOB) CREATE TABLE record (ID NUMBER, Result CLOB, Swimmer_ID NUMBER, Event_ID NUMBER) CREATE TABLE event (ID NUMBER, Name CLOB, Stadium_ID NUMBER, Year CLOB)
Return a bar chart about the distribution of Nationality and the sum of ID , and group by attribute Nationality, I want to sort from high to low by the y-axis.
SELECT Nationality, SUM(ID) FROM swimmer GROUP BY Nationality ORDER BY SUM(ID) DESC
SELECT "Nationality", SUM("ID") FROM "swimmer" GROUP BY "Nationality" ORDER BY SUM("ID") DESC
0.09082
CREATE TABLE table_204_982 (id NUMBER, "party/electoral alliance" CLOB, "seats" NUMBER, "change" NUMBER, "votes" NUMBER, "%" CLOB)
total number of parties who lost seats in the argentine chamber of deputies in the legislative election of 1930
SELECT COUNT("party/electoral alliance") FROM table_204_982 WHERE "change" < 0
SELECT COUNT("party/electoral alliance") FROM "table_204_982" WHERE "change" < 0
0.078125
CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER)
what exactly was the name of the drug that patient 030-42006 was prescribed in the same day after receiving a drug levels procedure in 07/this year?
SELECT t2.drugname FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-42006') AND treatment.treatmentname = 'drug levels' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', treatment.treatmenttime) = '07') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-42006') AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m', medication.drugstarttime) = '07') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t1.treatmenttime, 'start of day') = DATETIME(t2.drugstarttime, 'start of day')
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '030-42006' GROUP BY "patienthealthsystemstayid"), "t2" AS (SELECT "patient"."uniquepid", "medication"."drugname", "medication"."drugstarttime" FROM "medication" JOIN "patient" ON "medication"."patientunitstayid" = "patient"."patientunitstayid" LEFT JOIN "_u_0" "_u_1" ON "_u_1"."" = "patient"."patienthealthsystemstayid" WHERE DATETIME("medication"."drugstarttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND NOT "_u_1"."" IS NULL AND STRFTIME('%m', "medication"."drugstarttime") = '07') SELECT "t2"."drugname" FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" JOIN "t2" "t2" ON "patient"."uniquepid" = "t2"."uniquepid" AND "t2"."drugstarttime" > "treatment"."treatmenttime" AND DATETIME("t2"."drugstarttime", 'start of day') = DATETIME("treatment"."treatmenttime", 'start of day') WHERE "treatment"."treatmentname" = 'drug levels' AND DATETIME("treatment"."treatmenttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND NOT "_u_0"."" IS NULL AND STRFTIME('%m', "treatment"."treatmenttime") = '07'
1.261719
CREATE TABLE table_name_88 (year VARCHAR2, score VARCHAR2)
Which Year has a Score of 5 7, 4 6, 6 3, 1 6?
SELECT year FROM table_name_88 WHERE score = "5–7, 4–6, 6–3, 1–6"
SELECT "year" FROM "table_name_88" WHERE "5–7, 4–6, 6–3, 1–6" = "score"
0.069336
CREATE TABLE table_32473 ("Name" CLOB, "Release date" CLOB, "RTM build" CLOB, "Current version" CLOB, "Status support" CLOB, "License" CLOB, "Based on ( kernel ) " CLOB, "Supported architectures" CLOB, "OS type" CLOB)
What is the RTM build of the Windows Home Server 2011?
SELECT "RTM build" FROM table_32473 WHERE "Name" = 'windows home server 2011'
SELECT "RTM build" FROM "table_32473" WHERE "Name" = 'windows home server 2011'
0.077148
CREATE TABLE departments (DEPARTMENT_ID NUMBER, DEPARTMENT_NAME VARCHAR2, MANAGER_ID NUMBER, LOCATION_ID NUMBER) CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2) CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE employees (EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2, LAST_NAME VARCHAR2, EMAIL VARCHAR2, PHONE_NUMBER VARCHAR2, HIRE_DATE DATE, JOB_ID VARCHAR2, SALARY NUMBER, COMMISSION_PCT NUMBER, MANAGER_ID NUMBER, DEPARTMENT_ID NUMBER) CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID NUMBER) CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2)
For all employees who have the letters D or S in their first name, a line chart shows the change of salary over hire_date, and sort by the x axis in ascending.
SELECT HIRE_DATE, SALARY FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY HIRE_DATE
SELECT "HIRE_DATE", "SALARY" FROM "employees" WHERE "FIRST_NAME" LIKE '%D%' OR "FIRST_NAME" LIKE '%S%' ORDER BY "HIRE_DATE"
0.120117
CREATE TABLE table_32202 ("Year" FLOAT, "Team Name" CLOB, "Wins" FLOAT, "Losses" FLOAT, "W-L %" CLOB, "Manager" CLOB)
What is the win/loss percentage with wins of 63 and losses smaller than 76?
SELECT "W-L %" FROM table_32202 WHERE "Wins" = '63' AND "Losses" < '76'
SELECT "W-L %" FROM "table_32202" WHERE "Losses" < '76' AND "Wins" = '63'
0.071289
CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
count the number of patients whose insurance is medicare and diagnoses short title is ben neo spinal meninges?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.insurance = "Medicare" AND diagnoses.short_title = "Ben neo spinal meninges"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Ben neo spinal meninges" = "diagnoses"."short_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "Medicare" = "demographic"."insurance"
0.233398
CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2) CREATE TABLE departments (DEPARTMENT_ID NUMBER, DEPARTMENT_NAME VARCHAR2, MANAGER_ID NUMBER, LOCATION_ID NUMBER) CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID NUMBER) CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2) CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE employees (EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2, LAST_NAME VARCHAR2, EMAIL VARCHAR2, PHONE_NUMBER VARCHAR2, HIRE_DATE DATE, JOB_ID VARCHAR2, SALARY NUMBER, COMMISSION_PCT NUMBER, MANAGER_ID NUMBER, DEPARTMENT_ID NUMBER)
For those employees who was hired before 2002-06-21, show me about the distribution of job_id and the average of manager_id , and group by attribute job_id in a bar chart, and show by the total number in ascending.
SELECT JOB_ID, AVG(MANAGER_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' GROUP BY JOB_ID ORDER BY AVG(MANAGER_ID)
SELECT "JOB_ID", AVG("MANAGER_ID") FROM "employees" WHERE "HIRE_DATE" < '2002-06-21' GROUP BY "JOB_ID" ORDER BY AVG("MANAGER_ID")
0.125977
CREATE TABLE table_name_1 (crowd VARCHAR2, date VARCHAR2, away_team VARCHAR2)
When the Away team footscray played on the Date of 19 july 1980, what was the amount of people in the Crowd?
SELECT crowd FROM table_name_1 WHERE date = "19 july 1980" AND away_team = "footscray"
SELECT "crowd" FROM "table_name_1" WHERE "19 july 1980" = "date" AND "away_team" = "footscray"
0.091797
CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME)
has patient 021-221706 made to an admission until 2104?
SELECT COUNT(*) > 0 FROM patient WHERE patient.uniquepid = '021-221706' AND STRFTIME('%y', patient.hospitaladmittime) <= '2104'
SELECT COUNT(*) > 0 FROM "patient" WHERE "patient"."uniquepid" = '021-221706' AND STRFTIME('%y', "patient"."hospitaladmittime") <= '2104'
0.133789
CREATE TABLE table_30162 ("Proceed to Quarter-final" CLOB, "Match points" CLOB, "Aggregate score" CLOB, "Points margin" FLOAT, "Eliminated from competition" CLOB)
What were the match points when Bordeaux-B gles was eliminated from competition?
SELECT "Match points" FROM table_30162 WHERE "Eliminated from competition" = 'Bordeaux-Bègles'
SELECT "Match points" FROM "table_30162" WHERE "Eliminated from competition" = 'Bordeaux-Bègles'
0.09375
CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME)
indicate the daily minimum amount of respiration for patient 025-56111 on the last icu visit.
SELECT MIN(vitalperiodic.respiration) FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-56111') AND NOT patient.unitdischargetime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1) AND NOT vitalperiodic.respiration IS NULL GROUP BY STRFTIME('%y-%m-%d', vitalperiodic.observationtime)
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '025-56111' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL AND NOT "patient"."unitdischargetime" IS NULL GROUP BY "patientunitstayid" ORDER BY "patient"."unitadmittime" DESC FETCH FIRST 1 ROWS ONLY) SELECT MIN("vitalperiodic"."respiration") FROM "vitalperiodic" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "vitalperiodic"."patientunitstayid" WHERE NOT "_u_1"."" IS NULL AND NOT "vitalperiodic"."respiration" IS NULL GROUP BY STRFTIME('%y-%m-%d', "vitalperiodic"."observationtime")
0.723633
CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB)
how many patients are under age 55 and tested with lab item id 51026?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.age < "55" AND lab.itemid = "51026"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "51026" = "lab"."itemid" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "55" > "demographic"."age"
0.181641
CREATE TABLE table_name_2 (icao VARCHAR2, iata VARCHAR2)
What is the ICAO when the IATA shows mfm?
SELECT icao FROM table_name_2 WHERE iata = "mfm"
SELECT "icao" FROM "table_name_2" WHERE "iata" = "mfm"
0.052734
CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2) CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID NUMBER) CREATE TABLE employees (EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2, LAST_NAME VARCHAR2, EMAIL VARCHAR2, PHONE_NUMBER VARCHAR2, HIRE_DATE DATE, JOB_ID VARCHAR2, SALARY NUMBER, COMMISSION_PCT NUMBER, MANAGER_ID NUMBER, DEPARTMENT_ID NUMBER) CREATE TABLE departments (DEPARTMENT_ID NUMBER, DEPARTMENT_NAME VARCHAR2, MANAGER_ID NUMBER, LOCATION_ID NUMBER) CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2)
For those employees who do not work in departments with managers that have ids between 100 and 200, a line chart shows the change of commission_pct over hire_date, and sort X in asc order.
SELECT HIRE_DATE, COMMISSION_PCT FROM employees WHERE NOT DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM departments WHERE MANAGER_ID BETWEEN 100 AND 200) ORDER BY HIRE_DATE
SELECT "HIRE_DATE", "COMMISSION_PCT" FROM "employees" WHERE NOT "DEPARTMENT_ID" IN (SELECT "DEPARTMENT_ID" FROM "departments" WHERE "MANAGER_ID" <= 200 AND "MANAGER_ID" >= 100) ORDER BY "HIRE_DATE"
0.192383
CREATE TABLE table_204_261 (id NUMBER, "rank" NUMBER, "nation" CLOB, "gold" NUMBER, "silver" NUMBER, "bronze" NUMBER, "total" NUMBER)
which nation ranked in first with the most amount of total medals ?
SELECT "nation" FROM table_204_261 ORDER BY "total" DESC LIMIT 1
SELECT "nation" FROM "table_204_261" ORDER BY "total" DESC FETCH FIRST 1 ROWS ONLY
0.080078
CREATE TABLE roller_coaster (roller_coaster_id NUMBER, name CLOB, park CLOB, country_id NUMBER, length NUMBER, height NUMBER, speed CLOB, opened CLOB, status CLOB) CREATE TABLE country (country_id NUMBER, name CLOB, population NUMBER, area NUMBER, languages CLOB)
How many roller coasters are there?
SELECT COUNT(*) FROM roller_coaster
SELECT COUNT(*) FROM "roller_coaster"
0.036133
CREATE TABLE table_name_19 (format VARCHAR2, region VARCHAR2)
Which format has a region of united kingdom?
SELECT format FROM table_name_19 WHERE region = "united kingdom"
SELECT "format" FROM "table_name_19" WHERE "region" = "united kingdom"
0.068359
CREATE TABLE table_204_32 (id NUMBER, "season" NUMBER, "division" CLOB, "w-l" CLOB, "finish" CLOB, "home" CLOB, "road" CLOB, "gf" NUMBER, "ga" NUMBER, "coach" CLOB, "playoffs" CLOB, "avg attendance" NUMBER)
amount of seasons with a winning record
SELECT COUNT("season") FROM table_204_32 WHERE "w-l" > "w-l"
SELECT COUNT("season") FROM "table_204_32" WHERE "w-l" > "w-l"
0.060547
CREATE TABLE table_13258876_2 (result VARCHAR2, attendance VARCHAR2)
What was the score of the game when the attendance was 48945?
SELECT result FROM table_13258876_2 WHERE attendance = 48945
SELECT "result" FROM "table_13258876_2" WHERE "attendance" = 48945
0.064453
CREATE TABLE table_204_321 (id NUMBER, "community" CLOB, "currency" CLOB, "region" CLOB, "target date" NUMBER, "notes" CLOB)
what is the only proposed community in the south asia region ?
SELECT "community" FROM table_204_321 WHERE "region" = 'south asia'
SELECT "community" FROM "table_204_321" WHERE "region" = 'south asia'
0.067383
CREATE TABLE table_204_965 (id NUMBER, "year" CLOB, "city" CLOB, "state , province , dept. , etc." CLOB, "country" CLOB, "notes" CLOB)
what was the capital of puerto rico after caparra ?
SELECT "city" FROM table_204_965 WHERE "state, province, dept., etc." = 'puerto rico' AND "year" > (SELECT "year" FROM table_204_965 WHERE "city" = 'caparra') ORDER BY "year" LIMIT 1
SELECT "city" FROM "table_204_965" WHERE "state, province, dept., etc." = 'puerto rico' AND "year" > (SELECT "year" FROM "table_204_965" WHERE "city" = 'caparra') ORDER BY "year" FETCH FIRST 1 ROWS ONLY
0.197266
CREATE TABLE table_26096 ("Province" CLOB, "Contestant" CLOB, "Age" FLOAT, "Height ( in ) " CLOB, "Height ( mt ) " CLOB, "Hometown" CLOB)
What is the height in inches of contestants who are from the province of La Rioja?
SELECT "Height (in)" FROM table_26096 WHERE "Province" = 'La Rioja'
SELECT "Height (in)" FROM "table_26096" WHERE "Province" = 'La Rioja'
0.067383
CREATE TABLE table_67242 ("Year" FLOAT, "Entrant" CLOB, "Chassis" CLOB, "Engine" CLOB, "Points" FLOAT)
What entrant had a Maserati 250F chassis and fewer than 6 points before 1957?
SELECT "Entrant" FROM table_67242 WHERE "Chassis" = 'maserati 250f' AND "Year" < '1957' AND "Points" < '6'
SELECT "Entrant" FROM "table_67242" WHERE "Chassis" = 'maserati 250f' AND "Points" < '6' AND "Year" < '1957'
0.105469
CREATE TABLE table_name_5 (arena VARCHAR2, founded VARCHAR2)
Which arena was founded in 2000?
SELECT arena FROM table_name_5 WHERE founded = 2000
SELECT "arena" FROM "table_name_5" WHERE "founded" = 2000
0.055664
CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME)
were there any results of microbiological tests on patient 031-3507's stool?
SELECT COUNT(*) FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-3507')) AND microlab.culturesite = 'stool'
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '031-3507' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid") SELECT COUNT(*) FROM "microlab" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "microlab"."patientunitstayid" WHERE "microlab"."culturesite" = 'stool' AND NOT "_u_1"."" IS NULL
0.509766
CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
How many patients have had an open and other sigmoidectomy procedure?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE procedures.long_title = "Open and other sigmoidectomy"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "procedures" ON "Open and other sigmoidectomy" = "procedures"."long_title" AND "demographic"."hadm_id" = "procedures"."hadm_id"
0.196289
CREATE TABLE table_name_38 (vin_code VARCHAR2)
What's the compression ratio when the vin code is c?
SELECT "c" AS ompression_ratio FROM table_name_38 WHERE vin_code = "c"
SELECT "c" AS "ompression_ratio" FROM "table_name_38" WHERE "c" = "vin_code"
0.074219
CREATE TABLE table_203_780 (id NUMBER, "rank" NUMBER, "diver" CLOB, "preliminary\ points" NUMBER, "preliminary\ rank" NUMBER, "final\ points" NUMBER, "final\ rank" NUMBER, "final\ total" NUMBER)
what is the difference in the total score between first and second place ?
SELECT ABS((SELECT "final\ntotal" FROM table_203_780 WHERE "rank" = 1) - (SELECT "final\ntotal" FROM table_203_780 WHERE "rank" = 2))
SELECT ABS((SELECT "final\ntotal" FROM "table_203_780" WHERE "rank" = 1) - (SELECT "final\ntotal" FROM "table_203_780" WHERE "rank" = 2))
0.133789
CREATE TABLE table_name_97 (week NUMBER, result VARCHAR2, partner VARCHAR2)
In what Week resulting in the bottom 3 was Endre Jansen Partner?
SELECT MAX(week) FROM table_name_97 WHERE result = "bottom 3" AND partner = "endre jansen"
SELECT MAX("week") FROM "table_name_97" WHERE "bottom 3" = "result" AND "endre jansen" = "partner"
0.095703
CREATE TABLE cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name CLOB) CREATE TABLE prescriptions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, startdate TIME, enddate TIME, drug CLOB, dose_val_rx CLOB, dose_unit_rx CLOB, route CLOB) CREATE TABLE icustays (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, first_careunit CLOB, last_careunit CLOB, first_wardid NUMBER, last_wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE d_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label CLOB) CREATE TABLE chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) CREATE TABLE transfers (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, eventtype CLOB, careunit CLOB, wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE admissions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, admittime TIME, dischtime TIME, admission_type CLOB, admission_location CLOB, discharge_location CLOB, insurance CLOB, language CLOB, marital_status CLOB, ethnicity CLOB, age NUMBER) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) CREATE TABLE procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME)
did patient 17944 during this year receive a base excess lab test?
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'base excess') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 17944) AND DATETIME(labevents.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
WITH "_u_0" AS (SELECT "d_labitems"."itemid" FROM "d_labitems" WHERE "d_labitems"."label" = 'base excess' GROUP BY "itemid"), "_u_1" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 17944 GROUP BY "hadm_id") SELECT COUNT(*) > 0 FROM "labevents" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "labevents"."itemid" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "labevents"."hadm_id" WHERE DATETIME("labevents"."charttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND NOT "_u_0"."" IS NULL AND NOT "_u_1"."" IS NULL
0.552734
CREATE TABLE table_79560 ("Tie no" CLOB, "Home team" CLOB, "Score" CLOB, "Away team" CLOB, "Date" CLOB)
Which tie number had an away team of Arsenal?
SELECT "Tie no" FROM table_79560 WHERE "Away team" = 'arsenal'
SELECT "Tie no" FROM "table_79560" WHERE "Away team" = 'arsenal'
0.0625
CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
what is primary disease and drug name of subject id 85673?
SELECT demographic.diagnosis, prescriptions.drug FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.subject_id = "85673"
SELECT "demographic"."diagnosis", "prescriptions"."drug" FROM "demographic" JOIN "prescriptions" ON "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "85673" = "demographic"."subject_id"
0.189453
CREATE TABLE table_name_28 (area__km_2__ NUMBER, population__2011_ VARCHAR2, density__inhabitants_km_2__ VARCHAR2, name VARCHAR2)
What is the area in km2 for Cape Agulhas, whose density is larger than 9.4 inhabitants/km2 and whose population in 2011 was less than 33,038?
SELECT MAX(area__km_2__) FROM table_name_28 WHERE density__inhabitants_km_2__ > 9.4 AND name = "cape agulhas" AND population__2011_ < 33 OFFSET 038
SELECT MAX("area__km_2__") FROM "table_name_28" WHERE "cape agulhas" = "name" AND "density__inhabitants_km_2__" > 9.4 AND "population__2011_" < 33 OFFSET 038 ROWS
0.158203
CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB)
give me the number of patients whose admission type is elective and lab test name is sodium?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND lab.label = "Sodium"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "Sodium" = "lab"."label" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "ELECTIVE" = "demographic"."admission_type"
0.198242
CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB)
give me the number of patients whose gender is f and primary disease is gastrointestinal bleed?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.gender = "F" AND demographic.diagnosis = "GASTROINTESTINAL BLEED"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "F" = "demographic"."gender" AND "GASTROINTESTINAL BLEED" = "demographic"."diagnosis"
0.15625
CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB)
how many patients are below 56 years of age and use the main drug type?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "56" AND prescriptions.drug_type = "MAIN"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "MAIN" = "prescriptions"."drug_type" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "56" > "demographic"."age"
0.212891
CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB)
how many patients whose marital status is divorced and gender is m?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.marital_status = "DIVORCED" AND demographic.gender = "M"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "DIVORCED" = "demographic"."marital_status" AND "M" = "demographic"."gender"
0.147461
CREATE TABLE table_1341472_34 (first_elected VARCHAR2, district VARCHAR2)
Name the first elected for new york 1
SELECT COUNT(first_elected) FROM table_1341472_34 WHERE district = "New York 1"
SELECT COUNT("first_elected") FROM "table_1341472_34" WHERE "New York 1" = "district"
0.083008
CREATE TABLE city (city_code VARCHAR2, city_name VARCHAR2, state_code VARCHAR2, country_name VARCHAR2, time_zone_code VARCHAR2) CREATE TABLE days (days_code VARCHAR2, day_name VARCHAR2) CREATE TABLE date_day (month_number NUMBER, day_number NUMBER, year NUMBER, day_name VARCHAR2) CREATE TABLE airport (airport_code VARCHAR2, airport_name CLOB, airport_location CLOB, state_code VARCHAR2, country_name VARCHAR2, time_zone_code VARCHAR2, minimum_connect_time NUMBER) CREATE TABLE flight_leg (flight_id NUMBER, leg_number NUMBER, leg_flight NUMBER) CREATE TABLE aircraft (aircraft_code VARCHAR2, aircraft_description VARCHAR2, manufacturer VARCHAR2, basic_type VARCHAR2, engines NUMBER, propulsion VARCHAR2, wide_body VARCHAR2, wing_span NUMBER, length NUMBER, weight NUMBER, capacity NUMBER, pay_load NUMBER, cruising_speed NUMBER, range_miles NUMBER, pressurized VARCHAR2) CREATE TABLE month (month_number NUMBER, month_name CLOB) CREATE TABLE flight (aircraft_code_sequence CLOB, airline_code VARCHAR2, airline_flight CLOB, arrival_time NUMBER, connections NUMBER, departure_time NUMBER, dual_carrier CLOB, flight_days CLOB, flight_id NUMBER, flight_number NUMBER, from_airport VARCHAR2, meal_code CLOB, stops NUMBER, time_elapsed NUMBER, to_airport VARCHAR2) CREATE TABLE time_zone (time_zone_code CLOB, time_zone_name CLOB, hours_from_gmt NUMBER) CREATE TABLE food_service (meal_code CLOB, meal_number NUMBER, compartment CLOB, meal_description VARCHAR2) CREATE TABLE dual_carrier (main_airline VARCHAR2, low_flight_number NUMBER, high_flight_number NUMBER, dual_airline VARCHAR2, service_name CLOB) CREATE TABLE class_of_service (booking_class VARCHAR2, rank NUMBER, class_description CLOB) CREATE TABLE airport_service (city_code VARCHAR2, airport_code VARCHAR2, miles_distant NUMBER, direction VARCHAR2, minutes_distant NUMBER) CREATE TABLE flight_fare (flight_id NUMBER, fare_id NUMBER) CREATE TABLE ground_service (city_code CLOB, airport_code CLOB, transport_type CLOB, ground_fare NUMBER) CREATE TABLE fare (fare_id NUMBER, from_airport VARCHAR2, to_airport VARCHAR2, fare_basis_code CLOB, fare_airline CLOB, restriction_code CLOB, one_direction_cost NUMBER, round_trip_cost NUMBER, round_trip_required VARCHAR2) CREATE TABLE flight_stop (flight_id NUMBER, stop_number NUMBER, stop_days CLOB, stop_airport CLOB, arrival_time NUMBER, arrival_airline CLOB, arrival_flight_number NUMBER, departure_time NUMBER, departure_airline CLOB, departure_flight_number NUMBER, stop_time NUMBER) CREATE TABLE restriction (restriction_code CLOB, advance_purchase NUMBER, stopovers CLOB, saturday_stay_required CLOB, minimum_stay NUMBER, maximum_stay NUMBER, application CLOB, no_discounts CLOB) CREATE TABLE time_interval (period CLOB, begin_time NUMBER, end_time NUMBER) CREATE TABLE state (state_code CLOB, state_name CLOB, country_name CLOB) CREATE TABLE equipment_sequence (aircraft_code_sequence VARCHAR2, aircraft_code VARCHAR2) CREATE TABLE code_description (code VARCHAR2, description CLOB) CREATE TABLE compartment_class (compartment VARCHAR2, class_type VARCHAR2) CREATE TABLE airline (airline_code VARCHAR2, airline_name CLOB, note CLOB) CREATE TABLE fare_basis (fare_basis_code CLOB, booking_class CLOB, class_type CLOB, premium CLOB, economy CLOB, discounted CLOB, night CLOB, season CLOB, basis_days CLOB)
show me the flights from BOSTON to SAN FRANCISCO leaving after 1600 on friday
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE ((date_day.day_number = 25 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.departure_time > 1600 AND flight.flight_days = days.days_code) AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SAN FRANCISCO' AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'BOSTON' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code
SELECT DISTINCT "flight"."flight_id" FROM "airport_service" "AIRPORT_SERVICE_0" JOIN "date_day" ON "date_day"."day_number" = 25 AND "date_day"."month_number" = 6 AND "date_day"."year" = 1991 JOIN "city" "CITY_0" ON "AIRPORT_SERVICE_0"."city_code" = "CITY_0"."city_code" AND "CITY_0"."city_name" = 'BOSTON' JOIN "days" ON "date_day"."day_name" = "days"."day_name" JOIN "flight" ON "AIRPORT_SERVICE_0"."airport_code" = "flight"."from_airport" AND "days"."days_code" = "flight"."flight_days" AND "flight"."departure_time" > 1600 JOIN "airport_service" "AIRPORT_SERVICE_1" ON "AIRPORT_SERVICE_1"."airport_code" = "flight"."to_airport" JOIN "city" "CITY_1" ON "AIRPORT_SERVICE_1"."city_code" = "CITY_1"."city_code" AND "CITY_1"."city_name" = 'SAN FRANCISCO'
0.734375
CREATE TABLE table_2794180_11 (Dual VARCHAR2, year_s_ VARCHAR2)
Who was the dual television commentator in 1990?
SELECT Dual AS television_commentator FROM table_2794180_11 WHERE year_s_ = 1990
SELECT "Dual" AS "television_commentator" FROM "table_2794180_11" WHERE "year_s_" = 1990
0.085938
CREATE TABLE table_name_91 (grid NUMBER, time_retired VARCHAR2)
What is the highest numbered grid with a time or retired time of 52:52.1881?
SELECT MAX(grid) FROM table_name_91 WHERE time_retired = "52:52.1881"
SELECT MAX("grid") FROM "table_name_91" WHERE "52:52.1881" = "time_retired"
0.073242
CREATE TABLE table_name_76 (attendance VARCHAR2, result VARCHAR2)
How many were in attendance with a Result of l 17 10?
SELECT attendance FROM table_name_76 WHERE result = "l 17–10"
SELECT "attendance" FROM "table_name_76" WHERE "l 17–10" = "result"
0.06543
CREATE TABLE admissions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, admittime TIME, dischtime TIME, admission_type CLOB, admission_location CLOB, discharge_location CLOB, insurance CLOB, language CLOB, marital_status CLOB, ethnicity CLOB, age NUMBER) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) CREATE TABLE procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE transfers (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, eventtype CLOB, careunit CLOB, wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) CREATE TABLE d_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE icustays (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, first_careunit CLOB, last_careunit CLOB, first_wardid NUMBER, last_wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name CLOB) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE prescriptions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, startdate TIME, enddate TIME, drug CLOB, dose_val_rx CLOB, dose_unit_rx CLOB, route CLOB) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label CLOB)
when did the last time patient 3369 have a potassium lab test until 20 months ago?
SELECT labevents.charttime FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'potassium') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3369) AND DATETIME(labevents.charttime) <= DATETIME(CURRENT_TIME(), '-20 month') ORDER BY labevents.charttime DESC LIMIT 1
WITH "_u_0" AS (SELECT "d_labitems"."itemid" FROM "d_labitems" WHERE "d_labitems"."label" = 'potassium' GROUP BY "itemid"), "_u_1" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 3369 GROUP BY "hadm_id") SELECT "labevents"."charttime" FROM "labevents" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "labevents"."itemid" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "labevents"."hadm_id" WHERE DATETIME("labevents"."charttime") <= DATETIME(CURRENT_TIME(), '-20 month') AND NOT "_u_0"."" IS NULL AND NOT "_u_1"."" IS NULL ORDER BY "labevents"."charttime" DESC FETCH FIRST 1 ROWS ONLY
0.59082
CREATE TABLE table_5994 ("Player" CLOB, "Team" CLOB, "Date" CLOB, "Opponent" CLOB, "Venue" CLOB)
What was the venue where Chuck Klein played?
SELECT "Venue" FROM table_5994 WHERE "Player" = 'chuck klein'
SELECT "Venue" FROM "table_5994" WHERE "Player" = 'chuck klein'
0.061523
CREATE TABLE table_10010 ("Team" CLOB, "Driver" CLOB, "Class" CLOB, "Chassis" CLOB, "Engine" CLOB, "Rounds" CLOB)
what is the class when the chassis is dallara f308, rounds is all and the driver is sam abay?
SELECT "Class" FROM table_10010 WHERE "Chassis" = 'dallara f308' AND "Rounds" = 'all' AND "Driver" = 'sam abay'
SELECT "Class" FROM "table_10010" WHERE "Chassis" = 'dallara f308' AND "Driver" = 'sam abay' AND "Rounds" = 'all'
0.110352
CREATE TABLE table_name_75 (total_votes NUMBER, _number_of_seats_won NUMBER)
Can you tell me the average Total votes that has the # of seats won smaller than 0?
SELECT AVG(total_votes) FROM table_name_75 WHERE _number_of_seats_won < 0
SELECT AVG("total_votes") FROM "table_name_75" WHERE "_number_of_seats_won" < 0
0.077148
CREATE TABLE table_name_87 (grid VARCHAR2, time_retired VARCHAR2)
How many grids are associated with a Time/Retired of +1.837?
SELECT COUNT(grid) FROM table_name_87 WHERE time_retired = "+1.837"
SELECT COUNT("grid") FROM "table_name_87" WHERE "+1.837" = "time_retired"
0.071289
CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID NUMBER) CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2) CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2) CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE departments (DEPARTMENT_ID NUMBER, DEPARTMENT_NAME VARCHAR2, MANAGER_ID NUMBER, LOCATION_ID NUMBER) CREATE TABLE employees (EMPLOYEE_ID NUMBER, FIRST_NAME VARCHAR2, LAST_NAME VARCHAR2, EMAIL VARCHAR2, PHONE_NUMBER VARCHAR2, HIRE_DATE DATE, JOB_ID VARCHAR2, SALARY NUMBER, COMMISSION_PCT NUMBER, MANAGER_ID NUMBER, DEPARTMENT_ID NUMBER)
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 manager_id bin hire_date by time, sort by the y-axis in ascending.
SELECT HIRE_DATE, AVG(MANAGER_ID) FROM employees WHERE FIRST_NAME LIKE '%D%' OR FIRST_NAME LIKE '%S%' ORDER BY AVG(MANAGER_ID)
SELECT "HIRE_DATE", AVG("MANAGER_ID") FROM "employees" WHERE "FIRST_NAME" LIKE '%D%' OR "FIRST_NAME" LIKE '%S%' ORDER BY AVG("MANAGER_ID")
0.134766
CREATE TABLE table_12979 ("Week 1" CLOB, "Week 2" CLOB, "Week 3" CLOB, "Week 4" CLOB, "Week 5" CLOB)
What Week 2 has a Week 1 of crystal beddows?
SELECT "Week 2" FROM table_12979 WHERE "Week 1" = 'crystal beddows'
SELECT "Week 2" FROM "table_12979" WHERE "Week 1" = 'crystal beddows'
0.067383
CREATE TABLE table_1342359_39 (candidates VARCHAR2, district VARCHAR2)
Name the candidate for south carolina 1?
SELECT candidates FROM table_1342359_39 WHERE district = "South Carolina 1"
SELECT "candidates" FROM "table_1342359_39" WHERE "South Carolina 1" = "district"
0.079102
CREATE TABLE table_73400 ("District" CLOB, "Vacator" CLOB, "Reason for change" CLOB, "Successor" CLOB, "Date successor seated" CLOB)
What is the date successor seated where Massachusetts 2nd is the district?
SELECT "Date successor seated" FROM table_73400 WHERE "District" = 'Massachusetts 2nd'
SELECT "Date successor seated" FROM "table_73400" WHERE "District" = 'Massachusetts 2nd'
0.085938
CREATE TABLE table_43177 ("Place" CLOB, "Player" CLOB, "Country" CLOB, "Score" CLOB, "To par" CLOB)
What country was the player, rod pampling, from who placed t10?
SELECT "Country" FROM table_43177 WHERE "Place" = 't10' AND "Player" = 'rod pampling'
SELECT "Country" FROM "table_43177" WHERE "Place" = 't10' AND "Player" = 'rod pampling'
0.084961
CREATE TABLE table_4898 ("Home team" CLOB, "Home team score" CLOB, "Away team" CLOB, "Away team score" CLOB, "Venue" CLOB, "Crowd" FLOAT, "Date" CLOB)
How many people watch an away team score 6.9 (45)?
SELECT AVG("Crowd") FROM table_4898 WHERE "Away team score" = '6.9 (45)'
SELECT AVG("Crowd") FROM "table_4898" WHERE "Away team score" = '6.9 (45)'
0.072266
CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME)
count the number of patients who received a electrolyte administration - intravenous procedure during the same month following a diagnosis of acute coronary syndrome since 3 years ago.
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'acute coronary syndrome' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME(), '-3 year')) AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'electrolyte administration - intravenous' AND DATETIME(treatment.treatmenttime) >= DATETIME(CURRENT_TIME(), '-3 year')) AS t2 WHERE t1.diagnosistime < t2.treatmenttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.treatmenttime, 'start of month')
SELECT COUNT(DISTINCT "patient"."uniquepid") FROM "diagnosis" JOIN "patient" ON "diagnosis"."patientunitstayid" = "patient"."patientunitstayid" JOIN "treatment" ON "diagnosis"."diagnosistime" < "treatment"."treatmenttime" AND "treatment"."treatmentname" = 'electrolyte administration - intravenous' AND DATETIME("diagnosis"."diagnosistime", 'start of month') = DATETIME("treatment"."treatmenttime", 'start of month') AND DATETIME("treatment"."treatmenttime") >= DATETIME(CURRENT_TIME(), '-3 year') JOIN "patient" "patient_2" ON "patient_2"."patientunitstayid" = "treatment"."patientunitstayid" WHERE "diagnosis"."diagnosisname" = 'acute coronary syndrome' AND DATETIME("diagnosis"."diagnosistime") >= DATETIME(CURRENT_TIME(), '-3 year')
0.71875
CREATE TABLE table_39263 ("Date" CLOB, "Opponent" CLOB, "Score" CLOB, "Loss" CLOB, "Save" CLOB)
What is the score of the game on September 13 when the Expos were the opponent?
SELECT "Score" FROM table_39263 WHERE "Opponent" = 'expos' AND "Date" = 'september 13'
SELECT "Score" FROM "table_39263" WHERE "Date" = 'september 13' AND "Opponent" = 'expos'
0.085938
CREATE TABLE table_name_22 (position VARCHAR2, cfl_team VARCHAR2)
What position do the bc lions pick?
SELECT position FROM table_name_22 WHERE cfl_team = "bc lions"
SELECT "position" FROM "table_name_22" WHERE "bc lions" = "cfl_team"
0.066406
CREATE TABLE table_name_28 (season_joined_league VARCHAR2, settlements VARCHAR2)
In which season did the vora settlements join the league?
SELECT season_joined_league FROM table_name_28 WHERE settlements = "évora"
SELECT "season_joined_league" FROM "table_name_28" WHERE "settlements" = "évora"
0.078125
CREATE TABLE table_name_55 (psip_short_name VARCHAR2, channel NUMBER)
What is the short name for a channelgreater than 63.4?
SELECT psip_short_name FROM table_name_55 WHERE channel > 63.4
SELECT "psip_short_name" FROM "table_name_55" WHERE "channel" > 63.4
0.066406
CREATE TABLE table_name_36 (score VARCHAR2, home VARCHAR2, record VARCHAR2)
What is the score for the Chicago Black Hawks game with a record of 2-1?
SELECT score FROM table_name_36 WHERE home = "chicago black hawks" AND record = "2-1"
SELECT "score" FROM "table_name_36" WHERE "2-1" = "record" AND "chicago black hawks" = "home"
0.09082
CREATE TABLE table_78754 ("Year ( Ceremony ) " CLOB, "Film title used in nomination" CLOB, "Original title" CLOB, "Director" CLOB, "Result" CLOB)
What is the year when not nominated was the result, and In the Navel of the Sea was the film title used in nomination?
SELECT "Year (Ceremony)" FROM table_78754 WHERE "Result" = 'not nominated' AND "Film title used in nomination" = 'in the navel of the sea'
SELECT "Year (Ceremony)" FROM "table_78754" WHERE "Film title used in nomination" = 'in the navel of the sea' AND "Result" = 'not nominated'
0.136719
CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB)
provide the number of patients whose discharge location is snf and days of hospital stay is greater than 13?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "SNF" AND demographic.days_stay > "13"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "13" < "demographic"."days_stay" AND "SNF" = "demographic"."discharge_location"
0.150391
CREATE TABLE Allergy_Type (Allergy VARCHAR2, AllergyType VARCHAR2) CREATE TABLE Student (StuID NUMBER, LName VARCHAR2, Fname VARCHAR2, Age NUMBER, Sex VARCHAR2, Major NUMBER, Advisor NUMBER, city_code VARCHAR2) CREATE TABLE Has_Allergy (StuID NUMBER, Allergy VARCHAR2)
Plot the total number by grouped by city code as a bar graph, I want to rank x-axis from high to low order.
SELECT city_code, COUNT(*) FROM Student GROUP BY city_code ORDER BY city_code DESC
SELECT "city_code", COUNT(*) FROM "Student" GROUP BY "city_code" ORDER BY "city_code" DESC
0.087891
CREATE TABLE table_20397 ("N\\u00b0" FLOAT, "Television service" CLOB, "Country" CLOB, "Language" CLOB, "Content" CLOB, "DAR" CLOB, "HDTV" CLOB, "PPV" CLOB, "Package/Option" CLOB)
Name the total number of dar for disney channel and number is 613
SELECT COUNT("DAR") FROM table_20397 WHERE "Television service" = 'Disney Channel' AND "N\u00b0" = '613'
SELECT COUNT("DAR") FROM "table_20397" WHERE "N\u00b0" = '613' AND "Television service" = 'Disney Channel'
0.103516
CREATE TABLE table_17703 ("Rank in Nyagatare Sectors , 2012" FLOAT, "Sector" CLOB, "Area in sqkm" FLOAT, "Population August 15 , 2012" FLOAT, "Population , August 15 , 2002" FLOAT, "Population Change 2002-2012 ( % ) " CLOB, "Population Density 2012 ( km 2 ) " FLOAT)
What is the highest population for the
SELECT MAX("Population, August 15, 2002") FROM table_17703
SELECT MAX("Population, August 15, 2002") FROM "table_17703"
0.058594
CREATE TABLE table_3099 ("No." FLOAT, "Title" CLOB, "Directed by" CLOB, "Written by" CLOB, "Original air date" CLOB, "Production code" CLOB, "U.S. viewers ( million ) " CLOB)
Who directed 'hey now hey now perry'S girlfriend's back'?
SELECT "Directed by" FROM table_3099 WHERE "Title" = 'Hey Now Hey Now Perry''s Girlfriend''s Back'
SELECT "Directed by" FROM "table_3099" WHERE "Title" = 'Hey Now Hey Now Perry''s Girlfriend''s Back'
0.097656
CREATE TABLE table_17355408_12 (game VARCHAR2, date VARCHAR2)
What game was on May 25?
SELECT game FROM table_17355408_12 WHERE date = "May 25"
SELECT "game" FROM "table_17355408_12" WHERE "May 25" = "date"
0.060547
CREATE TABLE table_name_80 (date NUMBER, catalog VARCHAR2, label VARCHAR2, region VARCHAR2)
WHAT IS THE AVERAGE DATE FOR CBS LABEL, IN AUSTRALIA, AND SBP 241031 FOR CATALOG?
SELECT AVG(date) FROM table_name_80 WHERE label = "cbs" AND region = "australia" AND catalog = "sbp 241031"
SELECT AVG("date") FROM "table_name_80" WHERE "australia" = "region" AND "catalog" = "sbp 241031" AND "cbs" = "label"
0.114258
CREATE TABLE cinema (Cinema_ID NUMBER, Name CLOB, Openning_year NUMBER, Capacity NUMBER, Location CLOB) CREATE TABLE film (Film_ID NUMBER, Rank_in_series NUMBER, Number_in_season NUMBER, Title CLOB, Directed_by CLOB, Original_air_date CLOB, Production_code CLOB) CREATE TABLE schedule (Cinema_ID NUMBER, Film_ID NUMBER, Date CLOB, Show_times_per_day NUMBER, Price FLOAT)
Create a bar chart showing capacity across name, order Name in desc order.
SELECT Name, Capacity FROM cinema ORDER BY Name DESC
SELECT "Name", "Capacity" FROM "cinema" ORDER BY "Name" DESC
0.058594
CREATE TABLE table_27734769_8 (date VARCHAR2, high_points VARCHAR2)
What is the date the high points was lamarcus aldridge (36)?
SELECT date FROM table_27734769_8 WHERE high_points = "LaMarcus Aldridge (36)"
SELECT "date" FROM "table_27734769_8" WHERE "LaMarcus Aldridge (36)" = "high_points"
0.082031
CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE patient (uniquepid CLOB, patienthealthsystemstayid NUMBER, patientunitstayid NUMBER, gender CLOB, age CLOB, ethnicity CLOB, hospitalid NUMBER, wardid NUMBER, admissionheight NUMBER, admissionweight NUMBER, dischargeweight NUMBER, hospitaladmittime TIME, hospitaladmitsource CLOB, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus CLOB) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME) CREATE TABLE diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB)
count the number of hospital visits patient 021-240586 was since 5 years ago.
SELECT COUNT(DISTINCT patient.patienthealthsystemstayid) FROM patient WHERE patient.uniquepid = '021-240586' AND DATETIME(patient.hospitaladmittime) >= DATETIME(CURRENT_TIME(), '-5 year')
SELECT COUNT(DISTINCT "patient"."patienthealthsystemstayid") FROM "patient" WHERE "patient"."uniquepid" = '021-240586' AND DATETIME("patient"."hospitaladmittime") >= DATETIME(CURRENT_TIME(), '-5 year')
0.196289
CREATE TABLE table_24350 ("Type of Record" CLOB, "Attendance" FLOAT, "Date/Year" CLOB, "Stadium" CLOB, "Result/Games" CLOB)
what is the attendance in 2011 records
SELECT "Attendance" FROM table_24350 WHERE "Date/Year" = '2011'
SELECT "Attendance" FROM "table_24350" WHERE "Date/Year" = '2011'
0.063477
CREATE TABLE table_20095300_1 (name VARCHAR2, number VARCHAR2)
What horse has the number 25?
SELECT name FROM table_20095300_1 WHERE number = 25
SELECT "name" FROM "table_20095300_1" WHERE "number" = 25
0.055664
CREATE TABLE table_46668 ("Grade" CLOB, "Description" CLOB, "Measurement" CLOB, "Function %" CLOB, "Estimated function %" FLOAT)
What is the function percentage when the estimated function percentage is 20?
SELECT "Function %" FROM table_46668 WHERE "Estimated function %" = '20'
SELECT "Function %" FROM "table_46668" WHERE "Estimated function %" = '20'
0.072266
CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
how many patients whose gender is m and drug code is metr500pm?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.gender = "M" AND prescriptions.formulary_drug_cd = "METR500PM"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "METR500PM" = "prescriptions"."formulary_drug_cd" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "M" = "demographic"."gender"
0.227539
CREATE TABLE d_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE icustays (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, first_careunit CLOB, last_careunit CLOB, first_wardid NUMBER, last_wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) CREATE TABLE diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE transfers (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, eventtype CLOB, careunit CLOB, wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label CLOB) CREATE TABLE cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE admissions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, admittime TIME, dischtime TIME, admission_type CLOB, admission_location CLOB, discharge_location CLOB, insurance CLOB, language CLOB, marital_status CLOB, ethnicity CLOB, age NUMBER) CREATE TABLE prescriptions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, startdate TIME, enddate TIME, drug CLOB, dose_val_rx CLOB, dose_unit_rx CLOB, route CLOB) CREATE TABLE procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name CLOB)
what is the difference of arterial bp [diastolic] patient 22648 has last measured on the first icu visit compared to the value second to last measured on the first icu visit?
SELECT (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22648) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1) - (SELECT chartevents.valuenum FROM chartevents WHERE chartevents.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 22648) AND NOT icustays.outtime IS NULL ORDER BY icustays.intime LIMIT 1) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'arterial bp [diastolic]' AND d_items.linksto = 'chartevents') ORDER BY chartevents.charttime DESC LIMIT 1 OFFSET 1)
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 22648 GROUP BY "hadm_id"), "_u_1" AS (SELECT "icustays"."icustay_id" FROM "icustays" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "icustays"."hadm_id" WHERE NOT "_u_0"."" IS NULL AND NOT "icustays"."outtime" IS NULL GROUP BY "icustay_id" ORDER BY "icustays"."intime" FETCH FIRST 1 ROWS ONLY), "_u_2" AS (SELECT "d_items"."itemid" FROM "d_items" WHERE "d_items"."label" = 'arterial bp [diastolic]' AND "d_items"."linksto" = 'chartevents' GROUP BY "itemid"), "_u_5" AS (SELECT "icustays"."icustay_id" FROM "icustays" LEFT JOIN "_u_0" "_u_4" ON "_u_4"."" = "icustays"."hadm_id" WHERE NOT "_u_4"."" IS NULL AND NOT "icustays"."outtime" IS NULL GROUP BY "icustay_id" ORDER BY "icustays"."intime" FETCH FIRST 1 ROWS ONLY) SELECT (SELECT "chartevents"."valuenum" FROM "chartevents" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "chartevents"."icustay_id" LEFT JOIN "_u_2" "_u_2" ON "_u_2"."" = "chartevents"."itemid" WHERE NOT "_u_1"."" IS NULL AND NOT "_u_2"."" IS NULL ORDER BY "chartevents"."charttime" DESC FETCH FIRST 1 ROWS ONLY) - (SELECT "chartevents"."valuenum" FROM "chartevents" LEFT JOIN "_u_5" "_u_5" ON "_u_5"."" = "chartevents"."icustay_id" LEFT JOIN "_u_2" "_u_6" ON "_u_6"."" = "chartevents"."itemid" WHERE NOT "_u_5"."" IS NULL AND NOT "_u_6"."" IS NULL ORDER BY "chartevents"."charttime" DESC OFFSET 1 ROWS FETCH FIRST 1 ROWS ONLY)
1.394531
CREATE TABLE table_42401 ("Call sign" CLOB, "Frequency MHz" FLOAT, "City of license" CLOB, "Facility ID" FLOAT, "ERP W" FLOAT, "Height m ( ft ) " CLOB, "Class" CLOB, "FCC info" CLOB)
What is the class of facility ID 150935?
SELECT "Class" FROM table_42401 WHERE "Facility ID" = '150935'
SELECT "Class" FROM "table_42401" WHERE "Facility ID" = '150935'
0.0625
CREATE TABLE table_train_34 ("id" NUMBER, "gender" CLOB, "allergy_to_adhesive" BOOLEAN, "contraception" BOOLEAN, "use_of_cyclosporin" BOOLEAN, "use_of_digoxin" BOOLEAN, "liver_disease" BOOLEAN, "rhabomyolysis" BOOLEAN, "allergy_to_hydrocortisone" BOOLEAN, "use_of_statins" BOOLEAN, "NOUSE" FLOAT)
rhabomyolysis
SELECT * FROM table_train_34 WHERE rhabomyolysis = 1
SELECT * FROM "table_train_34" WHERE "rhabomyolysis" = 1
0.054688
CREATE TABLE table_42183 ("Round" FLOAT, "Pick" FLOAT, "Name" CLOB, "Position" CLOB, "College" CLOB)
What's the average round the position of RB was drafted?
SELECT AVG("Round") FROM table_42183 WHERE "Position" = 'rb'
SELECT AVG("Round") FROM "table_42183" WHERE "Position" = 'rb'
0.060547
CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB)
count the number of white-russian ethnic background patients who had emergency hospital admission.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.ethnicity = "WHITE - RUSSIAN"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "EMERGENCY" = "demographic"."admission_type" AND "WHITE - RUSSIAN" = "demographic"."ethnicity"
0.165039
CREATE TABLE transfers (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, eventtype CLOB, careunit CLOB, wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) CREATE TABLE admissions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, admittime TIME, dischtime TIME, admission_type CLOB, admission_location CLOB, discharge_location CLOB, insurance CLOB, language CLOB, marital_status CLOB, ethnicity CLOB, age NUMBER) CREATE TABLE cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) CREATE TABLE diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name CLOB) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE icustays (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, first_careunit CLOB, last_careunit CLOB, first_wardid NUMBER, last_wardid NUMBER, intime TIME, outtime TIME) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label CLOB) CREATE TABLE d_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE prescriptions (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, startdate TIME, enddate TIME, drug CLOB, dose_val_rx CLOB, dose_unit_rx CLOB, route CLOB) CREATE TABLE chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB)
what are the five commonly ordered medications for patients who were diagnosed with chf nos previously within 2 months, until 2103?
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, diagnoses_icd.charttime FROM diagnoses_icd JOIN admissions ON diagnoses_icd.hadm_id = admissions.hadm_id WHERE diagnoses_icd.icd9_code = (SELECT d_icd_diagnoses.icd9_code FROM d_icd_diagnoses WHERE d_icd_diagnoses.short_title = 'chf nos') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2103') AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE STRFTIME('%y', prescriptions.startdate) <= '2103') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND DATETIME(t2.startdate) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month') GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 5
WITH "t2" AS (SELECT "admissions"."subject_id", "prescriptions"."drug", "prescriptions"."startdate" FROM "prescriptions" JOIN "admissions" ON "admissions"."hadm_id" = "prescriptions"."hadm_id" WHERE STRFTIME('%y', "prescriptions"."startdate") <= '2103'), "t3" AS (SELECT "t2"."drug", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS "c1" FROM "diagnoses_icd" JOIN "d_icd_diagnoses" ON "d_icd_diagnoses"."icd9_code" = "diagnoses_icd"."icd9_code" AND "d_icd_diagnoses"."short_title" = 'chf nos' JOIN "admissions" ON "admissions"."hadm_id" = "diagnoses_icd"."hadm_id" JOIN "t2" "t2" ON "admissions"."subject_id" = "t2"."subject_id" AND "diagnoses_icd"."charttime" < "t2"."startdate" AND DATETIME("diagnoses_icd"."charttime") <= DATETIME("t2"."startdate") AND DATETIME("diagnoses_icd"."charttime", '+2 month') >= DATETIME("t2"."startdate") WHERE STRFTIME('%y', "diagnoses_icd"."charttime") <= '2103' GROUP BY "t2"."drug") SELECT "t3"."drug" FROM "t3" "t3" WHERE "t3"."c1" <= 5
0.946289
CREATE TABLE table_39617 ("Round" FLOAT, "Pick #" FLOAT, "Overall" FLOAT, "Name" CLOB, "Position" CLOB, "College" CLOB)
What is the total round for a wide receiver with an overall of more than 145?
SELECT COUNT("Round") FROM table_39617 WHERE "Position" = 'wide receiver' AND "Overall" > '145'
SELECT COUNT("Round") FROM "table_39617" WHERE "Overall" > '145' AND "Position" = 'wide receiver'
0.094727
CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB) CREATE TABLE prescriptions (subject_id CLOB, hadm_id CLOB, icustay_id CLOB, drug_type CLOB, drug CLOB, formulary_drug_cd CLOB, route CLOB, drug_dose CLOB) CREATE TABLE demographic (subject_id CLOB, hadm_id CLOB, name CLOB, marital_status CLOB, age CLOB, dob CLOB, gender CLOB, language CLOB, religion CLOB, admission_type CLOB, days_stay CLOB, insurance CLOB, ethnicity CLOB, expire_flag CLOB, admission_location CLOB, discharge_location CLOB, diagnosis CLOB, dod CLOB, dob_year CLOB, dod_year CLOB, admittime CLOB, dischtime CLOB, admityear CLOB) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
find the number of patients still alive who were born before 2167.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.expire_flag = "0" AND demographic.dob_year < "2167"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "0" = "demographic"."expire_flag" AND "2167" > "demographic"."dob_year"
0.142578