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 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 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 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 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 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 cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER)
until 1 year ago, what was the top four most frequent medicines prescribed to patients within the same month after having been diagnosed with dementia?
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'dementia' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE DATETIME(medication.drugstarttime) <= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.drugstarttime AND DATETIME(t1.diagnosistime, 'start of month') = DATETIME(t2.drugstarttime, 'start of month') GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 4
WITH "t2" AS (SELECT "patient"."uniquepid", "medication"."drugname", "medication"."drugstarttime" FROM "medication" JOIN "patient" ON "medication"."patientunitstayid" = "patient"."patientunitstayid" WHERE DATETIME("medication"."drugstarttime") <= DATETIME(CURRENT_TIME(), '-1 year')), "t3" AS (SELECT "t2"."drugname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS "c1" FROM "diagnosis" JOIN "patient" ON "diagnosis"."patientunitstayid" = "patient"."patientunitstayid" JOIN "t2" "t2" ON "diagnosis"."diagnosistime" < "t2"."drugstarttime" AND "patient"."uniquepid" = "t2"."uniquepid" AND DATETIME("diagnosis"."diagnosistime", 'start of month') = DATETIME("t2"."drugstarttime", 'start of month') WHERE "diagnosis"."diagnosisname" = 'dementia' AND DATETIME("diagnosis"."diagnosistime") <= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY "t2"."drugname") SELECT "t3"."drugname" FROM "t3" "t3" WHERE "t3"."c1" <= 4
0.883789
CREATE TABLE table_name_64 (displacement VARCHAR2, model VARCHAR2)
What is the displacement for the petrol engines model?
SELECT displacement FROM table_name_64 WHERE model = "petrol engines"
SELECT "displacement" FROM "table_name_64" WHERE "model" = "petrol engines"
0.073242
CREATE TABLE table_12962773_10 (position VARCHAR2, current_club VARCHAR2)
How many players currently play for Barons Riga?
SELECT COUNT(position) FROM table_12962773_10 WHERE current_club = "Barons Riga"
SELECT COUNT("position") FROM "table_12962773_10" WHERE "Barons Riga" = "current_club"
0.083984
CREATE TABLE Student (advisor VARCHAR2) CREATE TABLE Faculty (FacID VARCHAR2)
Show the faculty id of each faculty member, along with the number of students he or she advises.
SELECT T1.FacID, COUNT(*) FROM Faculty AS T1 JOIN Student AS T2 ON T1.FacID = T2.advisor GROUP BY T1.FacID
SELECT "T1"."FacID", COUNT(*) FROM "Faculty" "T1" JOIN "Student" "T2" ON "T1"."FacID" = "T2"."advisor" GROUP BY "T1"."FacID"
0.121094
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 TagSynonyms (Id NUMBER, SourceTagName CLOB, TargetTagName CLOB, CreationDate TIME, OwnerUserId NUMBER, AutoRenameCount NUMBER, LastAutoRename TIME, Score NUMBER, ApprovedByUserId NUMBER, ApprovalDate TIME) CREATE TABLE FlagTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) 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 Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) CREATE TABLE ReviewTaskTypes (Id NUMBER, Name CLOB, Description CLOB) 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 PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate 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 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 SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange NUMBER) CREATE TABLE ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE PostTags (PostId NUMBER, TagId 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 Votes (Id NUMBER, PostId NUMBER, VoteTypeId NUMBER, UserId NUMBER, CreationDate TIME, BountyAmount 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 VoteTypes (Id NUMBER, Name CLOB) CREATE TABLE PostTypes (Id NUMBER, Name CLOB) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId 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 ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE PostHistoryTypes (Id NUMBER, Name CLOB) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER)
points towards a specific user's specific tag.
SELECT t.TagName, SUM(a.Score) AS "sumscor", COUNT(a.Id) AS "#answers" FROM Posts AS a, Tags AS t JOIN Posts AS q ON a.ParentId = q.Id WHERE a.OwnerUserId = '##UserID##' AND a.PostTypeId = 2 AND a.DeletionDate IS NULL AND a.ClosedDate IS NULL AND q.DeletionDate IS NULL AND q.ClosedDate IS NULL AND a.CommunityOwnedDate IS NULL AND q.CommunityOwnedDate IS NULL AND q.Tags LIKE '%<' + t.TagName + '>%' GROUP BY t.TagName
SELECT "t"."TagName", SUM("a"."Score") AS "sumscor", COUNT("a"."Id") AS "#answers" FROM "Posts" "a" JOIN "Posts" "q" ON "a"."ParentId" = "q"."Id" AND "q"."ClosedDate" IS NULL AND "q"."CommunityOwnedDate" IS NULL AND "q"."DeletionDate" IS NULL JOIN "Tags" "t" ON "q"."Tags" LIKE '%<' + "t"."TagName" + '>%' WHERE "a"."ClosedDate" IS NULL AND "a"."CommunityOwnedDate" IS NULL AND "a"."DeletionDate" IS NULL AND "a"."OwnerUserId" = '##UserID##' AND "a"."PostTypeId" = 2 GROUP BY "t"."TagName"
0.477539
CREATE TABLE table_17562 ("Stage" CLOB, "Winner" CLOB, "General classification" CLOB, "Points classification" CLOB, "Mountains classification" CLOB, "Young rider classification" CLOB, "Intergiro classification" CLOB, "Trofeo Fast Team" CLOB)
How many leaders are there in the intergiro classification in stage 20?
SELECT COUNT("Intergiro classification") FROM table_17562 WHERE "Stage" = '20'
SELECT COUNT("Intergiro classification") FROM "table_17562" WHERE "Stage" = '20'
0.078125
CREATE TABLE lab (labid NUMBER, patientunitstayid NUMBER, labname CLOB, labresult NUMBER, labresulttime 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 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 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 cost (costid NUMBER, uniquepid CLOB, patienthealthsystemstayid NUMBER, eventtype CLOB, eventid NUMBER, chargetime TIME, cost NUMBER) 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)
what are the three most commonly prescribed medications for patients for whom albumin human 25% is also prescribed at the same time, since 2103?
SELECT t3.drugname FROM (SELECT t2.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'albumin human 25%' AND STRFTIME('%y', medication.drugstarttime) >= '2103') AS t1 JOIN (SELECT patient.uniquepid, medication.drugname, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', medication.drugstarttime) >= '2103') AS t2 ON t1.uniquepid = t2.uniquepid WHERE DATETIME(t1.drugstarttime) = DATETIME(t2.drugstarttime) GROUP BY t2.drugname) AS t3 WHERE t3.c1 <= 3
WITH "t2" AS (SELECT "patient"."uniquepid", "medication"."drugname", "medication"."drugstarttime" FROM "medication" JOIN "patient" ON "medication"."patientunitstayid" = "patient"."patientunitstayid" WHERE STRFTIME('%y', "medication"."drugstarttime") >= '2103'), "t3" AS (SELECT "t2"."drugname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS "c1" FROM "medication" JOIN "patient" ON "medication"."patientunitstayid" = "patient"."patientunitstayid" JOIN "t2" "t2" ON "patient"."uniquepid" = "t2"."uniquepid" AND DATETIME("medication"."drugstarttime") = DATETIME("t2"."drugstarttime") WHERE "medication"."drugname" = 'albumin human 25%' AND STRFTIME('%y', "medication"."drugstarttime") >= '2103' GROUP BY "t2"."drugname") SELECT "t3"."drugname" FROM "t3" "t3" WHERE "t3"."c1" <= 3
0.758789
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) 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)
what is the number of patients with the diagnosis of osteoarthros nos-unspec who were admitted before 2137?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admityear < "2137" AND diagnoses.short_title = "Osteoarthros NOS-unspec"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Osteoarthros NOS-unspec" = "diagnoses"."short_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "2137" > "demographic"."admityear"
0.229492
CREATE TABLE table_203_803 (id NUMBER, "draw" NUMBER, "country" CLOB, "language" CLOB, "artist" CLOB, "song" CLOB, "english translation" CLOB, "place" NUMBER, "points" NUMBER)
what artist scored the least number of points ?
SELECT "artist" FROM table_203_803 ORDER BY "points" LIMIT 1
SELECT "artist" FROM "table_203_803" ORDER BY "points" FETCH FIRST 1 ROWS ONLY
0.076172
CREATE TABLE table_18127 ("District" CLOB, "Incumbent" CLOB, "Party" CLOB, "First elected" FLOAT, "Results" CLOB, "Candidates" CLOB)
How many parties is the incumbent Bob Brady a member of?
SELECT COUNT("Party") FROM table_18127 WHERE "Incumbent" = 'Bob Brady'
SELECT COUNT("Party") FROM "table_18127" WHERE "Incumbent" = 'Bob Brady'
0.070313
CREATE TABLE table_26986076_1 (sat_21_aug VARCHAR2, wed_25_aug VARCHAR2)
If Wed Aug 25 is no time, what is Sat aug 21?
SELECT sat_21_aug FROM table_26986076_1 WHERE wed_25_aug = "—— No Time"
SELECT "sat_21_aug" FROM "table_26986076_1" WHERE "wed_25_aug" = "—— No Time"
0.075195
CREATE TABLE table_15346009_1 (date VARCHAR2, location VARCHAR2)
On what day was the tournament in Alabama?
SELECT date FROM table_15346009_1 WHERE location = "Alabama"
SELECT "date" FROM "table_15346009_1" WHERE "Alabama" = "location"
0.064453
CREATE TABLE table_23466021_4 (opponent VARCHAR2, attendance VARCHAR2)
Which opponent has 32194 as the attendance?
SELECT opponent FROM table_23466021_4 WHERE attendance = 32194
SELECT "opponent" FROM "table_23466021_4" WHERE "attendance" = 32194
0.066406
CREATE TABLE outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE d_labitems (row_id NUMBER, itemid NUMBER, label 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 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 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 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 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 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 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 microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name CLOB) CREATE TABLE d_icd_diagnoses (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)
have patient 23070 received lab tests in this month?
SELECT COUNT(*) > 0 FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 23070) AND DATETIME(labevents.charttime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 23070 GROUP BY "hadm_id") SELECT COUNT(*) > 0 FROM "labevents" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "labevents"."hadm_id" WHERE DATETIME("labevents"."charttime", 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND NOT "_u_0"."" IS NULL
0.353516
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 NUMBER, lastname CLOB, firstname CLOB, adults NUMBER, kids NUMBER)
How many different types of beds are there?
SELECT COUNT(DISTINCT bedtype) FROM rooms
SELECT COUNT(DISTINCT "bedtype") FROM "rooms"
0.043945
CREATE TABLE table_66591 ("Title" CLOB, "Label" CLOB, "Year of Release" FLOAT, "Country of Release" CLOB, "Peaches:" CLOB)
What was the last year MCA had a Release?
SELECT MAX("Year of Release") FROM table_66591 WHERE "Label" = 'mca'
SELECT MAX("Year of Release") FROM "table_66591" WHERE "Label" = 'mca'
0.068359
CREATE TABLE table_69365 ("Outcome" CLOB, "Year" FLOAT, "Tournament" CLOB, "Opponent" CLOB, "Score" CLOB)
What was the outcome of the match against Nguyen Tien Minh in the Bulgaria Open?
SELECT "Outcome" FROM table_69365 WHERE "Opponent" = 'nguyen tien minh' AND "Tournament" = 'bulgaria open'
SELECT "Outcome" FROM "table_69365" WHERE "Opponent" = 'nguyen tien minh' AND "Tournament" = 'bulgaria open'
0.105469
CREATE TABLE table_name_67 (election NUMBER, outcome_of_election VARCHAR2, seats VARCHAR2)
What is the earliest election with 2 seats and the outcome of the election of minority in parliament?
SELECT MIN(election) FROM table_name_67 WHERE outcome_of_election = "minority in parliament" AND seats = "2"
SELECT MIN("election") FROM "table_name_67" WHERE "2" = "seats" AND "minority in parliament" = "outcome_of_election"
0.113281
CREATE TABLE table_36449 ("Building" CLOB, "Height [m]" FLOAT, "Floors" FLOAT, "Built" FLOAT, "City" CLOB, "Architect" CLOB)
Who was the architect that built the Electric Railway Chambers before 1915?
SELECT "Architect" FROM table_36449 WHERE "Built" < '1915' AND "Building" = 'electric railway chambers'
SELECT "Architect" FROM "table_36449" WHERE "Building" = 'electric railway chambers' AND "Built" < '1915'
0.102539
CREATE TABLE storm (Storm_ID NUMBER, Name CLOB, Dates_active CLOB, Max_speed NUMBER, Damage_millions_USD FLOAT, Number_Deaths NUMBER) CREATE TABLE region (Region_id NUMBER, Region_code CLOB, Region_name CLOB) CREATE TABLE affected_region (Region_id NUMBER, Storm_ID NUMBER, Number_city_affected FLOAT)
Show me a bar chart for how many storms occured in each region?, and order total number from high to low order.
SELECT Region_name, COUNT(*) FROM region AS T1 JOIN affected_region AS T2 ON T1.Region_id = T2.Region_id GROUP BY T1.Region_id ORDER BY COUNT(*) DESC
SELECT "Region_name", COUNT(*) FROM "region" "T1" JOIN "affected_region" "T2" ON "T1"."Region_id" = "T2"."Region_id" GROUP BY "T1"."Region_id" ORDER BY COUNT(*) DESC
0.161133
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 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 average age of patients whose insurance is private and days of hospital stay is 7?
SELECT AVG(demographic.age) FROM demographic WHERE demographic.insurance = "Private" AND demographic.days_stay = "7"
SELECT AVG("demographic"."age") FROM "demographic" WHERE "7" = "demographic"."days_stay" AND "Private" = "demographic"."insurance"
0.126953
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) CREATE TABLE procedures (subject_id CLOB, hadm_id CLOB, icd9_code CLOB, short_title CLOB, long_title CLOB)
count the number of patients whose drug route is td?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE prescriptions.route = "TD"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "TD" = "prescriptions"."route" AND "demographic"."hadm_id" = "prescriptions"."hadm_id"
0.174805
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 labevents (row_id NUMBER, subject_id NUMBER, hadm_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 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 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 outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value 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 chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, itemid NUMBER, charttime TIME, valuenum NUMBER, valueuom CLOB) 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 patients (row_id NUMBER, subject_id NUMBER, gender CLOB, dob TIME, dod TIME) 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 d_icd_diagnoses (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB)
compared to last measured on the current hospital visit, was the phosphate value of patient 73713 less than the value first measured on the current hospital visit?
SELECT (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') ORDER BY labevents.charttime DESC LIMIT 1) < (SELECT labevents.valuenum FROM labevents WHERE labevents.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 73713 AND admissions.dischtime IS NULL) AND labevents.itemid IN (SELECT d_labitems.itemid FROM d_labitems WHERE d_labitems.label = 'phosphate') ORDER BY labevents.charttime LIMIT 1)
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."dischtime" IS NULL AND "admissions"."subject_id" = 73713 GROUP BY "hadm_id"), "_u_1" AS (SELECT "d_labitems"."itemid" FROM "d_labitems" WHERE "d_labitems"."label" = 'phosphate' GROUP BY "itemid") SELECT (SELECT "labevents"."valuenum" FROM "labevents" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "labevents"."hadm_id" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "labevents"."itemid" WHERE NOT "_u_0"."" IS NULL AND NOT "_u_1"."" IS NULL ORDER BY "labevents"."charttime" DESC FETCH FIRST 1 ROWS ONLY) < (SELECT "labevents"."valuenum" FROM "labevents" LEFT JOIN "_u_0" "_u_3" ON "_u_3"."" = "labevents"."hadm_id" LEFT JOIN "_u_1" "_u_4" ON "_u_4"."" = "labevents"."itemid" WHERE NOT "_u_3"."" IS NULL AND NOT "_u_4"."" IS NULL ORDER BY "labevents"."charttime" FETCH FIRST 1 ROWS ONLY)
0.834961
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 ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE PostTags (PostId NUMBER, TagId NUMBER) CREATE TABLE PostNoticeTypes (Id NUMBER, ClassId NUMBER, Name CLOB, Body CLOB, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId NUMBER) CREATE TABLE PendingFlags (Id NUMBER, FlagTypeId NUMBER, PostId NUMBER, CreationDate TIME, CloseReasonTypeId NUMBER, CloseAsOffTopicReasonTypeId NUMBER, DuplicateOfQuestionId NUMBER, BelongsOnBaseHostAddress 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 Comments (Id NUMBER, PostId NUMBER, Score NUMBER, Text CLOB, CreationDate TIME, UserDisplayName CLOB, UserId NUMBER, ContentLicense CLOB) CREATE TABLE FlagTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE Votes (Id NUMBER, PostId NUMBER, VoteTypeId NUMBER, UserId NUMBER, CreationDate TIME, BountyAmount NUMBER) CREATE TABLE CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) 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 PostNotices (Id NUMBER, PostId NUMBER, PostNoticeTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body CLOB, OwnerUserId NUMBER, DeletionUserId NUMBER) CREATE TABLE ReviewTaskTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE ReviewRejectionReasons (Id NUMBER, Name CLOB, Description CLOB, PostTypeId NUMBER) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) CREATE TABLE PostHistoryTypes (Id NUMBER, Name CLOB) CREATE TABLE PostTypes (Id NUMBER, Name 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 Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) 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 ReviewTaskResultTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange NUMBER) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId NUMBER) CREATE TABLE VoteTypes (Id NUMBER, Name CLOB) CREATE TABLE PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate TIME) 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 SuggestedEdits (Id NUMBER, PostId NUMBER, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId NUMBER, Comment CLOB, Text CLOB, Title CLOB, Tags CLOB, RevisionGUID other)
Closed Questions Count by Month.
SELECT date1, COUNT(Id) AS cnt FROM (SELECT TIME_TO_STR(d.CreationDate, '%y-%m') AS "date1", (d.Id) AS id FROM Posts AS d LEFT JOIN PostHistory AS ph ON ph.PostId = d.Id LEFT JOIN PostLinks AS pl ON pl.PostId = d.Id LEFT JOIN Posts AS o ON o.Id = pl.RelatedPostId WHERE d.PostTypeId = 1 AND ph.PostHistoryTypeId = 10) AS t1 GROUP BY date1 ORDER BY date1
SELECT "date1", COUNT("Id") AS "cnt" FROM "Posts" "d" LEFT JOIN "PostHistory" "ph" ON "d"."Id" = "ph"."PostId" LEFT JOIN "PostLinks" "pl" ON "d"."Id" = "pl"."PostId" LEFT JOIN "Posts" "o" ON "o"."Id" = "pl"."RelatedPostId" WHERE "d"."PostTypeId" = 1 AND "ph"."PostHistoryTypeId" = 10 GROUP BY "date1" ORDER BY "date1"
0.30957
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)
How many of the patients belonging to white - russian ethnic origin were born before the year 1850?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.ethnicity = "WHITE - RUSSIAN" AND demographic.dob_year < "1850"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "1850" > "demographic"."dob_year" AND "WHITE - RUSSIAN" = "demographic"."ethnicity"
0.154297
CREATE TABLE table_29453 ("University" CLOB, "Varsity Name" CLOB, "City" CLOB, "Province" CLOB, "Founded" FLOAT, "Soccer Stadium" CLOB, "Stadium Capacity" FLOAT)
What is the soccer stadium with the varsity name is citadins?
SELECT "Soccer Stadium" FROM table_29453 WHERE "Varsity Name" = 'Citadins'
SELECT "Soccer Stadium" FROM "table_29453" WHERE "Varsity Name" = 'Citadins'
0.074219
CREATE TABLE locations (LOCATION_ID NUMBER, STREET_ADDRESS VARCHAR2, POSTAL_CODE VARCHAR2, CITY VARCHAR2, STATE_PROVINCE VARCHAR2, COUNTRY_ID VARCHAR2) 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 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 countries (COUNTRY_ID VARCHAR2, COUNTRY_NAME VARCHAR2, REGION_ID NUMBER) CREATE TABLE regions (REGION_ID NUMBER, REGION_NAME VARCHAR2)
For those employees who was hired before 2002-06-21, show me the trend about department_id over hire_date with a line chart, rank from high to low by the X-axis.
SELECT HIRE_DATE, DEPARTMENT_ID FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY HIRE_DATE DESC
SELECT "HIRE_DATE", "DEPARTMENT_ID" FROM "employees" WHERE "HIRE_DATE" < '2002-06-21' ORDER BY "HIRE_DATE" DESC
0.108398
CREATE TABLE table_66896 ("Year" CLOB, "Superintendent" CLOB, "Glendale Principal" CLOB, "H.H. Principal" CLOB, "Maplemere Principal" CLOB, "W.R. Principal" CLOB, "M.S. Principal" CLOB, "H.S. Principal" CLOB, "H. S. Asst. Principal" CLOB)
Who is the Glendale principal with Greg Smorel as m.s. principal and Joleen Reinholz as H.S. principal during 2006-2007?
SELECT "Glendale Principal" FROM table_66896 WHERE "M.S. Principal" = 'greg smorel' AND "H.S. Principal" = 'joleen reinholz' AND "Year" = '2006-2007'
SELECT "Glendale Principal" FROM "table_66896" WHERE "H.S. Principal" = 'joleen reinholz' AND "M.S. Principal" = 'greg smorel' AND "Year" = '2006-2007'
0.147461
CREATE TABLE table_name_55 (height__ft_ NUMBER, name VARCHAR2, floors VARCHAR2)
what is the lowest height (ft) for messeturm and more than 55 floors?
SELECT MIN(height__ft_) FROM table_name_55 WHERE name = "messeturm" AND floors > 55
SELECT MIN("height__ft_") FROM "table_name_55" WHERE "floors" > 55 AND "messeturm" = "name"
0.088867
CREATE TABLE table_name_15 (bronze NUMBER, rank VARCHAR2, silver VARCHAR2)
What was the highest number of bronze medals for the entry with rank 2 and fewer than 3 silver medals?
SELECT MAX(bronze) FROM table_name_15 WHERE rank = "2" AND silver < 3
SELECT MAX("bronze") FROM "table_name_15" WHERE "2" = "rank" AND "silver" < 3
0.075195
CREATE TABLE electoral_register (electoral_register_id NUMBER, cmi_cross_ref_id NUMBER) CREATE TABLE benefits_overpayments (council_tax_id NUMBER, cmi_cross_ref_id NUMBER) CREATE TABLE cmi_cross_references (cmi_cross_ref_id NUMBER, master_customer_id NUMBER, source_system_code CLOB) CREATE TABLE parking_fines (council_tax_id NUMBER, cmi_cross_ref_id NUMBER) CREATE TABLE council_tax (council_tax_id NUMBER, cmi_cross_ref_id NUMBER) CREATE TABLE rent_arrears (council_tax_id NUMBER, cmi_cross_ref_id NUMBER) CREATE TABLE customer_master_index (master_customer_id NUMBER, cmi_details CLOB) CREATE TABLE business_rates (business_rates_id NUMBER, cmi_cross_ref_id NUMBER)
List all information about customer master index, and sort them by details in descending order.
SELECT * FROM customer_master_index ORDER BY cmi_details DESC
SELECT * FROM "customer_master_index" ORDER BY "cmi_details" DESC
0.063477
CREATE TABLE Part_Faults (part_fault_id NUMBER, part_id NUMBER, fault_short_name VARCHAR2, fault_description VARCHAR2, other_fault_details VARCHAR2) CREATE TABLE Parts (part_id NUMBER, part_name VARCHAR2, chargeable_yn VARCHAR2, chargeable_amount VARCHAR2, other_part_details VARCHAR2) CREATE TABLE Third_Party_Companies (company_id NUMBER, company_type VARCHAR2, company_name VARCHAR2, company_address VARCHAR2, other_company_details VARCHAR2) CREATE TABLE Engineer_Skills (engineer_id NUMBER, skill_id NUMBER) CREATE TABLE Skills (skill_id NUMBER, skill_code VARCHAR2, skill_description VARCHAR2) CREATE TABLE Assets (asset_id NUMBER, maintenance_contract_id NUMBER, supplier_company_id NUMBER, asset_details VARCHAR2, asset_make VARCHAR2, asset_model VARCHAR2, asset_acquired_date DATETIME, asset_disposed_date DATETIME, other_asset_details VARCHAR2) CREATE TABLE Staff (staff_id NUMBER, staff_name VARCHAR2, gender VARCHAR2, other_staff_details VARCHAR2) CREATE TABLE Asset_Parts (asset_id NUMBER, part_id NUMBER) CREATE TABLE Skills_Required_To_Fix (part_fault_id NUMBER, skill_id NUMBER) CREATE TABLE Fault_Log (fault_log_entry_id NUMBER, asset_id NUMBER, recorded_by_staff_id NUMBER, fault_log_entry_datetime DATETIME, fault_description VARCHAR2, other_fault_details VARCHAR2) CREATE TABLE Fault_Log_Parts (fault_log_entry_id NUMBER, part_fault_id NUMBER, fault_status VARCHAR2) CREATE TABLE Maintenance_Engineers (engineer_id NUMBER, company_id NUMBER, first_name VARCHAR2, last_name VARCHAR2, other_details VARCHAR2) CREATE TABLE Engineer_Visits (engineer_visit_id NUMBER, contact_staff_id NUMBER, engineer_id NUMBER, fault_log_entry_id NUMBER, fault_status VARCHAR2, visit_start_datetime DATETIME, visit_end_datetime DATETIME, other_visit_details VARCHAR2) CREATE TABLE Maintenance_Contracts (maintenance_contract_id NUMBER, maintenance_contract_company_id NUMBER, contract_start_date DATETIME, contract_end_date DATETIME, other_contract_details VARCHAR2)
Bar graph to show how many asset make from different asset make, order by the X-axis in desc.
SELECT asset_make, COUNT(asset_make) FROM Assets GROUP BY asset_make ORDER BY asset_make DESC
SELECT "asset_make", COUNT("asset_make") FROM "Assets" GROUP BY "asset_make" ORDER BY "asset_make" DESC
0.100586
CREATE TABLE table_name_52 (draw NUMBER, points NUMBER)
Which average draw has points greater than 12?
SELECT AVG(draw) FROM table_name_52 WHERE points > 12
SELECT AVG("draw") FROM "table_name_52" WHERE "points" > 12
0.057617
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 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 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 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 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)
when was the last time patient 021-32860 received a glucose - juice or other oral glucose administration procedure?
SELECT treatment.treatmenttime FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '021-32860')) AND treatment.treatmentname = 'glucose - juice or other oral glucose administration' ORDER BY treatment.treatmenttime DESC LIMIT 1
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '021-32860' 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 "treatment"."treatmenttime" FROM "treatment" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "treatment"."patientunitstayid" WHERE "treatment"."treatmentname" = 'glucose - juice or other oral glucose administration' AND NOT "_u_1"."" IS NULL ORDER BY "treatment"."treatmenttime" DESC FETCH FIRST 1 ROWS ONLY
0.644531
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 diagnosis (diagnosisid NUMBER, patientunitstayid NUMBER, diagnosisname CLOB, diagnosistime TIME, icd9code CLOB) 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 treatment (treatmentid NUMBER, patientunitstayid NUMBER, treatmentname CLOB, treatmenttime TIME) CREATE TABLE allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime 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 microlab (microlabid NUMBER, patientunitstayid NUMBER, culturesite CLOB, organism CLOB, culturetakentime TIME)
what are the five most frequently prescribed drugs for patients 30s in the previous year?
SELECT t1.drugname FROM (SELECT medication.drugname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM medication WHERE medication.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 30 AND 39) AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') GROUP BY medication.drugname) AS t1 WHERE t1.c1 <= 5
WITH "_u_0" AS (SELECT "patient"."patientunitstayid" FROM "patient" WHERE "patient"."age" <= 39 AND "patient"."age" >= 30 GROUP BY "patientunitstayid"), "t1" AS (SELECT "medication"."drugname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS "c1" FROM "medication" LEFT JOIN "_u_0" "_u_0" ON "_u_0"."" = "medication"."patientunitstayid" WHERE DATETIME("medication"."drugstarttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND NOT "_u_0"."" IS NULL GROUP BY "medication"."drugname") SELECT "t1"."drugname" FROM "t1" "t1" WHERE "t1"."c1" <= 5
0.556641
CREATE TABLE Timed_Status_of_Things (thing_id NUMBER, Date_and_Date DATETIME, Status_of_Thing_Code CHAR) CREATE TABLE Services (service_id NUMBER, organization_id NUMBER, service_type_code CHAR, service_details VARCHAR2) CREATE TABLE Customers (customer_id NUMBER, customer_details VARCHAR2) CREATE TABLE Properties (property_id NUMBER, property_type_code CHAR, property_address VARCHAR2, other_details VARCHAR2) CREATE TABLE Residents (resident_id NUMBER, property_id NUMBER, date_moved_in DATETIME, date_moved_out DATETIME, other_details VARCHAR2) CREATE TABLE Customer_Events (Customer_Event_ID NUMBER, customer_id NUMBER, date_moved_in DATETIME, property_id NUMBER, resident_id NUMBER, thing_id NUMBER) CREATE TABLE Customer_Event_Notes (Customer_Event_Note_ID NUMBER, Customer_Event_ID NUMBER, service_type_code CHAR, resident_id NUMBER, property_id NUMBER, date_moved_in DATETIME) CREATE TABLE Timed_Locations_of_Things (thing_id NUMBER, Date_and_Time DATETIME, Location_Code CHAR) CREATE TABLE Residents_Services (resident_id NUMBER, service_id NUMBER, date_moved_in DATETIME, property_id NUMBER, date_requested DATETIME, date_provided DATETIME, other_details VARCHAR2) CREATE TABLE Things (thing_id NUMBER, organization_id NUMBER, Type_of_Thing_Code CHAR, service_type_code CHAR, service_details VARCHAR2) CREATE TABLE Organizations (organization_id NUMBER, parent_organization_id NUMBER, organization_details VARCHAR2)
What is the proportion of each customer's move in date? Show me the bar chart.
SELECT date_moved_in, COUNT(date_moved_in) FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id = T2.customer_id GROUP BY date_moved_in
SELECT "date_moved_in", COUNT("date_moved_in") FROM "Customers" "T1" JOIN "Customer_Events" "T2" ON "T1"."customer_id" = "T2"."customer_id" GROUP BY "date_moved_in"
0.160156
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 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)
give me the number of patients whose death status is 1 and primary disease is pituitary bleed?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.expire_flag = "1" AND demographic.diagnosis = "PITUITARY BLEED"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "1" = "demographic"."expire_flag" AND "PITUITARY BLEED" = "demographic"."diagnosis"
0.154297
CREATE TABLE table_25438110_5 (casinos VARCHAR2, fy09_$millions VARCHAR2)
How many casinos are associated with a FY2009 $mil value of exactly $279?
SELECT COUNT(casinos) FROM table_25438110_5 WHERE fy09_$millions = "$279"
SELECT COUNT("casinos") FROM "table_25438110_5" WHERE "$279" = "fy09_$millions"
0.077148
CREATE TABLE dual_carrier (main_airline VARCHAR2, low_flight_number NUMBER, high_flight_number NUMBER, dual_airline VARCHAR2, service_name CLOB) CREATE TABLE code_description (code VARCHAR2, description 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 days (days_code VARCHAR2, day_name VARCHAR2) CREATE TABLE flight_fare (flight_id NUMBER, fare_id NUMBER) CREATE TABLE month (month_number NUMBER, month_name CLOB) CREATE TABLE city (city_code VARCHAR2, city_name VARCHAR2, state_code VARCHAR2, country_name VARCHAR2, time_zone_code VARCHAR2) CREATE TABLE equipment_sequence (aircraft_code_sequence VARCHAR2, aircraft_code VARCHAR2) CREATE TABLE time_zone (time_zone_code CLOB, time_zone_name CLOB, hours_from_gmt NUMBER) CREATE TABLE flight_leg (flight_id NUMBER, leg_number NUMBER, leg_flight 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 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 date_day (month_number NUMBER, day_number NUMBER, year NUMBER, day_name VARCHAR2) CREATE TABLE airline (airline_code VARCHAR2, airline_name CLOB, note CLOB) CREATE TABLE class_of_service (booking_class VARCHAR2, rank NUMBER, class_description CLOB) CREATE TABLE time_interval (period CLOB, begin_time NUMBER, end_time NUMBER) CREATE TABLE compartment_class (compartment VARCHAR2, class_type 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 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 airport_service (city_code VARCHAR2, airport_code VARCHAR2, miles_distant NUMBER, direction VARCHAR2, minutes_distant NUMBER) CREATE TABLE state (state_code CLOB, state_name CLOB, country_name 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 food_service (meal_code CLOB, meal_number NUMBER, compartment CLOB, meal_description VARCHAR2)
what are connecting flights from CHICAGO into SEATTLE on 6 5
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 ((CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'SEATTLE' AND date_day.day_number = 5 AND date_day.month_number = 6 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'CHICAGO' AND flight.from_airport = AIRPORT_SERVICE_0.airport_code) AND flight.connections > 0
SELECT DISTINCT "flight"."flight_id" FROM "airport_service" "AIRPORT_SERVICE_0" JOIN "date_day" ON "date_day"."day_number" = 5 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" = 'CHICAGO' 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"."connections" > 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" = 'SEATTLE'
0.722656
CREATE TABLE table_name_75 (outcome VARCHAR2, score VARCHAR2)
What is the Outcome of the match with a Score of 6 3, 6 4?
SELECT outcome FROM table_name_75 WHERE score = "6–3, 6–4"
SELECT "outcome" FROM "table_name_75" WHERE "6–3, 6–4" = "score"
0.0625
CREATE TABLE date_day (month_number NUMBER, day_number NUMBER, year NUMBER, day_name VARCHAR2) CREATE TABLE time_interval (period CLOB, begin_time NUMBER, end_time NUMBER) CREATE TABLE flight_leg (flight_id NUMBER, leg_number NUMBER, leg_flight NUMBER) CREATE TABLE days (days_code VARCHAR2, day_name VARCHAR2) CREATE TABLE equipment_sequence (aircraft_code_sequence VARCHAR2, aircraft_code 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 ground_service (city_code CLOB, airport_code CLOB, transport_type CLOB, ground_fare NUMBER) CREATE TABLE city (city_code VARCHAR2, city_name VARCHAR2, state_code VARCHAR2, country_name VARCHAR2, time_zone_code VARCHAR2) 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 food_service (meal_code CLOB, meal_number NUMBER, compartment CLOB, meal_description VARCHAR2) CREATE TABLE flight_fare (flight_id NUMBER, fare_id 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 compartment_class (compartment VARCHAR2, class_type VARCHAR2) CREATE TABLE airport_service (city_code VARCHAR2, airport_code VARCHAR2, miles_distant NUMBER, direction VARCHAR2, minutes_distant NUMBER) CREATE TABLE time_zone (time_zone_code CLOB, time_zone_name CLOB, hours_from_gmt NUMBER) CREATE TABLE month (month_number NUMBER, month_name CLOB) CREATE TABLE dual_carrier (main_airline VARCHAR2, low_flight_number NUMBER, high_flight_number NUMBER, dual_airline VARCHAR2, service_name CLOB) CREATE TABLE code_description (code VARCHAR2, description 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 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 class_of_service (booking_class VARCHAR2, rank NUMBER, class_description CLOB) CREATE TABLE state (state_code CLOB, state_name CLOB, country_name 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 airline (airline_code VARCHAR2, airline_name CLOB, note CLOB) 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)
show me all flights from PITTSBURGH to BALTIMORE tomorrow
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 (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'BALTIMORE' AND date_day.day_number = 20 AND date_day.month_number = 1 AND date_day.year = 1991 AND days.day_name = date_day.day_name AND flight.flight_days = days.days_code AND flight.to_airport = AIRPORT_SERVICE_1.airport_code) AND CITY_0.city_code = AIRPORT_SERVICE_0.city_code AND CITY_0.city_name = 'PITTSBURGH' 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" = 20 AND "date_day"."month_number" = 1 AND "date_day"."year" = 1991 JOIN "city" "CITY_0" ON "AIRPORT_SERVICE_0"."city_code" = "CITY_0"."city_code" AND "CITY_0"."city_name" = 'PITTSBURGH' 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" 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.698242
CREATE TABLE table_11403 ("Game" FLOAT, "Date" CLOB, "Score" CLOB, "Location" CLOB, "Time" CLOB, "Attendance" FLOAT)
what is the attendance when the location is veterans stadium, the game is more than 3 and the time is 2:21?
SELECT AVG("Attendance") FROM table_11403 WHERE "Location" = 'veterans stadium' AND "Game" > '3' AND "Time" = '2:21'
SELECT AVG("Attendance") FROM "table_11403" WHERE "Game" > '3' AND "Location" = 'veterans stadium' AND "Time" = '2:21'
0.115234
CREATE TABLE course_prerequisite (pre_course_id NUMBER, course_id NUMBER) CREATE TABLE semester (semester_id NUMBER, semester VARCHAR2, year NUMBER) CREATE TABLE course (course_id NUMBER, name VARCHAR2, department VARCHAR2, number VARCHAR2, credits VARCHAR2, advisory_requirement VARCHAR2, enforced_requirement VARCHAR2, description VARCHAR2, num_semesters NUMBER, num_enrolled NUMBER, has_discussion VARCHAR2, has_lab VARCHAR2, has_projects VARCHAR2, has_exams VARCHAR2, num_reviews NUMBER, clarity_score NUMBER, easiness_score NUMBER, helpfulness_score NUMBER) CREATE TABLE offering_instructor (offering_instructor_id NUMBER, offering_id NUMBER, instructor_id NUMBER) CREATE TABLE program (program_id NUMBER, name VARCHAR2, college VARCHAR2, introduction VARCHAR2) CREATE TABLE course_offering (offering_id NUMBER, course_id NUMBER, semester NUMBER, section_number NUMBER, start_time TIME, end_time TIME, monday VARCHAR2, tuesday VARCHAR2, wednesday VARCHAR2, thursday VARCHAR2, friday VARCHAR2, saturday VARCHAR2, sunday VARCHAR2, has_final_project VARCHAR2, has_final_exam VARCHAR2, textbook VARCHAR2, class_address VARCHAR2, allow_audit VARCHAR2) CREATE TABLE comment_instructor (instructor_id NUMBER, student_id NUMBER, score NUMBER, comment_text VARCHAR2) CREATE TABLE program_course (program_id NUMBER, course_id NUMBER, workload NUMBER, category VARCHAR2) CREATE TABLE student_record (student_id NUMBER, course_id NUMBER, semester NUMBER, grade VARCHAR2, how VARCHAR2, transfer_source VARCHAR2, earn_credit VARCHAR2, repeat_term VARCHAR2, test_id VARCHAR2) CREATE TABLE ta (campus_job_id NUMBER, student_id NUMBER, location VARCHAR2) CREATE TABLE program_requirement (program_id NUMBER, category VARCHAR2, min_credit NUMBER, additional_req VARCHAR2) CREATE TABLE instructor (instructor_id NUMBER, name VARCHAR2, uniqname VARCHAR2) CREATE TABLE course_tags_count (course_id NUMBER, clear_grading NUMBER, pop_quiz NUMBER, group_projects NUMBER, inspirational NUMBER, long_lectures NUMBER, extra_credit NUMBER, few_tests NUMBER, good_feedback NUMBER, tough_tests NUMBER, heavy_papers NUMBER, cares_for_students NUMBER, heavy_assignments NUMBER, respected NUMBER, participation NUMBER, heavy_reading NUMBER, tough_grader NUMBER, hilarious NUMBER, would_take_again NUMBER, good_lecture NUMBER, no_skip NUMBER) CREATE TABLE jobs (job_id NUMBER, job_title VARCHAR2, description VARCHAR2, requirement VARCHAR2, city VARCHAR2, state VARCHAR2, country VARCHAR2, zip NUMBER) CREATE TABLE student (student_id NUMBER, lastname VARCHAR2, firstname VARCHAR2, program_id NUMBER, declare_major VARCHAR2, total_credit NUMBER, total_gpa FLOAT, entered_as VARCHAR2, admit_term NUMBER, predicted_graduation_semester NUMBER, degree VARCHAR2, minor VARCHAR2, internship VARCHAR2) CREATE TABLE gsi (course_offering_id NUMBER, student_id NUMBER) CREATE TABLE area (course_id NUMBER, area VARCHAR2) CREATE TABLE requirement (requirement_id NUMBER, requirement VARCHAR2, college VARCHAR2)
For Winter or Fall 2014 , what courses in software are offered ?
SELECT DISTINCT course.department, course.name, course.number, semester.semester FROM course INNER JOIN area ON course.course_id = area.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE area.area LIKE '%software%' AND semester.semester IN ('WN', 'FA') AND semester.year = 2014
SELECT DISTINCT "course"."department", "course"."name", "course"."number", "semester"."semester" FROM "course" JOIN "area" ON "area"."area" LIKE '%software%' AND "area"."course_id" = "course"."course_id" JOIN "course_offering" ON "course"."course_id" = "course_offering"."course_id" JOIN "semester" ON "course_offering"."semester" = "semester"."semester_id" AND "semester"."semester" IN ('WN', 'FA') AND "semester"."year" = 2014
0.417969
CREATE TABLE table_name_73 (position VARCHAR2)
Who held the Male Sports Rep position in 2011?
SELECT 2011 FROM table_name_73 WHERE position = "male sports rep"
SELECT 2011 FROM "table_name_73" WHERE "male sports rep" = "position"
0.067383
CREATE TABLE table_9444 ("Name" CLOB, "Born-Died" CLOB, "Term start" CLOB, "Term end" CLOB, "Political Party" CLOB)
Which Born-Died has a Term start of 4 november 1943?
SELECT "Born-Died" FROM table_9444 WHERE "Term start" = '4 november 1943'
SELECT "Born-Died" FROM "table_9444" WHERE "Term start" = '4 november 1943'
0.073242
CREATE TABLE cost (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, event_type CLOB, event_id NUMBER, chargetime TIME, cost 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 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_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 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_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 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 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 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 d_labitems (row_id NUMBER, itemid NUMBER, label CLOB)
in 2103, what are the five most frequent specimen tests given to patients within 2 months after being diagnosed with hearing loss nos?
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 = 'hearing loss nos') AND STRFTIME('%y', diagnoses_icd.charttime) = '2103') 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) = '2103') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t2.charttime) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month') GROUP BY t2.spec_type_desc) AS t3 WHERE t3.c1 <= 5
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") = '2103'), "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" = 'hearing loss 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"."charttime" AND DATETIME("diagnoses_icd"."charttime") <= DATETIME("t2"."charttime") AND DATETIME("diagnoses_icd"."charttime", '+2 month') >= DATETIME("t2"."charttime") WHERE STRFTIME('%y', "diagnoses_icd"."charttime") = '2103' GROUP BY "t2"."spec_type_desc") SELECT "t3"."spec_type_desc" FROM "t3" "t3" WHERE "t3"."c1" <= 5
1.016602
CREATE TABLE table_name_12 (total NUMBER, country VARCHAR2, player VARCHAR2)
Which Total has a Country of united states, and a Player of andy north?
SELECT AVG(total) FROM table_name_12 WHERE country = "united states" AND player = "andy north"
SELECT AVG("total") FROM "table_name_12" WHERE "andy north" = "player" AND "country" = "united states"
0.099609
CREATE TABLE table_71517 ("Date" CLOB, "Tournament" CLOB, "Winning score" CLOB, "Margin of victory" CLOB, "Runner-up" CLOB)
Which runner-up has a 10 strokes margin of victory?
SELECT "Runner-up" FROM table_71517 WHERE "Margin of victory" = '10 strokes'
SELECT "Runner-up" FROM "table_71517" WHERE "Margin of victory" = '10 strokes'
0.076172
CREATE TABLE company (company_id NUMBER, rank NUMBER, company CLOB, headquarters CLOB, main_industry CLOB, sales_billion NUMBER, profits_billion NUMBER, assets_billion NUMBER, market_value NUMBER) CREATE TABLE station_company (station_id NUMBER, company_id NUMBER, rank_of_the_year NUMBER) CREATE TABLE gas_station (station_id NUMBER, open_year NUMBER, location CLOB, manager_name CLOB, vice_manager_name CLOB, representative_name CLOB)
Show all headquarters without a company in banking industry.
SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking'
SELECT "headquarters" FROM "company" EXCEPT SELECT "headquarters" FROM "company" WHERE "main_industry" = 'Banking'
0.111328
CREATE TABLE table_35038 ("Name" CLOB, "County" CLOB, "Location" CLOB, "Built" CLOB, "Length ( ft ) " FLOAT, "Spans" CLOB)
Who has a length of 71 ft?
SELECT "Name" FROM table_35038 WHERE "Length (ft)" = '71'
SELECT "Name" FROM "table_35038" WHERE "Length (ft)" = '71'
0.057617
CREATE TABLE table_name_48 (nationality VARCHAR2, player VARCHAR2)
What is the nationality of Stromile Swift?
SELECT nationality FROM table_name_48 WHERE player = "stromile swift"
SELECT "nationality" FROM "table_name_48" WHERE "player" = "stromile swift"
0.073242
CREATE TABLE table_13309 ("Entities" CLOB, "Country" CLOB, "Supply point" CLOB, "Voltage ( kV ) " FLOAT, "Power ( MW ) " FLOAT)
How much Voltage (kV) has a Country of argentina, and a Power (MW) larger than 30, and a Supply point of yacyret ?
SELECT COUNT("Voltage (kV)") FROM table_13309 WHERE "Country" = 'argentina' AND "Power (MW)" > '30' AND "Supply point" = 'yacyretá'
SELECT COUNT("Voltage (kV)") FROM "table_13309" WHERE "Country" = 'argentina' AND "Power (MW)" > '30' AND "Supply point" = 'yacyretá'
0.129883
CREATE TABLE Statements (Statement_ID NUMBER, Statement_Details VARCHAR2) CREATE TABLE Ref_Budget_Codes (Budget_Type_Code CHAR, Budget_Type_Description VARCHAR2) CREATE TABLE Documents (Document_ID NUMBER, Document_Type_Code CHAR, Project_ID NUMBER, Document_Date DATETIME, Document_Name VARCHAR2, Document_Description VARCHAR2, Other_Details VARCHAR2) CREATE TABLE Accounts (Account_ID NUMBER, Statement_ID NUMBER, Account_Details VARCHAR2) CREATE TABLE Ref_Document_Types (Document_Type_Code CHAR, Document_Type_Name VARCHAR2, Document_Type_Description VARCHAR2) CREATE TABLE Documents_with_Expenses (Document_ID NUMBER, Budget_Type_Code CHAR, Document_Details VARCHAR2) CREATE TABLE Projects (Project_ID NUMBER, Project_Details VARCHAR2)
what are the different budget type codes, and how many documents are there for each?
SELECT Budget_Type_Code, COUNT(*) FROM Documents_with_Expenses GROUP BY Budget_Type_Code
SELECT "Budget_Type_Code", COUNT(*) FROM "Documents_with_Expenses" GROUP BY "Budget_Type_Code"
0.091797
CREATE TABLE table_48564 ("Driver" CLOB, "Entrant" CLOB, "Constructor" CLOB, "Time/Retired" CLOB, "Grid" CLOB, "Heat 1/2" CLOB)
What is the Time/Retired value for Ludovico Scarfiotti?
SELECT "Time/Retired" FROM table_48564 WHERE "Driver" = 'ludovico scarfiotti'
SELECT "Time/Retired" FROM "table_48564" WHERE "Driver" = 'ludovico scarfiotti'
0.077148
CREATE TABLE table_52071 ("Home team" CLOB, "Home team score" CLOB, "Away team" CLOB, "Away team score" CLOB, "Venue" CLOB, "Crowd" FLOAT, "Date" CLOB)
In what venue was the away team South Melbourne?
SELECT "Venue" FROM table_52071 WHERE "Away team" = 'south melbourne'
SELECT "Venue" FROM "table_52071" WHERE "Away team" = 'south melbourne'
0.069336
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 All_Games and ACC_Percent , and list y axis in ascending order.
SELECT All_Games, ACC_Percent FROM basketball_match ORDER BY ACC_Percent
SELECT "All_Games", "ACC_Percent" FROM "basketball_match" ORDER BY "ACC_Percent"
0.078125
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 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)
look for the long title of diagnoses for diagnoses icd9 code 76403.
SELECT diagnoses.long_title FROM diagnoses WHERE diagnoses.icd9_code = "76403"
SELECT "diagnoses"."long_title" FROM "diagnoses" WHERE "76403" = "diagnoses"."icd9_code"
0.085938
CREATE TABLE course_prerequisite (pre_course_id NUMBER, course_id NUMBER) CREATE TABLE student (student_id NUMBER, lastname VARCHAR2, firstname VARCHAR2, program_id NUMBER, declare_major VARCHAR2, total_credit NUMBER, total_gpa FLOAT, entered_as VARCHAR2, admit_term NUMBER, predicted_graduation_semester NUMBER, degree VARCHAR2, minor VARCHAR2, internship VARCHAR2) CREATE TABLE instructor (instructor_id NUMBER, name VARCHAR2, uniqname VARCHAR2) CREATE TABLE course_offering (offering_id NUMBER, course_id NUMBER, semester NUMBER, section_number NUMBER, start_time TIME, end_time TIME, monday VARCHAR2, tuesday VARCHAR2, wednesday VARCHAR2, thursday VARCHAR2, friday VARCHAR2, saturday VARCHAR2, sunday VARCHAR2, has_final_project VARCHAR2, has_final_exam VARCHAR2, textbook VARCHAR2, class_address VARCHAR2, allow_audit VARCHAR2) CREATE TABLE program (program_id NUMBER, name VARCHAR2, college VARCHAR2, introduction VARCHAR2) CREATE TABLE offering_instructor (offering_instructor_id NUMBER, offering_id NUMBER, instructor_id NUMBER) CREATE TABLE semester (semester_id NUMBER, semester VARCHAR2, year NUMBER) CREATE TABLE course_tags_count (course_id NUMBER, clear_grading NUMBER, pop_quiz NUMBER, group_projects NUMBER, inspirational NUMBER, long_lectures NUMBER, extra_credit NUMBER, few_tests NUMBER, good_feedback NUMBER, tough_tests NUMBER, heavy_papers NUMBER, cares_for_students NUMBER, heavy_assignments NUMBER, respected NUMBER, participation NUMBER, heavy_reading NUMBER, tough_grader NUMBER, hilarious NUMBER, would_take_again NUMBER, good_lecture NUMBER, no_skip NUMBER) CREATE TABLE course (course_id NUMBER, name VARCHAR2, department VARCHAR2, number VARCHAR2, credits VARCHAR2, advisory_requirement VARCHAR2, enforced_requirement VARCHAR2, description VARCHAR2, num_semesters NUMBER, num_enrolled NUMBER, has_discussion VARCHAR2, has_lab VARCHAR2, has_projects VARCHAR2, has_exams VARCHAR2, num_reviews NUMBER, clarity_score NUMBER, easiness_score NUMBER, helpfulness_score NUMBER) CREATE TABLE comment_instructor (instructor_id NUMBER, student_id NUMBER, score NUMBER, comment_text VARCHAR2) CREATE TABLE area (course_id NUMBER, area VARCHAR2) CREATE TABLE student_record (student_id NUMBER, course_id NUMBER, semester NUMBER, grade VARCHAR2, how VARCHAR2, transfer_source VARCHAR2, earn_credit VARCHAR2, repeat_term VARCHAR2, test_id VARCHAR2) CREATE TABLE program_requirement (program_id NUMBER, category VARCHAR2, min_credit NUMBER, additional_req VARCHAR2) CREATE TABLE program_course (program_id NUMBER, course_id NUMBER, workload NUMBER, category VARCHAR2) CREATE TABLE ta (campus_job_id NUMBER, student_id NUMBER, location VARCHAR2) CREATE TABLE jobs (job_id NUMBER, job_title VARCHAR2, description VARCHAR2, requirement VARCHAR2, city VARCHAR2, state VARCHAR2, country VARCHAR2, zip NUMBER) CREATE TABLE gsi (course_offering_id NUMBER, student_id NUMBER) CREATE TABLE requirement (requirement_id NUMBER, requirement VARCHAR2, college VARCHAR2)
What time of the day do ORALSURG 750 lectures start next semester ?
SELECT DISTINCT course_offering.start_time FROM course INNER JOIN program_course ON program_course.course_id = course.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE course.department = 'ORALSURG' AND course.number = 750 AND semester.semester = 'FA' AND semester.year = 2016
SELECT DISTINCT "course_offering"."start_time" FROM "course" JOIN "course_offering" ON "course"."course_id" = "course_offering"."course_id" JOIN "program_course" ON "course"."course_id" = "program_course"."course_id" JOIN "semester" ON "course_offering"."semester" = "semester"."semester_id" AND "semester"."semester" = 'FA' AND "semester"."year" = 2016 WHERE "course"."department" = 'ORALSURG' AND "course"."number" = 750
0.412109
CREATE TABLE table_20850527_1 (game VARCHAR2, opponent VARCHAR2)
What game number did the Wildcats play Purdue?
SELECT game FROM table_20850527_1 WHERE opponent = "Purdue"
SELECT "game" FROM "table_20850527_1" WHERE "Purdue" = "opponent"
0.063477
CREATE TABLE table_name_36 (result VARCHAR2, date VARCHAR2)
What were the results for november 25, 1973?
SELECT result FROM table_name_36 WHERE date = "november 25, 1973"
SELECT "result" FROM "table_name_36" WHERE "date" = "november 25, 1973"
0.069336
CREATE TABLE table_50403 ("Rank" FLOAT, "Player" CLOB, "Years" CLOB, "Games" FLOAT, "Ast. Avg." FLOAT, "Total Assists" FLOAT)
WHAT IS THE AVG AST FOR GAMES LARGER THAN 101, RANK 5, TOTAL ASSISTS SMALLER THAN 331?
SELECT AVG("Ast. Avg.") FROM table_50403 WHERE "Games" > '101' AND "Rank" = '5' AND "Total Assists" < '331'
SELECT AVG("Ast. Avg.") FROM "table_50403" WHERE "Games" > '101' AND "Rank" = '5' AND "Total Assists" < '331'
0.106445
CREATE TABLE table_56795 ("Player" CLOB, "Height" CLOB, "School" CLOB, "Hometown" CLOB, "College" CLOB)
What is the hometown of the player that attends UCLA?
SELECT "Hometown" FROM table_56795 WHERE "College" = 'ucla'
SELECT "Hometown" FROM "table_56795" WHERE "College" = 'ucla'
0.05957
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 PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate TIME) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER) CREATE TABLE PostHistoryTypes (Id NUMBER, Name CLOB) CREATE TABLE ReviewTaskTypes (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 CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE PendingFlags (Id NUMBER, FlagTypeId NUMBER, PostId NUMBER, CreationDate TIME, CloseReasonTypeId NUMBER, CloseAsOffTopicReasonTypeId NUMBER, DuplicateOfQuestionId NUMBER, BelongsOnBaseHostAddress CLOB) CREATE TABLE Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) CREATE TABLE ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange 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 VoteTypes (Id NUMBER, Name CLOB) CREATE TABLE PostNoticeTypes (Id NUMBER, ClassId NUMBER, Name CLOB, Body CLOB, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId NUMBER) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) CREATE TABLE PostTypes (Id NUMBER, Name 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 Comments (Id NUMBER, PostId NUMBER, Score NUMBER, Text CLOB, CreationDate TIME, UserDisplayName CLOB, UserId NUMBER, ContentLicense CLOB) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId NUMBER) CREATE TABLE ReviewTaskResultTypes (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE FlagTypes (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 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 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 PostNotices (Id NUMBER, PostId NUMBER, PostNoticeTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body CLOB, OwnerUserId NUMBER, DeletionUserId NUMBER) CREATE TABLE ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE PostTags (PostId NUMBER, TagId NUMBER) 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)
Find answers of specific user by a keyword.
SELECT Id AS "post_link", CreationDate FROM Posts WHERE PostTypeId = 2 AND OwnerUserId = 510662 ORDER BY CreationDate DESC
SELECT "Id" AS "post_link", "CreationDate" FROM "Posts" WHERE "OwnerUserId" = 510662 AND "PostTypeId" = 2 ORDER BY "CreationDate" DESC
0.130859
CREATE TABLE d_items (row_id NUMBER, itemid NUMBER, label CLOB, linksto CLOB) 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 microbiologyevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, charttime TIME, spec_type_desc CLOB, org_name 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 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 chartevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_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 diagnoses_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 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 outputevents (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, value NUMBER) CREATE TABLE d_icd_procedures (row_id NUMBER, icd9_code CLOB, short_title CLOB, long_title CLOB) CREATE TABLE procedures_icd (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icd9_code CLOB, charttime 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 inputevents_cv (row_id NUMBER, subject_id NUMBER, hadm_id NUMBER, icustay_id NUMBER, charttime TIME, itemid NUMBER, amount NUMBER)
let's count the number of patients that were diagnosed with myelopathy in oth dis and did not come back to the hospital in the same month since 1 year ago.
SELECT (SELECT COUNT(DISTINCT t1.subject_id) 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 = 'myelopathy in oth dis') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t1) - (SELECT COUNT(DISTINCT t2.subject_id) 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 = 'myelopathy in oth dis') AND DATETIME(diagnoses_icd.charttime) >= DATETIME(CURRENT_TIME(), '-1 year')) AS t2 JOIN admissions ON t2.subject_id = admissions.subject_id WHERE t2.charttime < admissions.admittime AND DATETIME(admissions.admittime) >= DATETIME(CURRENT_TIME(), '-1 year') AND DATETIME(t2.charttime, 'start of month') = DATETIME(admissions.admittime, 'start of month'))
WITH "_u_0" AS (SELECT "d_icd_diagnoses"."icd9_code" FROM "d_icd_diagnoses" WHERE "d_icd_diagnoses"."short_title" = 'myelopathy in oth dis') SELECT (SELECT COUNT(DISTINCT "admissions"."subject_id") FROM "diagnoses_icd" JOIN "_u_0" "_u_0" ON "_u_0"."icd9_code" = "diagnoses_icd"."icd9_code" JOIN "admissions" ON "admissions"."hadm_id" = "diagnoses_icd"."hadm_id" WHERE DATETIME("diagnoses_icd"."charttime") >= DATETIME(CURRENT_TIME(), '-1 year')) - (SELECT COUNT(DISTINCT "admissions_2"."subject_id") FROM "diagnoses_icd" JOIN "_u_0" "_u_2" ON "_u_2"."icd9_code" = "diagnoses_icd"."icd9_code" JOIN "admissions" "admissions_2" ON "admissions_2"."hadm_id" = "diagnoses_icd"."hadm_id" JOIN "admissions" ON "admissions"."admittime" > "diagnoses_icd"."charttime" AND "admissions"."subject_id" = "admissions_2"."subject_id" AND DATETIME("admissions"."admittime") >= DATETIME(CURRENT_TIME(), '-1 year') AND DATETIME("admissions"."admittime", 'start of month') = DATETIME("diagnoses_icd"."charttime", 'start of month') WHERE DATETIME("diagnoses_icd"."charttime") >= DATETIME(CURRENT_TIME(), '-1 year'))
1.067383
CREATE TABLE table_16396 ("Pick #" FLOAT, "CFL Team" CLOB, "Player" CLOB, "Position" CLOB, "College" CLOB)
What CFL teams are part of Simon Fraser college?
SELECT "CFL Team" FROM table_16396 WHERE "College" = 'Simon Fraser'
SELECT "CFL Team" FROM "table_16396" WHERE "College" = 'Simon Fraser'
0.067383
CREATE TABLE table_75032 ("Call sign" CLOB, "Analog channel" CLOB, "Digital channel" CLOB, "Virtual channel" CLOB, "Network" CLOB, "Station Ownership" CLOB)
Network of nbc is what digital channel?
SELECT "Digital channel" FROM table_75032 WHERE "Network" = 'nbc'
SELECT "Digital channel" FROM "table_75032" WHERE "Network" = 'nbc'
0.06543
CREATE TABLE table_name_19 (car_model VARCHAR2, engine VARCHAR2)
What Car Model has the Engine of Ford 6.0 V8?
SELECT car_model FROM table_name_19 WHERE engine = "ford 6.0 v8"
SELECT "car_model" FROM "table_name_19" WHERE "engine" = "ford 6.0 v8"
0.068359
CREATE TABLE table_name_18 (game VARCHAR2, record VARCHAR2)
What is the Game number when the Rangers have a Record of 25-24-11?
SELECT COUNT(game) FROM table_name_18 WHERE record = "25-24-11"
SELECT COUNT("game") FROM "table_name_18" WHERE "25-24-11" = "record"
0.067383
CREATE TABLE table_203_370 (id NUMBER, "year" NUMBER, "competition" CLOB, "venue" CLOB, "position" CLOB, "event" CLOB, "notes" CLOB)
which was the only competition to occur in china ?
SELECT "competition" FROM table_203_370 WHERE "venue" = 'pr china'
SELECT "competition" FROM "table_203_370" WHERE "venue" = 'pr china'
0.066406
CREATE TABLE table_name_56 (year NUMBER, role VARCHAR2, director VARCHAR2)
What year was the role nan taylor, alias of nan ellis, aka mrs. andrews and directed by William keighley?
SELECT SUM(year) FROM table_name_56 WHERE role = "nan taylor, alias of nan ellis, aka mrs. andrews" AND director = "william keighley"
SELECT SUM("year") FROM "table_name_56" WHERE "director" = "william keighley" AND "nan taylor, alias of nan ellis, aka mrs. andrews" = "role"
0.137695
CREATE TABLE employees (first_name VARCHAR2, department_id VARCHAR2) CREATE TABLE departments (department_name VARCHAR2, department_id VARCHAR2)
Display the first name and department name for each employee.
SELECT T1.first_name, T2.department_name FROM employees AS T1 JOIN departments AS T2 ON T1.department_id = T2.department_id
SELECT "T1"."first_name", "T2"."department_name" FROM "employees" "T1" JOIN "departments" "T2" ON "T1"."department_id" = "T2"."department_id"
0.137695
CREATE TABLE table_45807 ("Pick" FLOAT, "Player" CLOB, "Nationality" CLOB, "New WNBA Team" CLOB, "Former WNBA Team" CLOB, "College/Country/Team" CLOB)
What was the new WNBA team of the player selected with a pick over 7?
SELECT "New WNBA Team" FROM table_45807 WHERE "Pick" > '7'
SELECT "New WNBA Team" FROM "table_45807" WHERE "Pick" > '7'
0.058594
CREATE TABLE student (student_id NUMBER, lastname VARCHAR2, firstname VARCHAR2, program_id NUMBER, declare_major VARCHAR2, total_credit NUMBER, total_gpa FLOAT, entered_as VARCHAR2, admit_term NUMBER, predicted_graduation_semester NUMBER, degree VARCHAR2, minor VARCHAR2, internship VARCHAR2) CREATE TABLE ta (campus_job_id NUMBER, student_id NUMBER, location VARCHAR2) CREATE TABLE gsi (course_offering_id NUMBER, student_id NUMBER) CREATE TABLE student_record (student_id NUMBER, course_id NUMBER, semester NUMBER, grade VARCHAR2, how VARCHAR2, transfer_source VARCHAR2, earn_credit VARCHAR2, repeat_term VARCHAR2, test_id VARCHAR2) CREATE TABLE requirement (requirement_id NUMBER, requirement VARCHAR2, college VARCHAR2) CREATE TABLE jobs (job_id NUMBER, job_title VARCHAR2, description VARCHAR2, requirement VARCHAR2, city VARCHAR2, state VARCHAR2, country VARCHAR2, zip NUMBER) CREATE TABLE program_requirement (program_id NUMBER, category VARCHAR2, min_credit NUMBER, additional_req VARCHAR2) CREATE TABLE course_prerequisite (pre_course_id NUMBER, course_id NUMBER) CREATE TABLE offering_instructor (offering_instructor_id NUMBER, offering_id NUMBER, instructor_id NUMBER) CREATE TABLE course_tags_count (course_id NUMBER, clear_grading NUMBER, pop_quiz NUMBER, group_projects NUMBER, inspirational NUMBER, long_lectures NUMBER, extra_credit NUMBER, few_tests NUMBER, good_feedback NUMBER, tough_tests NUMBER, heavy_papers NUMBER, cares_for_students NUMBER, heavy_assignments NUMBER, respected NUMBER, participation NUMBER, heavy_reading NUMBER, tough_grader NUMBER, hilarious NUMBER, would_take_again NUMBER, good_lecture NUMBER, no_skip NUMBER) CREATE TABLE area (course_id NUMBER, area VARCHAR2) CREATE TABLE instructor (instructor_id NUMBER, name VARCHAR2, uniqname VARCHAR2) CREATE TABLE program_course (program_id NUMBER, course_id NUMBER, workload NUMBER, category VARCHAR2) CREATE TABLE course_offering (offering_id NUMBER, course_id NUMBER, semester NUMBER, section_number NUMBER, start_time TIME, end_time TIME, monday VARCHAR2, tuesday VARCHAR2, wednesday VARCHAR2, thursday VARCHAR2, friday VARCHAR2, saturday VARCHAR2, sunday VARCHAR2, has_final_project VARCHAR2, has_final_exam VARCHAR2, textbook VARCHAR2, class_address VARCHAR2, allow_audit VARCHAR2) CREATE TABLE semester (semester_id NUMBER, semester VARCHAR2, year NUMBER) CREATE TABLE program (program_id NUMBER, name VARCHAR2, college VARCHAR2, introduction VARCHAR2) CREATE TABLE comment_instructor (instructor_id NUMBER, student_id NUMBER, score NUMBER, comment_text VARCHAR2) CREATE TABLE course (course_id NUMBER, name VARCHAR2, department VARCHAR2, number VARCHAR2, credits VARCHAR2, advisory_requirement VARCHAR2, enforced_requirement VARCHAR2, description VARCHAR2, num_semesters NUMBER, num_enrolled NUMBER, has_discussion VARCHAR2, has_lab VARCHAR2, has_projects VARCHAR2, has_exams VARCHAR2, num_reviews NUMBER, clarity_score NUMBER, easiness_score NUMBER, helpfulness_score NUMBER)
Which classes that are upper-level give 11 credits ?
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id WHERE course.credits = 11 AND program_course.category LIKE 'ULCS'
SELECT DISTINCT "course"."department", "course"."name", "course"."number" FROM "course" JOIN "program_course" ON "course"."course_id" = "program_course"."course_id" AND "program_course"."category" LIKE 'ULCS' WHERE "course"."credits" = 11
0.232422
CREATE TABLE job_history (EMPLOYEE_ID NUMBER, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR2, DEPARTMENT_ID 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 regions (REGION_ID NUMBER, REGION_NAME 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 those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, draw a scatter chart about the correlation between salary and department_id .
SELECT SALARY, DEPARTMENT_ID FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40
SELECT "SALARY", "DEPARTMENT_ID" FROM "employees" WHERE ("COMMISSION_PCT" <> "null" OR "DEPARTMENT_ID" <> 40) AND ("DEPARTMENT_ID" <> 40 OR "SALARY" <= 12000) AND ("DEPARTMENT_ID" <> 40 OR "SALARY" >= 8000)
0.201172
CREATE TABLE products (code NUMBER, name CLOB, price NUMBER, manufacturer NUMBER) CREATE TABLE manufacturers (code NUMBER, name CLOB, headquarter CLOB, founder CLOB, revenue NUMBER)
What is the total revenue of companies started by founder?
SELECT SUM(revenue), founder FROM manufacturers GROUP BY founder
SELECT SUM("revenue"), "founder" FROM "manufacturers" GROUP BY "founder"
0.070313
CREATE TABLE table_name_28 (crowd VARCHAR2, home_team VARCHAR2)
What is the size of the crowd for the home team of Footscray?
SELECT crowd FROM table_name_28 WHERE home_team = "footscray"
SELECT "crowd" FROM "table_name_28" WHERE "footscray" = "home_team"
0.06543
CREATE TABLE table_1849 ("Main contestant" CLOB, "Co-contestant ( Yaar vs. Pyaar ) " CLOB, "Date performed" CLOB, "Scores by each individual judge" CLOB, "Total score/week" CLOB, "Position" CLOB, "Status" CLOB)
How many different combinations of scores by individual judges were given to the contestant competing against Mukul Dev?
SELECT COUNT("Scores by each individual judge") FROM table_1849 WHERE "Co-contestant (Yaar vs. Pyaar)" = 'Mukul Dev'
SELECT COUNT("Scores by each individual judge") FROM "table_1849" WHERE "Co-contestant (Yaar vs. Pyaar)" = 'Mukul Dev'
0.115234
CREATE TABLE table_36701 ("Conference" CLOB, "Division" CLOB, "Team" CLOB, "City" CLOB, "Home Stadium" CLOB)
What is the name of the Home Stadium in which the Division is in the south, and Conference is national, as well as being in the city named charlotte, North Carolina?
SELECT "Home Stadium" FROM table_36701 WHERE "Division" = 'south' AND "Conference" = 'national' AND "City" = 'charlotte, north carolina'
SELECT "Home Stadium" FROM "table_36701" WHERE "City" = 'charlotte, north carolina' AND "Conference" = 'national' AND "Division" = 'south'
0.134766
CREATE TABLE table_name_71 (start NUMBER, player VARCHAR2)
For the player fero lasagavibau who has the lowest start?
SELECT MIN(start) FROM table_name_71 WHERE player = "fero lasagavibau"
SELECT MIN("start") FROM "table_name_71" WHERE "fero lasagavibau" = "player"
0.074219
CREATE TABLE table_45654 ("Class" CLOB, "Team" CLOB, "Driver" CLOB, "Chassis \\u2013 Engine" CLOB, "Laps" FLOAT)
What Team had 40 Laps in C1 Class?
SELECT "Team" FROM table_45654 WHERE "Class" = 'c1' AND "Laps" = '40'
SELECT "Team" FROM "table_45654" WHERE "Class" = 'c1' AND "Laps" = '40'
0.069336
CREATE TABLE program (Program_ID NUMBER, Name CLOB, Origin CLOB, Launch FLOAT, Owner CLOB) CREATE TABLE broadcast_share (Channel_ID NUMBER, Program_ID NUMBER, Date CLOB, Share_in_percent FLOAT) CREATE TABLE channel (Channel_ID NUMBER, Name CLOB, Owner CLOB, Share_in_percent FLOAT, Rating_in_percent FLOAT) CREATE TABLE broadcast (Channel_ID NUMBER, Program_ID NUMBER, Time_of_day CLOB)
Show me a bar chart for what is the total rating of channel for each channel owner?, and show in ascending by the total number.
SELECT Owner, SUM(Rating_in_percent) FROM channel GROUP BY Owner ORDER BY SUM(Rating_in_percent)
SELECT "Owner", SUM("Rating_in_percent") FROM "channel" GROUP BY "Owner" ORDER BY SUM("Rating_in_percent")
0.103516
CREATE TABLE table_name_47 (nationality VARCHAR2, position VARCHAR2, school_club_team VARCHAR2)
What is the nationality for the guard position from Bowling Green?
SELECT nationality FROM table_name_47 WHERE position = "guard" AND school_club_team = "bowling green"
SELECT "nationality" FROM "table_name_47" WHERE "bowling green" = "school_club_team" AND "guard" = "position"
0.106445
CREATE TABLE table_15614 ("Year" FLOAT, "Division" FLOAT, "League" CLOB, "Regular Season" CLOB, "Playoffs" CLOB, "Open Cup" CLOB)
What league played in 2011?
SELECT "League" FROM table_15614 WHERE "Year" = '2011'
SELECT "League" FROM "table_15614" WHERE "Year" = '2011'
0.054688
CREATE TABLE table_30016 ("Province" CLOB, "Provincial capital" CLOB, "Commandery" CLOB, "Commandery capital" CLOB, "No. of counties" FLOAT)
When yidu is the commandery what is the lowest number of countries?
SELECT MIN("No. of counties") FROM table_30016 WHERE "Commandery" = 'Yidu 宜都'
SELECT MIN("No. of counties") FROM "table_30016" WHERE "Commandery" = 'Yidu 宜都'
0.077148
CREATE TABLE table_15819 ("District" CLOB, "Counties Represented" CLOB, "Party" CLOB, "First Elected" FLOAT, "Committee" CLOB)
What counties represented have a democratic committee, and a committee of ways and means?
SELECT "Counties Represented" FROM table_15819 WHERE "Party" = 'democratic' AND "Committee" = 'ways and means'
SELECT "Counties Represented" FROM "table_15819" WHERE "Committee" = 'ways and means' AND "Party" = 'democratic'
0.109375
CREATE TABLE table_44823 ("Game" FLOAT, "Date" FLOAT, "Opponent" CLOB, "Score" CLOB, "Decision" CLOB, "Location/Attendance" CLOB, "Record" CLOB)
What is the location and attendance of game 44?
SELECT "Location/Attendance" FROM table_44823 WHERE "Game" = '44'
SELECT "Location/Attendance" FROM "table_44823" WHERE "Game" = '44'
0.06543
CREATE TABLE table_204_882 (id NUMBER, "number" NUMBER, "builder" CLOB, "entered service" CLOB, "withdrawn" CLOB, "notes" CLOB)
how many locomotives were still in service after the year 1950 ?
SELECT COUNT(*) FROM table_204_882 WHERE "entered service" <= 1950 AND "withdrawn" >= 1950
SELECT COUNT(*) FROM "table_204_882" WHERE "entered service" <= 1950 AND "withdrawn" >= 1950
0.089844
CREATE TABLE PostNotices (Id NUMBER, PostId NUMBER, PostNoticeTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body CLOB, OwnerUserId NUMBER, DeletionUserId NUMBER) CREATE TABLE PostTypes (Id NUMBER, Name CLOB) CREATE TABLE SuggestedEditVotes (Id NUMBER, SuggestedEditId NUMBER, UserId NUMBER, VoteTypeId NUMBER, CreationDate TIME, TargetUserId NUMBER, TargetRepChange NUMBER) CREATE TABLE PostFeedback (Id NUMBER, PostId NUMBER, IsAnonymous BOOLEAN, VoteTypeId NUMBER, CreationDate TIME) CREATE TABLE ReviewTaskStates (Id NUMBER, Name CLOB, Description CLOB) CREATE TABLE Tags (Id NUMBER, TagName CLOB, Count NUMBER, ExcerptPostId NUMBER, WikiPostId NUMBER) 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 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 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 Badges (Id NUMBER, UserId NUMBER, Name CLOB, Date TIME, Class NUMBER, TagBased BOOLEAN) CREATE TABLE ReviewTasks (Id NUMBER, ReviewTaskTypeId NUMBER, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId NUMBER, PostId NUMBER, SuggestedEditId NUMBER, CompletedByReviewTaskId NUMBER) CREATE TABLE PostTags (PostId NUMBER, TagId NUMBER) CREATE TABLE PostLinks (Id NUMBER, CreationDate TIME, PostId NUMBER, RelatedPostId NUMBER, LinkTypeId NUMBER) CREATE TABLE PostNoticeTypes (Id NUMBER, ClassId NUMBER, Name CLOB, Body CLOB, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId NUMBER) CREATE TABLE ReviewTaskResults (Id NUMBER, ReviewTaskId NUMBER, ReviewTaskResultTypeId NUMBER, CreationDate TIME, RejectionReasonId NUMBER, Comment CLOB) CREATE TABLE PostHistoryTypes (Id NUMBER, Name 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 CloseReasonTypes (Id NUMBER, Name CLOB, Description CLOB) 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 Comments (Id NUMBER, PostId NUMBER, Score NUMBER, Text CLOB, CreationDate TIME, UserDisplayName CLOB, UserId NUMBER, ContentLicense CLOB) CREATE TABLE VoteTypes (Id NUMBER, Name 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 FlagTypes (Id NUMBER, Name CLOB, Description CLOB) 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 ReviewRejectionReasons (Id NUMBER, Name CLOB, Description CLOB, PostTypeId NUMBER) CREATE TABLE Votes (Id NUMBER, PostId NUMBER, VoteTypeId NUMBER, UserId NUMBER, CreationDate TIME, BountyAmount NUMBER) CREATE TABLE PendingFlags (Id NUMBER, FlagTypeId NUMBER, PostId NUMBER, CreationDate TIME, CloseReasonTypeId NUMBER, CloseAsOffTopicReasonTypeId NUMBER, DuplicateOfQuestionId NUMBER, BelongsOnBaseHostAddress CLOB) CREATE TABLE ReviewTaskTypes (Id NUMBER, Name CLOB, Description CLOB)
Users with high self-accept rates (and having > 10 answers). (the extreme self-learners)
SELECT Users.Id AS "user_link", (CAST(COUNT(a.Id) AS FLOAT) / CAST((SELECT COUNT(*) FROM Posts AS p WHERE p.OwnerUserId = Users.Id AND PostTypeId = 1) AS FLOAT) * 100) AS SelfAnswerPercentage FROM Posts AS q INNER JOIN Posts AS a ON q.AcceptedAnswerId = a.Id INNER JOIN Users ON Users.Id = q.OwnerUserId WHERE q.OwnerUserId = a.OwnerUserId GROUP BY Users.Id, DisplayName HAVING COUNT(a.Id) > 20 ORDER BY SelfAnswerPercentage DESC LIMIT 100
WITH "_u_0" AS (SELECT COUNT(*), "p"."OwnerUserId" AS "_u_1", 1 AS "_u_2" FROM "Posts" "p" GROUP BY "p"."OwnerUserId", 1) SELECT "Users"."Id" AS "user_link", CAST(COUNT("a"."Id") AS FLOAT) / NULLIF(CAST(COALESCE("_u_0"."", *) AS FLOAT), 0) * 100 AS "SelfAnswerPercentage" FROM "Posts" "q" JOIN "Users" ON "Users"."Id" = "q"."OwnerUserId" JOIN "Posts" "a" ON "a"."Id" = "q"."AcceptedAnswerId" AND "a"."OwnerUserId" = "q"."OwnerUserId" LEFT JOIN "_u_0" "_u_0" ON "PostTypeId" = "_u_0"."_u_2" AND "Users"."Id" = "_u_0"."_u_1" GROUP BY "Users"."Id", "DisplayName" HAVING COUNT("a"."Id") > 20 ORDER BY "SelfAnswerPercentage" DESC FETCH FIRST 100 ROWS ONLY
0.634766
CREATE TABLE table_name_53 (venue VARCHAR2, away_team VARCHAR2)
Where was the game when Melbourne was the away team?
SELECT venue FROM table_name_53 WHERE away_team = "melbourne"
SELECT "venue" FROM "table_name_53" WHERE "away_team" = "melbourne"
0.06543
CREATE TABLE table_75845 ("Date" CLOB, "Venue" CLOB, "Score" CLOB, "Result" CLOB, "Competition" CLOB)
What result has January 21, 2002 as the date?
SELECT "Result" FROM table_75845 WHERE "Date" = 'january 21, 2002'
SELECT "Result" FROM "table_75845" WHERE "Date" = 'january 21, 2002'
0.066406
CREATE TABLE table_name_60 (status VARCHAR2, area_km_2 VARCHAR2, census_ranking VARCHAR2)
What is the status of the community that has an area larger than 5.2 sq km, and a Census Ranking of 2,531 of 5,008?
SELECT status FROM table_name_60 WHERE area_km_2 > 5.2 AND census_ranking = "2,531 of 5,008"
SELECT "status" FROM "table_name_60" WHERE "2,531 of 5,008" = "census_ranking" AND "area_km_2" > 5.2
0.097656
CREATE TABLE table_8975 ("Game" FLOAT, "December" FLOAT, "Opponent" CLOB, "Score" CLOB, "Record" CLOB)
What was the score when the opponent was Montreal Canadiens?
SELECT "Score" FROM table_8975 WHERE "Opponent" = 'montreal canadiens'
SELECT "Score" FROM "table_8975" WHERE "Opponent" = 'montreal canadiens'
0.070313
CREATE TABLE table_name_95 (score VARCHAR2, date VARCHAR2)
What is the score on october 7?
SELECT score FROM table_name_95 WHERE date = "october 7"
SELECT "score" FROM "table_name_95" WHERE "date" = "october 7"
0.060547
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 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 allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime TIME) 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 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 vitalperiodic (vitalperiodicid NUMBER, patientunitstayid NUMBER, temperature NUMBER, sao2 NUMBER, heartrate NUMBER, respiration NUMBER, systemicsystolic NUMBER, systemicdiastolic NUMBER, systemicmean NUMBER, observationtime TIME)
how many patients were prescribed potassium chloride during the same hospital visit after having undergone immunoregulatory agents?
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'immunoregulatory agents') AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime, patient.patienthealthsystemstayid FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'potassium chloride') AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
WITH "t2" AS (SELECT "medication"."drugstarttime", "patient"."patienthealthsystemstayid" FROM "medication" JOIN "patient" ON "medication"."patientunitstayid" = "patient"."patientunitstayid" WHERE "medication"."drugname" = 'potassium chloride') SELECT COUNT(DISTINCT "patient"."uniquepid") FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" JOIN "t2" "t2" ON "patient"."patienthealthsystemstayid" = "t2"."patienthealthsystemstayid" AND "t2"."drugstarttime" > "treatment"."treatmenttime" WHERE "treatment"."treatmentname" = 'immunoregulatory agents'
0.581055
CREATE TABLE table_name_60 (team VARCHAR2, race_title VARCHAR2)
Name the team for launceston
SELECT team FROM table_name_60 WHERE race_title = "launceston"
SELECT "team" FROM "table_name_60" WHERE "launceston" = "race_title"
0.066406
CREATE TABLE table_name_97 (opponent VARCHAR2, score VARCHAR2)
Who was the opponent with a score of 141 102?
SELECT opponent FROM table_name_97 WHERE score = "141–102"
SELECT "opponent" FROM "table_name_97" WHERE "141–102" = "score"
0.0625
CREATE TABLE table_50408 ("Res." CLOB, "Record" CLOB, "Opponent" CLOB, "Method" CLOB, "Event" CLOB, "Round" FLOAT, "Location" CLOB)
What was the result when the opponent was Rory Markham?
SELECT "Res." FROM table_50408 WHERE "Opponent" = 'rory markham'
SELECT "Res." FROM "table_50408" WHERE "Opponent" = 'rory markham'
0.064453
CREATE TABLE driver (Driver_ID NUMBER, Name CLOB, Party CLOB, Home_city CLOB, Age NUMBER) CREATE TABLE school (School_ID NUMBER, Grade CLOB, School CLOB, Location CLOB, Type CLOB) CREATE TABLE school_bus (School_ID NUMBER, Driver_ID NUMBER, Years_Working NUMBER, If_full_time BOOLEAN)
Show the type of school and the number of buses for each type in a bar chart, list x-axis in descending order.
SELECT Type, COUNT(*) FROM school_bus AS T1 JOIN school AS T2 ON T1.School_ID = T2.School_ID GROUP BY T2.Type ORDER BY Type DESC
SELECT "Type", COUNT(*) FROM "school_bus" "T1" JOIN "school" "T2" ON "T1"."School_ID" = "T2"."School_ID" GROUP BY "T2"."Type" ORDER BY "Type" DESC
0.142578
CREATE TABLE table_45478 ("Competition" CLOB, "Played" FLOAT, "Draw" FLOAT, "Lost" FLOAT, "Favour" FLOAT, "Against" FLOAT)
How many games did they lose when they tied less than 2 games?
SELECT "Lost" FROM table_45478 WHERE "Draw" < '2'
SELECT "Lost" FROM "table_45478" WHERE "Draw" < '2'
0.049805
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 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 allergy (allergyid NUMBER, patientunitstayid NUMBER, drugname CLOB, allergyname CLOB, allergytime 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 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)
did any organisms were found in patient 025-44495's last sputum, expectorated microbiology test this month?
SELECT COUNT(*) > 0 FROM microlab WHERE microlab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '025-44495')) AND microlab.culturesite = 'sputum, expectorated' AND DATETIME(microlab.culturetakentime, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') ORDER BY microlab.culturetakentime DESC LIMIT 1
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '025-44495' 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 "microlab" LEFT JOIN "_u_1" "_u_1" ON "_u_1"."" = "microlab"."patientunitstayid" WHERE "microlab"."culturesite" = 'sputum, expectorated' AND DATETIME("microlab"."culturetakentime", 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND NOT "_u_1"."" IS NULL ORDER BY "microlab"."culturetakentime" DESC FETCH FIRST 1 ROWS ONLY
0.711914