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 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 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 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) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE medication (medicationid NUMBER, patientunitstayid NUMBER, drugname CLOB, dosage CLOB, routeadmin CLOB, drugstarttime TIME, drugstoptime TIME) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME)
tell me the age of patient 035-4312 in their current hospital visit?
SELECT patient.age FROM patient WHERE patient.uniquepid = '035-4312' AND patient.hospitaldischargetime IS NULL
SELECT "patient"."age" FROM "patient" WHERE "patient"."hospitaldischargetime" IS NULL AND "patient"."uniquepid" = '035-4312'
0.121094
CREATE TABLE table_33094 ("Home team" CLOB, "Home team score" CLOB, "Away team" CLOB, "Away team score" CLOB, "Venue" CLOB, "Crowd" FLOAT, "Date" CLOB)
What was the smallest crowd size for a home game for Richmond?
SELECT MIN("Crowd") FROM table_33094 WHERE "Home team" = 'richmond'
SELECT MIN("Crowd") FROM "table_33094" WHERE "Home team" = 'richmond'
0.067383
CREATE TABLE table_1165048_1 (dudley_tuckey_medal VARCHAR2, leading_goalkicker VARCHAR2)
who is the dudley tuckey medal where leading goalkicker is scott simister (46)
SELECT dudley_tuckey_medal FROM table_1165048_1 WHERE leading_goalkicker = "Scott Simister (46)"
SELECT "dudley_tuckey_medal" FROM "table_1165048_1" WHERE "Scott Simister (46)" = "leading_goalkicker"
0.099609
CREATE TABLE table_name_51 (equipment VARCHAR2, position VARCHAR2, points VARCHAR2)
What is Equipment, when Position is greater than 28, and when Points is greater than 10?
SELECT equipment FROM table_name_51 WHERE position > 28 AND points > 10
SELECT "equipment" FROM "table_name_51" WHERE "points" > 10 AND "position" > 28
0.077148
CREATE TABLE table_name_6 (score VARCHAR2, home VARCHAR2, date VARCHAR2)
What was the score on February 21 when the home team was the Pittsburgh Penguins?
SELECT score FROM table_name_6 WHERE home = "pittsburgh penguins" AND date = "february 21"
SELECT "score" FROM "table_name_6" WHERE "date" = "february 21" AND "home" = "pittsburgh penguins"
0.095703
CREATE TABLE table_32104 ("Title" CLOB, "Japan" CLOB, "North America" CLOB, "Europe" CLOB, "Australia" CLOB)
Tell me the north america for september 18, 2009
SELECT "North America" FROM table_32104 WHERE "Europe" = 'september 18, 2009'
SELECT "North America" FROM "table_32104" WHERE "Europe" = 'september 18, 2009'
0.077148
CREATE TABLE Products (Code NUMBER, Name VARCHAR2, Price NUMBER, Manufacturer NUMBER) CREATE TABLE Manufacturers (Code NUMBER, Name VARCHAR2, Headquarter VARCHAR2, Founder VARCHAR2, Revenue FLOAT)
Select the names of all the products in the store, and count them by a bar chart, show in descending by the y-axis.
SELECT Name, COUNT(Name) FROM Products GROUP BY Name ORDER BY COUNT(Name) DESC
SELECT "Name", COUNT("Name") FROM "Products" GROUP BY "Name" ORDER BY COUNT("Name") DESC
0.085938
CREATE TABLE table_25940 ("SF Round" FLOAT, "Country" CLOB, "Location" CLOB, "Date" CLOB, "Driver" CLOB, "Race 1 ( pts ) " FLOAT, "Race 2 ( pts ) " FLOAT, "Race Total ( pts ) " FLOAT)
What is every points value for race 1 if the total race points is 180?
SELECT "Race 1(pts)" FROM table_25940 WHERE "Race Total(pts)" = '180'
SELECT "Race 1(pts)" FROM "table_25940" WHERE "Race Total(pts)" = '180'
0.069336
CREATE TABLE equipment_sequence (aircraft_code_sequence VARCHAR2, aircraft_code VARCHAR2) 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 code_description (code VARCHAR2, description CLOB) CREATE TABLE time_zone (time_zone_code CLOB, time_zone_name CLOB, hours_from_gmt NUMBER) CREATE TABLE state (state_code CLOB, state_name CLOB, country_name CLOB) CREATE TABLE food_service (meal_code CLOB, meal_number NUMBER, compartment CLOB, meal_description VARCHAR2) 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) 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 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 compartment_class (compartment VARCHAR2, class_type VARCHAR2) CREATE TABLE dual_carrier (main_airline VARCHAR2, low_flight_number NUMBER, high_flight_number NUMBER, dual_airline VARCHAR2, service_name CLOB) 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 month (month_number NUMBER, month_name CLOB) CREATE TABLE time_interval (period CLOB, begin_time NUMBER, end_time NUMBER) CREATE TABLE airline (airline_code VARCHAR2, airline_name CLOB, note CLOB) CREATE TABLE date_day (month_number NUMBER, day_number NUMBER, year NUMBER, day_name VARCHAR2) CREATE TABLE class_of_service (booking_class VARCHAR2, rank NUMBER, class_description CLOB) CREATE TABLE city (city_code VARCHAR2, city_name VARCHAR2, state_code VARCHAR2, country_name VARCHAR2, time_zone_code VARCHAR2) CREATE TABLE airport_service (city_code VARCHAR2, airport_code VARCHAR2, miles_distant NUMBER, direction VARCHAR2, minutes_distant NUMBER) CREATE TABLE days (days_code VARCHAR2, day_name VARCHAR2) CREATE TABLE flight_leg (flight_id NUMBER, leg_number NUMBER, leg_flight NUMBER) CREATE TABLE ground_service (city_code CLOB, airport_code CLOB, transport_type CLOB, ground_fare 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 flight_fare (flight_id NUMBER, fare_id NUMBER) 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)
show me the flights from PHILADELPHIA to BALTIMORE in the morning
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, flight WHERE (CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PHILADELPHIA' AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND flight.departure_time BETWEEN 0 AND 1200
SELECT DISTINCT "flight"."flight_id" FROM "airport_service" "AIRPORT_SERVICE_0" JOIN "city" "CITY_0" ON "AIRPORT_SERVICE_0"."city_code" = "CITY_0"."city_code" AND "CITY_0"."city_name" = 'PHILADELPHIA' JOIN "flight" ON "AIRPORT_SERVICE_0"."airport_code" = "flight"."from_airport" AND "flight"."departure_time" <= 1200 AND "flight"."departure_time" >= 0 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" = 'BALTIMORE'
0.560547
CREATE TABLE table_name_95 (rank NUMBER, total VARCHAR2, silver VARCHAR2)
What is the rank of the team with 11 total medals and more than 4 silver medals has?
SELECT SUM(rank) FROM table_name_95 WHERE total = 11 AND silver > 4
SELECT SUM("rank") FROM "table_name_95" WHERE "silver" > 4 AND "total" = 11
0.073242
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) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
how many patients are admitted before the year 2190 and tested in lab for abnormal status?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.admityear < "2190" AND lab.flag = "abnormal"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "abnormal" = "lab"."flag" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "2190" > "demographic"."admityear"
0.19043
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) CREATE TABLE lab (subject_id CLOB, hadm_id CLOB, itemid CLOB, charttime CLOB, flag CLOB, value_unit CLOB, label CLOB, fluid CLOB)
give the number of patients whose language is english and diagnosis long title is unspecified protein-calorie malnutrition.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.language = "ENGL" AND diagnoses.long_title = "Unspecified protein-calorie malnutrition"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Unspecified protein-calorie malnutrition" = "diagnoses"."long_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "ENGL" = "demographic"."language"
0.244141
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 allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) CREATE TABLE treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) 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 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 vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME)
what is the gastric (ng) output for patient 007-4119 on 02/08/last year?
SELECT SUM(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '007-4119')) AND intakeoutput.celllabel = 'gastric (ng)' AND intakeoutput.cellpath LIKE '%output%' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '02-08'
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '007-4119' 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 SUM("intakeoutput"."cellvaluenumeric") FROM "intakeoutput" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "intakeoutput"."patientunitstayid" WHERE "intakeoutput"."celllabel" = 'gastric (ng)' AND "intakeoutput"."cellpath" LIKE '%output%' AND DATETIME("intakeoutput"."intakeoutputtime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND NOT "_u_1"."" IS NULL AND STRFTIME('%m-%d', "intakeoutput"."intakeoutputtime") = '02-08'
0.783203
CREATE TABLE table_34909 ("Version" CLOB, "Length" CLOB, "Album" CLOB, "Remixed by" CLOB, "Year" FLOAT)
Which Remixed by has a Version of album version, and an Album of les mots?
SELECT "Remixed by" FROM table_34909 WHERE "Version" = 'album version' AND "Album" = 'les mots'
SELECT "Remixed by" FROM "table_34909" WHERE "Album" = 'les mots' AND "Version" = 'album version'
0.094727
CREATE TABLE table_name_25 (method VARCHAR2, round VARCHAR2, location VARCHAR2)
What method was there in round 1 when the location was Aruba?
SELECT method FROM table_name_25 WHERE round = "1" AND location = "aruba"
SELECT "method" FROM "table_name_25" WHERE "1" = "round" AND "aruba" = "location"
0.079102
CREATE TABLE people (People_ID NUMBER, Sex CLOB, Name CLOB, Date_of_Birth CLOB, Height FLOAT, Weight FLOAT) CREATE TABLE candidate (Candidate_ID NUMBER, People_ID NUMBER, Poll_Source CLOB, Date CLOB, Support_rate FLOAT, Consider_rate FLOAT, Oppose_rate FLOAT, Unsure_rate FLOAT)
Count the number of people of each sex who have a weight higher than 85 by a bar chart, show from high to low by the bar.
SELECT Sex, COUNT(*) FROM people WHERE Weight > 85 GROUP BY Sex ORDER BY Sex DESC
SELECT "Sex", COUNT(*) FROM "people" WHERE "Weight" > 85 GROUP BY "Sex" ORDER BY "Sex" DESC
0.088867
CREATE TABLE table_1053 ("Quarterback" CLOB, "Jersey No." CLOB, "Games Started" FLOAT, "Wins" FLOAT, "Losses" FLOAT, "Ties" FLOAT, "Winning Pct." CLOB)
Who is the quarter back for a winning pct of .792
SELECT "Quarterback" FROM table_1053 WHERE "Winning Pct." = '.792'
SELECT "Quarterback" FROM "table_1053" WHERE "Winning Pct." = '.792'
0.066406
CREATE TABLE table_203_69 (id NUMBER, "representative" CLOB, "title" CLOB, "from" NUMBER, "to" NUMBER, "appointed by" CLOB)
what is the total number of representatives ?
SELECT COUNT("representative") FROM table_203_69
SELECT COUNT("representative") FROM "table_203_69"
0.048828
CREATE TABLE mountain (mountain_id NUMBER, name CLOB, height NUMBER, prominence NUMBER, range CLOB, country CLOB) CREATE TABLE climber (climber_id NUMBER, name CLOB, country CLOB, time CLOB, points NUMBER, mountain_id NUMBER)
What are the names of climbers and the corresponding names of mountains that they climb?
SELECT T1.name, T2.name FROM climber AS T1 JOIN mountain AS T2 ON T1.mountain_id = T2.mountain_id
SELECT "T1"."name", "T2"."name" FROM "climber" "T1" JOIN "mountain" "T2" ON "T1"."mountain_id" = "T2"."mountain_id"
0.112305
CREATE TABLE table_name_40 (attendance NUMBER, score VARCHAR2)
What was the lowest attendance for a score of 5 - 0?
SELECT MIN(attendance) FROM table_name_40 WHERE score = "5 - 0"
SELECT MIN("attendance") FROM "table_name_40" WHERE "5 - 0" = "score"
0.067383
CREATE TABLE club (club_id NUMBER, club_name CLOB, region CLOB, start_year NUMBER) CREATE TABLE player_coach (player_id NUMBER, coach_id NUMBER, starting_year NUMBER) CREATE TABLE match_result (rank NUMBER, club_id NUMBER, gold NUMBER, big_silver NUMBER, small_silver NUMBER, bronze NUMBER, points NUMBER) CREATE TABLE coach (coach_id NUMBER, coach_name CLOB, gender CLOB, club_id NUMBER, rank NUMBER) CREATE TABLE player (player_id NUMBER, sponsor_name CLOB, player_name CLOB, gender CLOB, residence CLOB, occupation CLOB, votes NUMBER, rank CLOB)
Show the names of players and names of their coaches in descending order of the votes of players.
SELECT T3.player_name, T2.coach_name FROM player_coach AS T1 JOIN coach AS T2 ON T1.coach_id = T2.coach_id JOIN player AS T3 ON T1.player_id = T3.player_id ORDER BY T3.votes DESC
SELECT "T3"."player_name", "T2"."coach_name" FROM "player_coach" "T1" JOIN "coach" "T2" ON "T1"."coach_id" = "T2"."coach_id" JOIN "player" "T3" ON "T1"."player_id" = "T3"."player_id" ORDER BY "T3"."votes" DESC
0.204102
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) CREATE TABLE diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
give me the number of patients diagnosed under diagnoses icd9 code 4659 whose drug type is additive.
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 = "4659" AND prescriptions.drug_type = "ADDITIVE"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "4659" = "diagnoses"."icd9_code" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" JOIN "prescriptions" ON "ADDITIVE" = "prescriptions"."drug_type" AND "demographic"."hadm_id" = "prescriptions"."hadm_id"
0.287109
CREATE TABLE table_71575 ("Date" CLOB, "Tournament" CLOB, "Surface" CLOB, "Opponent" CLOB, "Score" CLOB)
Who played on clay on 3 march 2012?
SELECT "Opponent" FROM table_71575 WHERE "Surface" = 'clay' AND "Date" = '3 march 2012'
SELECT "Opponent" FROM "table_71575" WHERE "Date" = '3 march 2012' AND "Surface" = 'clay'
0.086914
CREATE TABLE table_name_68 (county VARCHAR2, listed VARCHAR2, construction_completed VARCHAR2)
In what county is the entry that has a Construction Completed date of 07/19/2000 and a Listed date of 09/21/1984 located?
SELECT county FROM table_name_68 WHERE listed = "09/21/1984" AND construction_completed = "07/19/2000"
SELECT "county" FROM "table_name_68" WHERE "07/19/2000" = "construction_completed" AND "09/21/1984" = "listed"
0.107422
CREATE TABLE table_203_782 (id NUMBER, "year" NUMBER, "actor" CLOB, "award" CLOB, "category" CLOB, "role" CLOB, "episode" CLOB, "result" CLOB)
how many annie awards were won before 2009 ?
SELECT COUNT(*) FROM table_203_782 WHERE "award" = 'annie award' AND "year" < 2009
SELECT COUNT(*) FROM "table_203_782" WHERE "award" = 'annie award' AND "year" < 2009
0.082031
CREATE TABLE SuggestedEdits (Id NUMBER, PostId NUMBER, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId NUMBER, Comment CLOB, Text CLOB, Title CLOB, Tags CLOB, RevisionGUID other) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId NUMBER) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) CREATE TABLE ReviewTaskTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE PostNoticeTypes (Id NUMBER, ClassId NUMBER, Name CLOB, Body CLOB, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId NUMBER) CREATE TABLE Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) CREATE TABLE PendingFlags (Id NUMBER, FlagTypeId NUMBER, PostId NUMBER, CreationDate TIME, CloseReasonTypeId NUMBER, CloseAsOffTopicReasonTypeId NUMBER, DuplicateOfQuestionId NUMBER, BelongsOnBaseHostAddress CLOB) CREATE TABLE VoteTypes (Id NUMBER, Name CLOB) CREATE TABLE SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange NUMBER) CREATE TABLE ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE Posts (Id NUMBER, PostTypeId NUMBER, AcceptedAnswerId NUMBER, ParentId NUMBER, CreationDate TIME, DeletionDate TIME, Score NUMBER, ViewCount NUMBER, Body CLOB, OwnerUserId NUMBER, OwnerDisplayName CLOB, LastEditorUserId NUMBER, LastEditorDisplayName CLOB, LastEditDate TIME, LastActivityDate TIME, Title CLOB, Tags CLOB, AnswerCount NUMBER, CommentCount NUMBER, FavoriteCount NUMBER, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense CLOB) CREATE TABLE Votes (Id NUMBER, PostId NUMBER, VoteTypeId NUMBER, UserId NUMBER, CreationDate TIME, BountyAmount NUMBER) CREATE TABLE ReviewRejectionReasons (Id NUMBER, Name CLOB, Description CLOB, PostTypeId NUMBER) CREATE TABLE Comments (Id NUMBER, PostId NUMBER, Score NUMBER, Text CLOB, CreationDate TIME, UserDisplayName CLOB, UserId NUMBER, ContentLicense CLOB) CREATE TABLE PostNotices (Id NUMBER, PostId NUMBER, PostNoticeTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body CLOB, OwnerUserId NUMBER, DeletionUserId NUMBER) CREATE TABLE ReviewTaskResultTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE CloseAsOffTopicReasonTypes (Id NUMBER, IsUniversal BOOLEAN, InputTitle CLOB, MarkdownInputGuidance CLOB, MarkdownPostOwnerGuidance CLOB, MarkdownPrivilegedUserGuidance CLOB, MarkdownConcensusDescription CLOB, CreationDate TIME, CreationModeratorId NUMBER, ApprovalDate TIME, ApprovalModeratorId NUMBER, DeactivationDate TIME, DeactivationModeratorId NUMBER) CREATE TABLE PostsWithDeleted (Id NUMBER, PostTypeId NUMBER, AcceptedAnswerId NUMBER, ParentId NUMBER, CreationDate TIME, DeletionDate TIME, Score NUMBER, ViewCount NUMBER, Body CLOB, OwnerUserId NUMBER, OwnerDisplayName CLOB, LastEditorUserId NUMBER, LastEditorDisplayName CLOB, LastEditDate TIME, LastActivityDate TIME, Title CLOB, Tags CLOB, AnswerCount NUMBER, CommentCount NUMBER, FavoriteCount NUMBER, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense CLOB) CREATE TABLE Users (Id NUMBER, Reputation NUMBER, CreationDate TIME, DisplayName CLOB, LastAccessDate TIME, WebsiteUrl CLOB, Location CLOB, AboutMe CLOB, Views NUMBER, UpVotes NUMBER, DownVotes NUMBER, ProfileImageUrl CLOB, EmailHash CLOB, AccountId NUMBER) CREATE TABLE PostTypes (Id NUMBER, Name CLOB) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER) CREATE TABLE PostHistory (Id NUMBER, PostHistoryTypeId NUMBER, PostId NUMBER, RevisionGUID other, CreationDate TIME, UserId NUMBER, UserDisplayName CLOB, Comment CLOB, Text CLOB, ContentLicense CLOB) CREATE TABLE TagSynonyms (Id NUMBER, SourceTagName CLOB, TargetTagName CLOB, CreationDate TIME, OwnerUserId NUMBER, AutoRenameCount NUMBER, LastAutoRename TIME, Score NUMBER, ApprovedByUserId NUMBER, ApprovalDate TIME) CREATE TABLE PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate TIME) CREATE TABLE PostTags (PostId NUMBER, TagId NUMBER) CREATE TABLE PostHistoryTypes (Id NUMBER, Name CLOB) CREATE TABLE FlagTypes (Id NUMBER, Name CLOB, Description CLOB)
Find questions with unsuccessful bounites.
SELECT PostId FROM Votes WHERE Votes.VoteTypeId = 9 AND Votes.BountyAmount IS NULL
SELECT "PostId" FROM "Votes" WHERE "Votes"."BountyAmount" IS NULL AND "Votes"."VoteTypeId" = 9
0.091797
CREATE TABLE table_name_5 (constructor VARCHAR2, grid VARCHAR2)
Which vehicle has a Grid of 13?
SELECT constructor FROM table_name_5 WHERE grid = 13
SELECT "constructor" FROM "table_name_5" WHERE "grid" = 13
0.056641
CREATE TABLE table_42289 ("Rank" FLOAT, "Player" CLOB, "Country" CLOB, "Earnings ( $ ) " FLOAT, "Wins" FLOAT)
What was the lowest rank which earned 24,920,665?
SELECT MIN("Rank") FROM table_42289 WHERE "Earnings( $ )" = '24,920,665'
SELECT MIN("Rank") FROM "table_42289" WHERE "Earnings( $ )" = '24,920,665'
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 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 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)
calculate the maximum age of government health insurance patients who were hospitalized for 3 days.
SELECT MAX(demographic.age) FROM demographic WHERE demographic.insurance = "Government" AND demographic.days_stay = "3"
SELECT MAX("demographic"."age") FROM "demographic" WHERE "3" = "demographic"."days_stay" AND "Government" = "demographic"."insurance"
0.129883
CREATE TABLE table_24005 ("Game" FLOAT, "Date" CLOB, "Opponent" CLOB, "Result" CLOB, "Cardinals points" FLOAT, "Opponents" FLOAT, "Record" CLOB)
How many opponents were in North Carolina state game?
SELECT COUNT("Opponents") FROM table_24005 WHERE "Opponent" = 'North Carolina State'
SELECT COUNT("Opponents") FROM "table_24005" WHERE "Opponent" = 'North Carolina State'
0.083984
CREATE TABLE table_204_110 (id NUMBER, "year" NUMBER, "champion" CLOB, "city" CLOB, "llws" CLOB, "record" CLOB)
which city was champion in 1957 , monterrey or el campo ?
SELECT "city" FROM table_204_110 WHERE "year" = 1957
SELECT "city" FROM "table_204_110" WHERE "year" = 1957
0.052734
CREATE TABLE table_21376 ("Official Name" CLOB, "Status" CLOB, "Area km 2" CLOB, "Population" FLOAT, "Census Ranking" CLOB)
What status doe the area with a census ranking of 2,290 of 5,008 have?
SELECT "Status" FROM table_21376 WHERE "Census Ranking" = '2,290 of 5,008'
SELECT "Status" FROM "table_21376" WHERE "Census Ranking" = '2,290 of 5,008'
0.074219
CREATE TABLE table_26547 ("No. in series" FLOAT, "No. in season" FLOAT, "Title" CLOB, "Directed by" CLOB, "Written by" CLOB, "Original air date" CLOB, "Production code" FLOAT)
Who wrote the episode that originally aired on January 15, 1993?
SELECT "Written by" FROM table_26547 WHERE "Original air date" = 'January 15, 1993'
SELECT "Written by" FROM "table_26547" WHERE "Original air date" = 'January 15, 1993'
0.083008
CREATE TABLE journal (journalid NUMBER, journalname VARCHAR2) CREATE TABLE paperfield (fieldid NUMBER, paperid NUMBER) CREATE TABLE field (fieldid NUMBER) CREATE TABLE keyphrase (keyphraseid NUMBER, keyphrasename VARCHAR2) CREATE TABLE venue (venueid NUMBER, venuename VARCHAR2) CREATE TABLE writes (paperid NUMBER, authorid NUMBER) CREATE TABLE paperdataset (paperid NUMBER, datasetid NUMBER) CREATE TABLE cite (citingpaperid NUMBER, citedpaperid NUMBER) CREATE TABLE dataset (datasetid NUMBER, datasetname VARCHAR2) CREATE TABLE author (authorid NUMBER, authorname VARCHAR2) CREATE TABLE paperkeyphrase (paperid NUMBER, keyphraseid NUMBER) CREATE TABLE paper (paperid NUMBER, title VARCHAR2, venueid NUMBER, year NUMBER, numciting NUMBER, numcitedby NUMBER, journalid NUMBER)
Donald Elmazi citation count
SELECT DISTINCT COUNT(cite.citedpaperid) FROM author, cite, paper, writes WHERE author.authorname = 'Donald Elmazi' AND paper.paperid = cite.citedpaperid AND writes.authorid = author.authorid AND writes.paperid = paper.paperid
SELECT DISTINCT COUNT("cite"."citedpaperid") FROM "author" CROSS JOIN "cite" JOIN "paper" ON "cite"."citedpaperid" = "paper"."paperid" JOIN "writes" ON "author"."authorid" = "writes"."authorid" AND "paper"."paperid" = "writes"."paperid" WHERE "author"."authorname" = 'Donald Elmazi'
0.275391
CREATE TABLE table_name_94 (date VARCHAR2, opponent VARCHAR2)
when is the opponent lyoto machida?
SELECT date FROM table_name_94 WHERE opponent = "lyoto machida"
SELECT "date" FROM "table_name_94" WHERE "lyoto machida" = "opponent"
0.067383
CREATE TABLE university (School_ID NUMBER, School CLOB, Location CLOB, Founded FLOAT, Affiliation CLOB, Enrollment FLOAT, Nickname CLOB, Primary_conference CLOB) CREATE TABLE basketball_match (Team_ID NUMBER, School_ID NUMBER, Team_Name CLOB, ACC_Regular_Season CLOB, ACC_Percent CLOB, ACC_Home CLOB, ACC_Road CLOB, All_Games CLOB, All_Games_Percent NUMBER, All_Home CLOB, All_Road CLOB, All_Neutral CLOB)
Return a bar chart about the distribution of ACC_Road and Team_ID , and group by attribute All_Home, and list in ascending by the Y-axis.
SELECT ACC_Road, Team_ID FROM basketball_match GROUP BY All_Home, ACC_Road ORDER BY Team_ID
SELECT "ACC_Road", "Team_ID" FROM "basketball_match" GROUP BY "All_Home", "ACC_Road" ORDER BY "Team_ID"
0.100586
CREATE TABLE table_53489 ("Year" FLOAT, "Competition" CLOB, "Date" CLOB, "Location" CLOB, "Score" CLOB, "Result" CLOB)
What is the result of the Europe/Africa Group I, play-off competition?
SELECT "Result" FROM table_53489 WHERE "Competition" = 'europe/africa group i, play-off'
SELECT "Result" FROM "table_53489" WHERE "Competition" = 'europe/africa group i, play-off'
0.087891
CREATE TABLE table_name_95 (league_from VARCHAR2, player VARCHAR2, position VARCHAR2, pick__number VARCHAR2)
Which League from has a Position of lw, a Pick # larger than 34, and a Player of bradley ross?
SELECT league_from FROM table_name_95 WHERE position = "lw" AND pick__number > 34 AND player = "bradley ross"
SELECT "league_from" FROM "table_name_95" WHERE "bradley ross" = "player" AND "lw" = "position" AND "pick__number" > 34
0.116211
CREATE TABLE table_75017 ("Date" CLOB, "City" CLOB, "Opponent" CLOB, "Results\\u00b9" CLOB, "Type of game" CLOB)
What Type of game was played on Date of July 29?
SELECT "Type of game" FROM table_75017 WHERE "Date" = 'july 29'
SELECT "Type of game" FROM "table_75017" WHERE "Date" = 'july 29'
0.063477
CREATE TABLE wine (no NUMBER, grape CLOB, winery CLOB, appelation CLOB, state CLOB, name CLOB, year NUMBER, price NUMBER, score NUMBER, cases NUMBER, drink CLOB) CREATE TABLE appellations (no NUMBER, appelation CLOB, county CLOB, state CLOB, area CLOB, isava CLOB) CREATE TABLE grapes (id NUMBER, grape CLOB, color CLOB)
What is the winery at which the wine with the highest score was made?
SELECT winery FROM wine ORDER BY score LIMIT 1
SELECT "winery" FROM "wine" ORDER BY "score" FETCH FIRST 1 ROWS ONLY
0.066406
CREATE TABLE table_name_99 (total NUMBER, silver VARCHAR2, nation VARCHAR2, bronze VARCHAR2, gold VARCHAR2)
what is the average total when bronze is more than 0, gold is 0, the nation is united states (usa) and silver is 0?
SELECT AVG(total) FROM table_name_99 WHERE bronze > 0 AND gold = 0 AND nation = "united states (usa)" AND silver < 0
SELECT AVG("total") FROM "table_name_99" WHERE "bronze" > 0 AND "gold" = 0 AND "nation" = "united states (usa)" AND "silver" < 0
0.125
CREATE TABLE diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) 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 inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) 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 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 procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime 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 d_labitems (row_id NUMBER, itemid NUMBER, label 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_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) 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 labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME)
in 06/2105, what was the daily average weight of patient 4288?
SELECT AVG(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 = 4288)) AND chartevents.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'admit wt' AND d_items.linksto = 'chartevents') AND STRFTIME('%y-%m', chartevents.charttime) = '2105-06' GROUP BY STRFTIME('%y-%m-%d', chartevents.charttime)
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 4288 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 GROUP BY "icustay_id"), "_u_2" AS (SELECT "d_items"."itemid" FROM "d_items" WHERE "d_items"."label" = 'admit wt' AND "d_items"."linksto" = 'chartevents' GROUP BY "itemid") SELECT AVG("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 AND STRFTIME('%y-%m', "chartevents"."charttime") = '2105-06' GROUP BY STRFTIME('%y-%m-%d', "chartevents"."charttime")
0.77832
CREATE TABLE countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE jobs (JOB_ID VARCHAR2, JOB_TITLE VARCHAR2, MIN_SALARY NUMBER, MAX_SALARY NUMBER) CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_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 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 those employees who was hired before 2002-06-21, visualize a bar chart about the distribution of hire_date and the average of employee_id bin hire_date by weekday, and order the average of employee id in asc order.
SELECT HIRE_DATE, AVG(EMPLOYEE_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(EMPLOYEE_ID)
SELECT "HIRE_DATE", AVG("EMPLOYEE_ID") FROM "employees" WHERE "HIRE_DATE" < '2002-06-21' ORDER BY AVG("EMPLOYEE_ID")
0.113281
CREATE TABLE table_9835 ("Res." CLOB, "Record" CLOB, "Opponent" CLOB, "Method" CLOB, "Event" CLOB, "Round" CLOB)
What is the result when the method was decision (unanimous), and Chris Wilson was the opponent?
SELECT "Res." FROM table_9835 WHERE "Method" = 'decision (unanimous)' AND "Opponent" = 'chris wilson'
SELECT "Res." FROM "table_9835" WHERE "Method" = 'decision (unanimous)' AND "Opponent" = 'chris wilson'
0.100586
CREATE TABLE table_65800 ("Date" CLOB, "Venue" CLOB, "Score" CLOB, "Result" CLOB, "Competition" CLOB)
What was the venue when the score was 7-1?
SELECT "Venue" FROM table_65800 WHERE "Score" = '7-1'
SELECT "Venue" FROM "table_65800" WHERE "Score" = '7-1'
0.053711
CREATE TABLE table_204_664 (id NUMBER, "rank" NUMBER, "bib" NUMBER, "name" CLOB, "nationality" CLOB, "start" CLOB, "penalties ( p+p+s+s ) " CLOB, "time" CLOB, "deficit" CLOB)
how long did it take for erik lesser to finish ?
SELECT "time" FROM table_204_664 WHERE "name" = 'erik lesser'
SELECT "time" FROM "table_204_664" WHERE "name" = 'erik lesser'
0.061523
CREATE TABLE table_29477 ("Team" CLOB, "Outgoing head coach" CLOB, "Manner of departure" CLOB, "Date of vacancy" CLOB, "Position in table" FLOAT, "Incoming head coach" CLOB, "Date of appointment" CLOB)
What is the team with the date of vacancy 8 dec 2010?
SELECT "Team" FROM table_29477 WHERE "Date of vacancy" = '8 Dec 2010'
SELECT "Team" FROM "table_29477" WHERE "Date of vacancy" = '8 Dec 2010'
0.069336
CREATE TABLE table_name_16 (year NUMBER, tournament VARCHAR2)
What year was the Commonwealth Games?
SELECT SUM(year) FROM table_name_16 WHERE tournament = "commonwealth games"
SELECT SUM("year") FROM "table_name_16" WHERE "commonwealth games" = "tournament"
0.079102
CREATE TABLE table_name_62 (points NUMBER, draw VARCHAR2, rank VARCHAR2)
What is the lowest points with 6 draws and lower than rank 10?
SELECT MIN(points) FROM table_name_62 WHERE draw = 6 AND rank > 10
SELECT MIN("points") FROM "table_name_62" WHERE "draw" = 6 AND "rank" > 10
0.072266
CREATE TABLE table_43328 ("Rank" FLOAT, "Name" CLOB, "Years" CLOB, "Matches" FLOAT, "Goals" FLOAT)
What is the lowest Rank when the goals are less than 124 for Jeff Cunningham?
SELECT MIN("Rank") FROM table_43328 WHERE "Goals" > '124' AND "Name" = 'jeff cunningham'
SELECT MIN("Rank") FROM "table_43328" WHERE "Goals" > '124' AND "Name" = 'jeff cunningham'
0.087891
CREATE TABLE table_55628 ("Year" FLOAT, "Network" CLOB, "Play-by-play" CLOB, "Colour commentator ( s ) " CLOB, "Studio host" CLOB)
Which network has a play-by-play announcer of John Wells?
SELECT "Network" FROM table_55628 WHERE "Play-by-play" = 'john wells'
SELECT "Network" FROM "table_55628" WHERE "Play-by-play" = 'john wells'
0.069336
CREATE TABLE table_name_72 (record VARCHAR2, date VARCHAR2)
What is Record, when Date is 'November 22'?
SELECT record FROM table_name_72 WHERE date = "november 22"
SELECT "record" FROM "table_name_72" WHERE "date" = "november 22"
0.063477
CREATE TABLE table_53270 ("Home team" CLOB, "Home team score" CLOB, "Away team" CLOB, "Away team score" CLOB, "Venue" CLOB, "Date" CLOB)
Name the home team when the away team was essendon
SELECT "Home team score" FROM table_53270 WHERE "Away team" = 'essendon'
SELECT "Home team score" FROM "table_53270" WHERE "Away team" = 'essendon'
0.072266
CREATE TABLE Rooms (RoomId CLOB, roomName CLOB, beds NUMBER, bedType CLOB, maxOccupancy NUMBER, basePrice NUMBER, decor CLOB) CREATE TABLE Reservations (Code NUMBER, Room CLOB, CheckIn CLOB, CheckOut CLOB, Rate FLOAT, LastName CLOB, FirstName CLOB, Adults NUMBER, Kids NUMBER)
What is the minimum price of the rooms for each different decor? Show me a bar chart!
SELECT decor, MIN(basePrice) FROM Rooms GROUP BY decor
SELECT "decor", MIN("basePrice") FROM "Rooms" GROUP BY "decor"
0.060547
CREATE TABLE table_name_68 (opponents_in_the_final VARCHAR2, score_in_the_final VARCHAR2)
Tell me the opponents for score in the final of 1 6, 2 6
SELECT opponents_in_the_final FROM table_name_68 WHERE score_in_the_final = "1–6, 2–6"
SELECT "opponents_in_the_final" FROM "table_name_68" WHERE "1–6, 2–6" = "score_in_the_final"
0.089844
CREATE TABLE table_19346 ("Week" FLOAT, "Date" CLOB, "Kickoff ( ET ) " CLOB, "TV" CLOB, "Opponent" CLOB, "Result" CLOB, "Record" CLOB, "Game Site" CLOB)
What date did they play in Cleveland Municipal Stadium?
SELECT "Date" FROM table_19346 WHERE "Game Site" = 'Cleveland Municipal Stadium'
SELECT "Date" FROM "table_19346" WHERE "Game Site" = 'Cleveland Municipal Stadium'
0.080078
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 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)
provide the number of patients whose admission type is urgent and diagnoses long title is acute salpingitis and oophoritis?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "URGENT" AND diagnoses.long_title = "Acute salpingitis and oophoritis"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Acute salpingitis and oophoritis" = "diagnoses"."long_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "URGENT" = "demographic"."admission_type"
0.244141
CREATE TABLE table_40494 ("Name" CLOB, "Built by HM Dockyard" CLOB, "Ordered" CLOB, "Laid down" CLOB, "Launched" CLOB)
What was launched and laid down in February 1819?
SELECT "Launched" FROM table_40494 WHERE "Laid down" = 'february 1819'
SELECT "Launched" FROM "table_40494" WHERE "Laid down" = 'february 1819'
0.070313
CREATE TABLE table_204_814 (id NUMBER, "date" CLOB, "opposition" CLOB, "result" CLOB, "score" CLOB, "brazil scorers" CLOB, "competition" CLOB)
how many games did this team play in 1982 ?
SELECT COUNT(*) FROM table_204_814
SELECT COUNT(*) FROM "table_204_814"
0.035156
CREATE TABLE table_13147 ("Player" CLOB, "Country" CLOB, "Year ( s ) won" CLOB, "Total" FLOAT, "To par" CLOB, "Finish" CLOB)
which To par has a Country of united states, and a Player of dave stockton?
SELECT "To par" FROM table_13147 WHERE "Country" = 'united states' AND "Player" = 'dave stockton'
SELECT "To par" FROM "table_13147" WHERE "Country" = 'united states' AND "Player" = 'dave stockton'
0.09668
CREATE TABLE table_name_87 (at_neutral_site VARCHAR2, overall_record VARCHAR2)
With an overall record of MU, 15-8 what is the at neutral site?
SELECT at_neutral_site FROM table_name_87 WHERE overall_record = "mu, 15-8"
SELECT "at_neutral_site" FROM "table_name_87" WHERE "mu, 15-8" = "overall_record"
0.079102
CREATE TABLE table_name_19 (year VARCHAR2, nominated VARCHAR2)
What year was Teen Angels 2 nominated?
SELECT year FROM table_name_19 WHERE nominated = "teen angels 2"
SELECT "year" FROM "table_name_19" WHERE "nominated" = "teen angels 2"
0.068359
CREATE TABLE table_67500 ("No.1" CLOB, "No.2" CLOB, "No.3" CLOB, "No.4" CLOB, "No.5" CLOB, "No.6" CLOB, "No.7" CLOB, "No.8" CLOB, "FINAL" CLOB)
What is the final result of the team that has Simara as No.5?
SELECT "FINAL" FROM table_67500 WHERE "No.5" = 'simara'
SELECT "FINAL" FROM "table_67500" WHERE "No.5" = 'simara'
0.055664
CREATE TABLE table_name_75 (lane NUMBER, react VARCHAR2, name VARCHAR2)
What is the sum of Land, when React is greater than 0.217, and when Name is Yoel Hern ndez?
SELECT SUM(lane) FROM table_name_75 WHERE react > 0.217 AND name = "yoel hernández"
SELECT SUM("lane") FROM "table_name_75" WHERE "name" = "yoel hernández" AND "react" > 0.217
0.088867
CREATE TABLE table_12564633_1 (series__number NUMBER, season__number VARCHAR2)
What is the series number for Season #18?
SELECT MIN(series__number) FROM table_12564633_1 WHERE season__number = 18
SELECT MIN("series__number") FROM "table_12564633_1" WHERE "season__number" = 18
0.078125
CREATE TABLE Student (StuID NUMBER, LName VARCHAR2, Fname VARCHAR2, Age NUMBER, Sex VARCHAR2, Major NUMBER, Advisor NUMBER, city_code VARCHAR2) CREATE TABLE Dorm (dormid NUMBER, dorm_name VARCHAR2, student_capacity NUMBER, gender VARCHAR2) CREATE TABLE Dorm_amenity (amenid NUMBER, amenity_name VARCHAR2) CREATE TABLE Lives_in (stuid NUMBER, dormid NUMBER, room_number NUMBER) CREATE TABLE Has_amenity (dormid NUMBER, amenid NUMBER)
Visualize a bar chart for what is the average age for each dorm and what are the names of each dorm?, could you sort bar from high to low order please?
SELECT dorm_name, AVG(T1.Age) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name ORDER BY dorm_name DESC
SELECT "dorm_name", AVG("T1"."Age") FROM "Student" "T1" JOIN "Lives_in" "T2" ON "T1"."stuid" = "T2"."stuid" JOIN "Dorm" "T3" ON "T2"."dormid" = "T3"."dormid" GROUP BY "T3"."dorm_name" ORDER BY "dorm_name" DESC
0.204102
CREATE TABLE table_name_10 (goals_conceded NUMBER, points VARCHAR2, lost VARCHAR2)
What is the total of Goals Conceded that has Points smaller than 21 and a Lost thats smaller than 8?
SELECT SUM(goals_conceded) FROM table_name_10 WHERE points < 21 AND lost < 8
SELECT SUM("goals_conceded") FROM "table_name_10" WHERE "lost" < 8 AND "points" < 21
0.082031
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) 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 intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) 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 treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME)
what was the first specimen test of patient 031-4423?
SELECT microlab.culturesite FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '031-4423')) ORDER BY microlab.culturetakentime LIMIT 1
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '031-4423' 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 "microlab"."culturesite" FROM "microlab" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "microlab"."patientunitstayid" WHERE NOT "_u_1"."" IS NULL ORDER BY "microlab"."culturetakentime" FETCH FIRST 1 ROWS ONLY
0.548828
CREATE TABLE dual_carrier (main_airline VARCHAR2, low_flight_number NUMBER, high_flight_number NUMBER, dual_airline VARCHAR2, service_name CLOB) 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_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 ground_service (city_code CLOB, airport_code CLOB, transport_type CLOB, ground_fare NUMBER) CREATE TABLE time_interval (period CLOB, begin_time NUMBER, end_time NUMBER) CREATE TABLE airline (airline_code VARCHAR2, airline_name CLOB, note CLOB) CREATE TABLE flight_fare (flight_id NUMBER, fare_id NUMBER) CREATE TABLE state (state_code CLOB, state_name CLOB, country_name CLOB) 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 compartment_class (compartment VARCHAR2, class_type VARCHAR2) CREATE TABLE days (days_code VARCHAR2, day_name VARCHAR2) CREATE TABLE code_description (code VARCHAR2, description 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) CREATE TABLE food_service (meal_code CLOB, meal_number NUMBER, compartment CLOB, meal_description VARCHAR2) 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 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 date_day (month_number NUMBER, day_number NUMBER, year NUMBER, day_name VARCHAR2) CREATE TABLE time_zone (time_zone_code CLOB, time_zone_name CLOB, hours_from_gmt 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 equipment_sequence (aircraft_code_sequence VARCHAR2, aircraft_code VARCHAR2) CREATE TABLE flight_leg (flight_id NUMBER, leg_number NUMBER, leg_flight NUMBER) CREATE TABLE city (city_code VARCHAR2, city_name VARCHAR2, state_code VARCHAR2, country_name VARCHAR2, time_zone_code 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)
hi i'm calling from BOSTON i'd like to make a flight to either ORLANDO or LOS ANGELES
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, city AS CITY_0, city AS CITY_1, city AS CITY_2, flight WHERE ((flight.to_airport = AIRPORT_SERVICE_1.airport_code AND CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ORLANDO') OR (flight.to_airport = AIRPORT_SERVICE_2.airport_code AND CITY_2.city_code = AIRPORT_SERVICE_2.city_code AND CITY_2.city_name = 'LOS ANGELES')) 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" CROSS JOIN "city" "CITY_1" JOIN "city" "CITY_0" ON "AIRPORT_SERVICE_0"."city_code" = "CITY_0"."city_code" AND "CITY_0"."city_name" = 'BOSTON' JOIN "city" "CITY_2" ON "CITY_1"."city_name" = 'ORLANDO' OR "CITY_2"."city_name" = 'LOS ANGELES' JOIN "flight" ON "AIRPORT_SERVICE_0"."airport_code" = "flight"."from_airport" JOIN "airport_service" "AIRPORT_SERVICE_2" ON ("AIRPORT_SERVICE_2"."airport_code" = "flight"."to_airport" OR "CITY_1"."city_name" = 'ORLANDO') AND ("AIRPORT_SERVICE_2"."city_code" = "CITY_2"."city_code" OR "CITY_1"."city_name" = 'ORLANDO') JOIN "airport_service" "AIRPORT_SERVICE_1" ON ("AIRPORT_SERVICE_1"."airport_code" = "flight"."to_airport" OR "AIRPORT_SERVICE_2"."airport_code" = "flight"."to_airport") AND ("AIRPORT_SERVICE_1"."airport_code" = "flight"."to_airport" OR "AIRPORT_SERVICE_2"."city_code" = "CITY_2"."city_code") AND ("AIRPORT_SERVICE_1"."airport_code" = "flight"."to_airport" OR "CITY_2"."city_name" = 'LOS ANGELES') AND ("AIRPORT_SERVICE_1"."city_code" = "CITY_1"."city_code" OR "AIRPORT_SERVICE_2"."airport_code" = "flight"."to_airport") AND ("AIRPORT_SERVICE_1"."city_code" = "CITY_1"."city_code" OR "AIRPORT_SERVICE_2"."city_code" = "CITY_2"."city_code") AND ("AIRPORT_SERVICE_1"."city_code" = "CITY_1"."city_code" OR "CITY_2"."city_name" = 'LOS ANGELES')
1.34375
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) 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 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 patients who stayed more than 69 days in the hospital with drug code metr500.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.days_stay > "69" AND prescriptions.formulary_drug_cd = "METR500"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "METR500" = "prescriptions"."formulary_drug_cd" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "69" < "demographic"."days_stay"
0.229492
CREATE TABLE table_197286_4 (distance VARCHAR2, direction VARCHAR2)
Name the distance from north
SELECT distance FROM table_197286_4 WHERE direction = "North"
SELECT "distance" FROM "table_197286_4" WHERE "North" = "direction"
0.06543
CREATE TABLE procedures (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) 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 diagnoses (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
what is the number of patients whose year of birth is less than 2109 and lab test name is magnesium, urine?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2109" AND lab.label = "Magnesium, Urine"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "Magnesium, Urine" = "lab"."label" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "2109" > "demographic"."dob_year"
0.198242
CREATE TABLE gas_station (Station_ID NUMBER, Open_Year NUMBER, Location CLOB, Manager_Name CLOB, Vice_Manager_Name CLOB, Representative_Name CLOB) CREATE TABLE company (Company_ID NUMBER, Rank NUMBER, Company CLOB, Headquarters CLOB, Main_Industry CLOB, Sales_billion FLOAT, Profits_billion FLOAT, Assets_billion FLOAT, Market_Value FLOAT) CREATE TABLE station_company (Station_ID NUMBER, Company_ID NUMBER, Rank_of_the_Year NUMBER)
How many gas stations dors each manager have? Plot a bar chart.
SELECT Manager_Name, COUNT(Manager_Name) FROM gas_station GROUP BY Manager_Name
SELECT "Manager_Name", COUNT("Manager_Name") FROM "gas_station" GROUP BY "Manager_Name"
0.084961
CREATE TABLE salary (salary VARCHAR2, YEAR VARCHAR2)
List the 3 highest salaries of the players in 2001?
SELECT salary FROM salary WHERE YEAR = 2001 ORDER BY salary DESC LIMIT 3
SELECT "salary" FROM "salary" WHERE "YEAR" = 2001 ORDER BY "salary" DESC FETCH FIRST 3 ROWS ONLY
0.09375
CREATE TABLE table_name_13 (year VARCHAR2, serial_title VARCHAR2)
I want the year for the three musketeers
SELECT year FROM table_name_13 WHERE serial_title = "the three musketeers"
SELECT "year" FROM "table_name_13" WHERE "serial_title" = "the three musketeers"
0.078125
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)
give the number of black/african american patients whose diagnoses icd9 code is 3315.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.ethnicity = "BLACK/AFRICAN AMERICAN" AND diagnoses.icd9_code = "3315"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "3315" = "diagnoses"."icd9_code" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "BLACK/AFRICAN AMERICAN" = "demographic"."ethnicity"
0.226563
CREATE TABLE table_60070 ("Team 1" CLOB, "Agg." CLOB, "Team 2" CLOB, "1st leg" CLOB, "2nd leg" CLOB)
What is 1st Leg, when Team 1 is 'Portol Palma Mallorca'?
SELECT "1st leg" FROM table_60070 WHERE "Team 1" = 'portol palma mallorca'
SELECT "1st leg" FROM "table_60070" WHERE "Team 1" = 'portol palma mallorca'
0.074219
CREATE TABLE table_name_93 (week VARCHAR2, opponent VARCHAR2, attendance VARCHAR2)
For the 1967 Cleveland Browns season what is the total number of times they played the Minnesota Vikings and had an atttendance smaller than 68,431?
SELECT COUNT(week) FROM table_name_93 WHERE opponent = "minnesota vikings" AND attendance < 68 OFFSET 431
SELECT COUNT("week") FROM "table_name_93" WHERE "attendance" < 68 AND "minnesota vikings" = "opponent" OFFSET 431 ROWS
0.115234
CREATE TABLE d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE d_icd_procedures (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 outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value 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 labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom 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 procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) 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 cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost NUMBER) CREATE TABLE patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label CLOB) CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name 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 is the percentile 109.0 in the laboratory test of chloride with regard to the same age of patient 15986 in their current hospital encounter?
SELECT DISTINCT t1.c1 FROM (SELECT labevents.valuenum, PERCENT_RANK() OVER (ORDER BY labevents.valuenum) AS c1 FROM labevents WHERE labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'chloride') AND labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age = (SELECT admissions.age FROM admissions WHERE admissions.subject_id = 15986 AND admissions.dischtime IS NULL))) AS t1 WHERE t1.valuenum = 109.0
WITH "_u_0" AS (SELECT "d_labitems"."itemid" FROM "d_labitems" WHERE "d_labitems"."label" = 'chloride' GROUP BY "itemid"), "_u_2" AS (SELECT "admissions"."hadm_id" FROM "admissions" JOIN "admissions" "admissions_2" ON "admissions"."age" = "admissions_2"."age" AND "admissions_2"."dischtime" IS NULL AND "admissions_2"."subject_id" = 15986 GROUP BY "hadm_id") SELECT DISTINCT PERCENT_RANK() OVER (ORDER BY "labevents"."valuenum") FROM "labevents" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "labevents"."itemid" LEFT JOIN "_u_2" "_u_2" ON "_u_2"."" = "labevents"."hadm_id" WHERE "labevents"."valuenum" = 109.0 AND NOT "_u_0"."" IS NULL AND NOT "_u_2"."" IS NULL
0.639648
CREATE TABLE table_name_14 (location VARCHAR2, winner VARCHAR2)
What is the location where shocker was the winner?
SELECT location FROM table_name_14 WHERE winner = "shocker"
SELECT "location" FROM "table_name_14" WHERE "shocker" = "winner"
0.063477
CREATE TABLE PostTags (PostId NUMBER, TagId NUMBER) CREATE TABLE CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE CloseAsOffTopicReasonTypes (Id NUMBER, IsUniversal BOOLEAN, InputTitle CLOB, MarkdownInputGuidance CLOB, MarkdownPostOwnerGuidance CLOB, MarkdownPrivilegedUserGuidance CLOB, MarkdownConcensusDescription CLOB, CreationDate TIME, CreationModeratorId NUMBER, ApprovalDate TIME, ApprovalModeratorId NUMBER, DeactivationDate TIME, DeactivationModeratorId NUMBER) CREATE TABLE TagSynonyms (Id NUMBER, SourceTagName CLOB, TargetTagName CLOB, CreationDate TIME, OwnerUserId NUMBER, AutoRenameCount NUMBER, LastAutoRename TIME, Score NUMBER, ApprovedByUserId NUMBER, ApprovalDate TIME) CREATE TABLE Posts (Id NUMBER, PostTypeId NUMBER, AcceptedAnswerId NUMBER, ParentId NUMBER, CreationDate TIME, DeletionDate TIME, Score NUMBER, ViewCount NUMBER, Body CLOB, OwnerUserId NUMBER, OwnerDisplayName CLOB, LastEditorUserId NUMBER, LastEditorDisplayName CLOB, LastEditDate TIME, LastActivityDate TIME, Title CLOB, Tags CLOB, AnswerCount NUMBER, CommentCount NUMBER, FavoriteCount NUMBER, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense CLOB) CREATE TABLE ReviewTaskTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE FlagTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE Users (Id NUMBER, Reputation NUMBER, CreationDate TIME, DisplayName CLOB, LastAccessDate TIME, WebsiteUrl CLOB, Location CLOB, AboutMe CLOB, Views NUMBER, UpVotes NUMBER, DownVotes NUMBER, ProfileImageUrl CLOB, EmailHash CLOB, AccountId NUMBER) CREATE TABLE PostNotices (Id NUMBER, PostId NUMBER, PostNoticeTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body CLOB, OwnerUserId NUMBER, DeletionUserId NUMBER) CREATE TABLE SuggestedEdits (Id NUMBER, PostId NUMBER, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId NUMBER, Comment CLOB, Text CLOB, Title CLOB, Tags CLOB, RevisionGUID other) CREATE TABLE PostNoticeTypes (Id NUMBER, ClassId NUMBER, Name CLOB, Body CLOB, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId NUMBER) CREATE TABLE PostTypes (Id NUMBER, Name CLOB) CREATE TABLE PostHistoryTypes (Id NUMBER, Name CLOB) CREATE TABLE ReviewTaskResultTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE PostsWithDeleted (Id NUMBER, PostTypeId NUMBER, AcceptedAnswerId NUMBER, ParentId NUMBER, CreationDate TIME, DeletionDate TIME, Score NUMBER, ViewCount NUMBER, Body CLOB, OwnerUserId NUMBER, OwnerDisplayName CLOB, LastEditorUserId NUMBER, LastEditorDisplayName CLOB, LastEditDate TIME, LastActivityDate TIME, Title CLOB, Tags CLOB, AnswerCount NUMBER, CommentCount NUMBER, FavoriteCount NUMBER, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense CLOB) CREATE TABLE PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate TIME) CREATE TABLE VoteTypes (Id NUMBER, Name CLOB) CREATE TABLE Comments (Id NUMBER, PostId NUMBER, Score NUMBER, Text CLOB, CreationDate TIME, UserDisplayName CLOB, UserId NUMBER, ContentLicense CLOB) CREATE TABLE Votes (Id NUMBER, PostId NUMBER, VoteTypeId NUMBER, UserId NUMBER, CreationDate TIME, BountyAmount NUMBER) CREATE TABLE Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) CREATE TABLE PostHistory (Id NUMBER, PostHistoryTypeId NUMBER, PostId NUMBER, RevisionGUID other, CreationDate TIME, UserId NUMBER, UserDisplayName CLOB, Comment CLOB, Text CLOB, ContentLicense CLOB) CREATE TABLE ReviewRejectionReasons (Id NUMBER, Name CLOB, Description CLOB, PostTypeId NUMBER) CREATE TABLE PendingFlags (Id NUMBER, FlagTypeId NUMBER, PostId NUMBER, CreationDate TIME, CloseReasonTypeId NUMBER, CloseAsOffTopicReasonTypeId NUMBER, DuplicateOfQuestionId NUMBER, BelongsOnBaseHostAddress CLOB) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId NUMBER) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) CREATE TABLE SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange NUMBER) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER)
Top 10 Tags Associated with Posts Created in 2017.
SELECT Tags, COUNT(DISTINCT Id) AS post_cnt FROM Posts WHERE YEAR(CreationDate) = '2017' GROUP BY Tags ORDER BY post_cnt DESC LIMIT 10
SELECT "Tags", COUNT(DISTINCT "Id") AS "post_cnt" FROM "Posts" WHERE YEAR("CreationDate") = '2017' GROUP BY "Tags" ORDER BY "post_cnt" DESC FETCH FIRST 10 ROWS ONLY
0.160156
CREATE TABLE table_203_90 (id NUMBER, "religious\ group" CLOB, "population\ %" CLOB, "growth\ ( 1991-2001 ) " CLOB, "sex ratio\ ( total ) " NUMBER, "literacy\ ( % ) " CLOB, "work participation\ ( % ) " CLOB, "sex ratio\ ( rural ) " NUMBER, "sex ratio\ ( urban ) " NUMBER, "sex ratio\ ( child ) " NUMBER)
how many of these religious groups have a literacy rate of above 60 % ?
SELECT COUNT("religious\ngroup") FROM table_203_90 WHERE "literacy\n(%)" > 60
SELECT COUNT("religious\ngroup") FROM "table_203_90" WHERE "literacy\n(%)" > 60
0.077148
CREATE TABLE table_37285 ("Position" FLOAT, "Team" CLOB, "Points" FLOAT, "Played" FLOAT, "Drawn" FLOAT, "Lost" FLOAT, "Against" FLOAT, "Difference" CLOB)
What is the highest amount of plays for fluminense?
SELECT MAX("Played") FROM table_37285 WHERE "Team" = 'fluminense'
SELECT MAX("Played") FROM "table_37285" WHERE "Team" = 'fluminense'
0.06543
CREATE TABLE school (Location VARCHAR2, School_ID VARCHAR2) CREATE TABLE school_details (Nickname VARCHAR2, School_ID VARCHAR2)
Show locations and nicknames of schools.
SELECT T1.Location, T2.Nickname FROM school AS T1 JOIN school_details AS T2 ON T1.School_ID = T2.School_ID
SELECT "T1"."Location", "T2"."Nickname" FROM "school" "T1" JOIN "school_details" "T2" ON "T1"."School_ID" = "T2"."School_ID"
0.121094
CREATE TABLE suppliers (supplier_id NUMBER, supplier_name CLOB, supplier_phone CLOB) CREATE TABLE customer_addresses (customer_id NUMBER, address_id NUMBER, date_from TIME, date_to TIME) CREATE TABLE products (product_id NUMBER, product_type_code CLOB, product_name CLOB, product_price NUMBER) CREATE TABLE department_stores (dept_store_id NUMBER, dept_store_chain_id NUMBER, store_name CLOB, store_address CLOB, store_phone CLOB, store_email CLOB) CREATE TABLE departments (department_id NUMBER, dept_store_id NUMBER, department_name CLOB) CREATE TABLE addresses (address_id NUMBER, address_details CLOB) CREATE TABLE customer_orders (order_id NUMBER, customer_id NUMBER, order_status_code CLOB, order_date TIME) CREATE TABLE department_store_chain (dept_store_chain_id NUMBER, dept_store_chain_name CLOB) CREATE TABLE staff (staff_id NUMBER, staff_gender CLOB, staff_name CLOB) CREATE TABLE customers (customer_id NUMBER, payment_method_code CLOB, customer_code CLOB, customer_name CLOB, customer_address CLOB, customer_phone CLOB, customer_email CLOB) CREATE TABLE supplier_addresses (supplier_id NUMBER, address_id NUMBER, date_from TIME, date_to TIME) CREATE TABLE order_items (order_item_id NUMBER, order_id NUMBER, product_id NUMBER) CREATE TABLE staff_department_assignments (staff_id NUMBER, department_id NUMBER, date_assigned_from TIME, job_title_code CLOB, date_assigned_to TIME) CREATE TABLE product_suppliers (product_id NUMBER, supplier_id NUMBER, date_supplied_from TIME, date_supplied_to TIME, total_amount_purchased CLOB, total_value_purchased NUMBER)
For each product type, return the maximum and minimum price.
SELECT product_type_code, MAX(product_price), MIN(product_price) FROM products GROUP BY product_type_code
SELECT "product_type_code", MAX("product_price"), MIN("product_price") FROM "products" GROUP BY "product_type_code"
0.112305
CREATE TABLE table_68258 ("Year" CLOB, "Position" CLOB, "League" CLOB, "FA Cup" CLOB, "Malaysia Cup" CLOB)
What year was the League the malaysian super league, and a Malaysia Cup of group stage?
SELECT "Year" FROM table_68258 WHERE "League" = 'malaysian super league' AND "Malaysia Cup" = 'group stage'
SELECT "Year" FROM "table_68258" WHERE "League" = 'malaysian super league' AND "Malaysia Cup" = 'group stage'
0.106445
CREATE TABLE table_35416 ("Week" FLOAT, "Date" CLOB, "Opponent" CLOB, "Time ( ET ) " CLOB, "Result" CLOB)
How many weeks have an Opponent of at new york giants?
SELECT COUNT("Week") FROM table_35416 WHERE "Opponent" = 'at new york giants'
SELECT COUNT("Week") FROM "table_35416" WHERE "Opponent" = 'at new york giants'
0.077148
CREATE TABLE table_name_87 (water_depth VARCHAR2, location VARCHAR2, name VARCHAR2)
What was the water depth in the Gulf of Mexico named Discoverer Clear Leader?
SELECT water_depth FROM table_name_87 WHERE location = "gulf of mexico" AND name = "discoverer clear leader"
SELECT "water_depth" FROM "table_name_87" WHERE "discoverer clear leader" = "name" AND "gulf of mexico" = "location"
0.113281
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 treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime TIME) CREATE TABLE cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) 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 intakeoutput (intakeoutputid NUMBER, patientunitstayid NUMBER, cellpath CLOB, celllabel CLOB, cellvaluenumeric NUMBER, intakeoutputtime TIME) 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)
when was the last time that patient 009-5001 was measured / taken a measurement of systemicsystolic today?
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001')) AND NOT vitalperiodic.systemicsystolic IS NULL AND DATETIME(vitalperiodic.observationtime, 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') ORDER BY vitalperiodic.observationtime DESC LIMIT 1
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '009-5001' 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 "vitalperiodic"."observationtime" FROM "vitalperiodic" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "vitalperiodic"."patientunitstayid" WHERE DATETIME("vitalperiodic"."observationtime", 'start of day') = DATETIME(CURRENT_TIME(), 'start of day', '-0 day') AND NOT "_u_1"."" IS NULL AND NOT "vitalperiodic"."systemicsystolic" IS NULL ORDER BY "vitalperiodic"."observationtime" DESC FETCH FIRST 1 ROWS ONLY
0.740234
CREATE TABLE table_49796 ("Province" CLOB, "South Asians 2001" FLOAT, "% 2001" CLOB, "South Asians 2011" FLOAT, "% 2011" CLOB)
How many South Asians on average were in Alberta in 2001 and in 2011 had 159,055?
SELECT AVG("South Asians 2001") FROM table_49796 WHERE "Province" = 'alberta' AND "South Asians 2011" > '159,055'
SELECT AVG("South Asians 2001") FROM "table_49796" WHERE "Province" = 'alberta' AND "South Asians 2011" > '159,055'
0.112305
CREATE TABLE table_27588823_2 (callsign VARCHAR2, location VARCHAR2)
How many call signs does the location masinloc, zambales have?
SELECT COUNT(callsign) FROM table_27588823_2 WHERE location = "Masinloc, Zambales"
SELECT COUNT("callsign") FROM "table_27588823_2" WHERE "Masinloc, Zambales" = "location"
0.085938
CREATE TABLE table_28421 ("No." FLOAT, "Title" CLOB, "Directed by" CLOB, "Written by" CLOB, "U.S. viewers ( million ) " CLOB, "Rank ( week ) " FLOAT, "Original air date" CLOB, "Production code" CLOB)
What is the production code for the episode that had 18.07 million viewers?
SELECT "Production code" FROM table_28421 WHERE "U.S. viewers (million)" = '18.07'
SELECT "Production code" FROM "table_28421" WHERE "U.S. viewers (million)" = '18.07'
0.082031
CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) 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 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 diagnoses_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME) 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 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 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 inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER) CREATE TABLE labevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) CREATE TABLE d_icd_procedures (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 procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime TIME)
what are the three most frequent specimen tests patients were given within the same month after being diagnosed with bmi 33.0-33.9,adult until 2104?
SELECT t3.spec_type_desc FROM (SELECT t2.spec_type_desc, 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 = 'bmi 33.0-33.9,adult') AND STRFTIME('%y', diagnoses_icd.charttime) <= '2104') AS t1 JOIN (SELECT admissions.subject_id, microbiologyevents.spec_type_desc, microbiologyevents.charttime FROM microbiologyevents JOIN admissions ON microbiologyevents.hadm_id = admissions.hadm_id WHERE STRFTIME('%y', microbiologyevents.charttime) <= '2104') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.charttime, 'start of month') GROUP BY t2.spec_type_desc) AS t3 WHERE t3.c1 <= 3
WITH "t2" AS (SELECT "admissions"."subject_id", "microbiologyevents"."spec_type_desc", "microbiologyevents"."charttime" FROM "microbiologyevents" JOIN "admissions" ON "admissions"."hadm_id" = "microbiologyevents"."hadm_id" WHERE STRFTIME('%y', "microbiologyevents"."charttime") <= '2104'), "t3" AS (SELECT "t2"."spec_type_desc", 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" = 'bmi 33.0-33.9,adult' 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"."charttime" AND DATETIME("diagnoses_icd"."charttime", 'start of month') = DATETIME("t2"."charttime", 'start of month') WHERE STRFTIME('%y', "diagnoses_icd"."charttime") <= '2104' GROUP BY "t2"."spec_type_desc") SELECT "t3"."spec_type_desc" FROM "t3" "t3" WHERE "t3"."c1" <= 3
0.973633
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 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 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 are with admission location clinic referral/premature and discharged to snf?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_location = "CLINIC REFERRAL/PREMATURE" AND demographic.discharge_location = "SNF"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "CLINIC REFERRAL/PREMATURE" = "demographic"."admission_location" AND "SNF" = "demographic"."discharge_location"
0.181641
CREATE TABLE table_79396 ("Olympics" CLOB, "Name" CLOB, "Country" CLOB, "Medal" CLOB, "Event" CLOB)
What country has a silver medal in the boxing, heavyweight event?
SELECT "Country" FROM table_79396 WHERE "Medal" = 'silver' AND "Event" = 'boxing, heavyweight'
SELECT "Country" FROM "table_79396" WHERE "Event" = 'boxing, heavyweight' AND "Medal" = 'silver'
0.09375
CREATE TABLE table_name_72 (nationality VARCHAR2, school_country VARCHAR2)
Which nationality is associated with Temple?
SELECT nationality FROM table_name_72 WHERE school_country = "temple"
SELECT "nationality" FROM "table_name_72" WHERE "school_country" = "temple"
0.073242
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 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) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
how many patients whose admission type is emergency and ethnicity is american indian/alaska native?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.ethnicity = "AMERICAN INDIAN/ALASKA NATIVE"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "AMERICAN INDIAN/ALASKA NATIVE" = "demographic"."ethnicity" AND "EMERGENCY" = "demographic"."admission_type"
0.178711
CREATE TABLE PRODUCTS (Product_Name VARCHAR2, Product_Price NUMBER)
Show all the distinct product names with price higher than the average.
SELECT DISTINCT Product_Name FROM PRODUCTS WHERE Product_Price > (SELECT AVG(Product_Price) FROM PRODUCTS)
SELECT DISTINCT "Product_Name" FROM "PRODUCTS" WHERE "Product_Price" > (SELECT AVG("Product_Price") FROM "PRODUCTS")
0.113281
CREATE TABLE table_75279 ("Date" CLOB, "Visitor" CLOB, "Score" CLOB, "Home" CLOB, "Record" CLOB)
Which Home has a Date of april 1?
SELECT "Home" FROM table_75279 WHERE "Date" = 'april 1'
SELECT "Home" FROM "table_75279" WHERE "Date" = 'april 1'
0.055664
CREATE TABLE table_13259009_2 (record VARCHAR2, opponent VARCHAR2)
What was the record when they played the Los Angeles Rams?
SELECT record FROM table_13259009_2 WHERE opponent = "Los Angeles Rams"
SELECT "record" FROM "table_13259009_2" WHERE "Los Angeles Rams" = "opponent"
0.075195