schema
stringlengths
28
5.65k
question
stringlengths
0
990
rejected
stringlengths
2
4.44k
chosen
stringlengths
4
9.17k
weight
float64
0
8.95
CREATE TABLE Allergy_Type (Allergy VARCHAR, AllergyType VARCHAR) CREATE TABLE Has_Allergy (StuID INT, Allergy VARCHAR) CREATE TABLE Student (StuID INT, LName VARCHAR, Fname VARCHAR, Age INT, Sex VARCHAR, Major INT, Advisor INT, city_code VARCHAR)
Return a bar chart on how many students have each different allergy?, rank by the x axis from low to high.
SELECT Allergy, COUNT(*) FROM Has_Allergy GROUP BY Allergy ORDER BY Allergy
SELECT "Allergy", COUNT(*) FROM "Has_Allergy" GROUP BY "Allergy" ORDER BY "Allergy" NULLS FIRST
0.092773
CREATE TABLE table_68969 ("Place" TEXT, "Player" TEXT, "Country" TEXT, "Score" TEXT, "To par" TEXT, "Money ( $ ) " FLOAT)
What was the place ranking for the player from Australia?
SELECT "Place" FROM table_68969 WHERE "Country" = 'australia'
SELECT "Place" FROM "table_68969" WHERE "Country" = 'australia'
0.061523
CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME)
what is the number of hours that have passed since patient 027-61708's first cultures during the current hospital visit?
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', 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 = '027-61708' AND patient.hospitaldischargetime IS NULL)) AND treatment.treatmentname = 'cultures' ORDER BY treatment.treatmenttime LIMIT 1
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."hospitaldischargetime" IS NULL AND "patient"."uniquepid" = '027-61708' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid") SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', "treatment"."treatmenttime")) FROM "treatment" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "treatment"."patientunitstayid" WHERE "treatment"."treatmentname" = 'cultures' AND NOT "_u_1"."" IS NULL ORDER BY "treatment"."treatmenttime" NULLS FIRST LIMIT 1
0.698242
CREATE TABLE Manufacturers (Code INT, Name VARCHAR, Headquarter VARCHAR, Founder VARCHAR, Revenue FLOAT) CREATE TABLE Products (Code INT, Name VARCHAR, Price DECIMAL, Manufacturer INT)
For those records from the products and each product's manufacturer, give me the comparison about the average of code over the founder , and group by attribute founder by a bar chart, I want to show in descending by the total number.
SELECT T2.Founder, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Founder ORDER BY T1.Code DESC
SELECT "T2"."Founder", "T1"."Code" FROM "Products" AS "T1" JOIN "Manufacturers" AS "T2" ON "T1"."Manufacturer" = "T2"."Code" GROUP BY "T2"."Founder" ORDER BY "T1"."Code" DESC NULLS LAST
0.180664
CREATE TABLE table_69698 ("Name" TEXT, "Championship" FLOAT, "League Cup" FLOAT, "FA Cup" FLOAT, "Total" FLOAT)
How many FA cups for the player with under 5 champs, 0 league cups, and over 3 total?
SELECT SUM("FA Cup") FROM table_69698 WHERE "Championship" < '5' AND "League Cup" = '0' AND "Total" > '3'
SELECT SUM("FA Cup") FROM "table_69698" WHERE "Championship" < '5' AND "League Cup" = '0' AND "Total" > '3'
0.104492
CREATE TABLE elimination (elimination_id TEXT, wrestler_id TEXT, team TEXT, eliminated_by TEXT, elimination_move TEXT, time TEXT) CREATE TABLE wrestler (wrestler_id DECIMAL, name TEXT, reign TEXT, days_held TEXT, location TEXT, event TEXT)
Return the names of wrestlers with fewer than 100 days held.
SELECT name FROM wrestler WHERE days_held < 100
SELECT "name" FROM "wrestler" WHERE "days_held" < 100
0.051758
CREATE TABLE table_19572 ("Rank" FLOAT, "Country" TEXT, "International tourist arrivals ( 2012 ) " TEXT, "International tourist arrivals ( 2011 ) " TEXT, "Change ( 2011 to 2012 ) " TEXT, "Change ( 2010 to 2011 ) " TEXT)
When the change (2011 to 2012) is +13.4% what is the country?
SELECT "Country" FROM table_19572 WHERE "Change (2011 to 2012)" = '+13.4%'
SELECT "Country" FROM "table_19572" WHERE "Change (2011 to 2012)" = '+13.4%'
0.074219
CREATE TABLE table_47821 ("Year" FLOAT, "Date" TEXT, "Winner" TEXT, "Result" TEXT, "Loser" TEXT, "Location" TEXT)
Who was the loser against the New York Giants in 2001?
SELECT "Loser" FROM table_47821 WHERE "Year" = '2001' AND "Winner" = 'new york giants'
SELECT "Loser" FROM "table_47821" WHERE "Winner" = 'new york giants' AND "Year" = '2001'
0.085938
CREATE TABLE table_44322 ("Position" FLOAT, "Driver / Passenger" TEXT, "Equipment" TEXT, "Bike No" FLOAT, "Points" FLOAT)
What were highest points received from someone using a zabel-wsp with a position greater than 7?
SELECT MAX("Points") FROM table_44322 WHERE "Equipment" = 'zabel-wsp' AND "Position" > '7'
SELECT MAX("Points") FROM "table_44322" WHERE "Equipment" = 'zabel-wsp' AND "Position" > '7'
0.089844
CREATE TABLE table_23614702_1 (main_artillery VARCHAR, warship VARCHAR)
What's Blanco Encalada's main artillery?
SELECT main_artillery FROM table_23614702_1 WHERE warship = "Blanco Encalada"
SELECT "main_artillery" FROM "table_23614702_1" WHERE "Blanco Encalada" = "warship"
0.081055
CREATE TABLE table_24065 ("Episode" TEXT, "Broadcast date" TEXT, "Run time" TEXT, "Viewers ( in millions ) " TEXT, "Archive" TEXT)
What was the archive for the episode with a run time of 25:24?
SELECT "Archive" FROM table_24065 WHERE "Run time" = '25:24'
SELECT "Archive" FROM "table_24065" WHERE "Run time" = '25:24'
0.060547
CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) CREATE TABLE diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE transfers (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, eventtype TEXT, careunit TEXT, wardid DECIMAL, intime TIME, outtime TIME) CREATE TABLE chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE prescriptions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, startdate TIME, enddate TIME, drug TEXT, dose_val_rx TEXT, dose_unit_rx TEXT, route TEXT) CREATE TABLE admissions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, admittime TIME, dischtime TIME, admission_type TEXT, admission_location TEXT, discharge_location TEXT, insurance TEXT, language TEXT, marital_status TEXT, ethnicity TEXT, age DECIMAL) CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) CREATE TABLE patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME) CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE icustays (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, first_careunit TEXT, last_careunit TEXT, first_wardid DECIMAL, last_wardid DECIMAL, intime TIME, outtime TIME)
last time patient 7519 got surgery until 2101?
SELECT procedures_icd.charttime FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 7519) AND STRFTIME('%y', procedures_icd.charttime) <= '2101' ORDER BY procedures_icd.charttime DESC LIMIT 1
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 7519 GROUP BY "hadm_id") SELECT "procedures_icd"."charttime" FROM "procedures_icd" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "procedures_icd"."hadm_id" WHERE NOT "_u_0"."" IS NULL AND STRFTIME('%y', "procedures_icd"."charttime") <= '2101' ORDER BY "procedures_icd"."charttime" DESC NULLS LAST LIMIT 1
0.388672
CREATE TABLE Student (Sex VARCHAR, Fname VARCHAR, Lname VARCHAR)
What is the gender of the student Linda Smith?
SELECT Sex FROM Student WHERE Fname = "Linda" AND Lname = "Smith"
SELECT "Sex" FROM "Student" WHERE "Fname" = "Linda" AND "Lname" = "Smith"
0.071289
CREATE TABLE Employees (Employee_ID INT, Role_Code CHAR, Employee_Name VARCHAR, Gender_MFU CHAR, Date_of_Birth DATETIME, Other_Details VARCHAR) CREATE TABLE Ref_Locations (Location_Code CHAR, Location_Name VARCHAR, Location_Description VARCHAR) CREATE TABLE Ref_Document_Types (Document_Type_Code CHAR, Document_Type_Name VARCHAR, Document_Type_Description VARCHAR) CREATE TABLE Ref_Calendar (Calendar_Date DATETIME, Day_Number INT) CREATE TABLE Documents_to_be_Destroyed (Document_ID INT, Destruction_Authorised_by_Employee_ID INT, Destroyed_by_Employee_ID INT, Planned_Destruction_Date DATETIME, Actual_Destruction_Date DATETIME, Other_Details VARCHAR) CREATE TABLE All_Documents (Document_ID INT, Date_Stored DATETIME, Document_Type_Code CHAR, Document_Name CHAR, Document_Description CHAR, Other_Details VARCHAR) CREATE TABLE Document_Locations (Document_ID INT, Location_Code CHAR, Date_in_Location_From DATETIME, Date_in_Locaton_To DATETIME) CREATE TABLE Roles (Role_Code CHAR, Role_Name VARCHAR, Role_Description VARCHAR)
Stacked bar of date in locaton to and the number of date in locaton to colored by Location_Code, order by the Y in ascending.
SELECT Date_in_Locaton_To, COUNT(Date_in_Locaton_To) FROM Document_Locations GROUP BY Location_Code ORDER BY COUNT(Date_in_Locaton_To)
SELECT "Date_in_Locaton_To", COUNT("Date_in_Locaton_To") FROM "Document_Locations" GROUP BY "Location_Code" ORDER BY COUNT("Date_in_Locaton_To") NULLS FIRST
0.152344
CREATE TABLE table_21698 ("Winner" TEXT, "Country" TEXT, "Winter Olympics" TEXT, "FIS Nordic World Ski Championships" TEXT, "Holmenkollen" TEXT)
What is the FIS Nordic World Ski Championships when holmenkollen is 1976?
SELECT "FIS Nordic World Ski Championships" FROM table_21698 WHERE "Holmenkollen" = '1976'
SELECT "FIS Nordic World Ski Championships" FROM "table_21698" WHERE "Holmenkollen" = '1976'
0.089844
CREATE TABLE Dorm (dormid INT, dorm_name VARCHAR, student_capacity INT, gender VARCHAR) CREATE TABLE Has_amenity (dormid INT, amenid INT) CREATE TABLE Lives_in (stuid INT, dormid INT, room_number INT) CREATE TABLE Student (StuID INT, LName VARCHAR, Fname VARCHAR, Age INT, Sex VARCHAR, Major INT, Advisor INT, city_code VARCHAR) CREATE TABLE Dorm_amenity (amenid INT, amenity_name VARCHAR)
Return a bar chart on how many students are older than 20 in each dorm?, and I want to rank in ascending by the Y.
SELECT dorm_name, COUNT(*) FROM Student AS T1 JOIN Lives_in AS T2 ON T1.stuid = T2.stuid JOIN Dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.Age > 20 GROUP BY T3.dorm_name ORDER BY COUNT(*)
SELECT "dorm_name", COUNT(*) FROM "Student" AS "T1" JOIN "Lives_in" AS "T2" ON "T1"."stuid" = "T2"."stuid" JOIN "Dorm" AS "T3" ON "T2"."dormid" = "T3"."dormid" WHERE "T1"."Age" > 20 GROUP BY "T3"."dorm_name" ORDER BY COUNT(*) NULLS FIRST
0.231445
CREATE TABLE table_name_70 (host_team VARCHAR, stadium VARCHAR)
What is the host team with the stadium Lincoln Financial Field?
SELECT host_team FROM table_name_70 WHERE stadium = "lincoln financial field"
SELECT "host_team" FROM "table_name_70" WHERE "lincoln financial field" = "stadium"
0.081055
CREATE TABLE table_75974 ("Season" TEXT, "Nationality" TEXT, "Player" TEXT, "Club" TEXT, "League" TEXT, "Goals" FLOAT, "Points" TEXT)
Which league's nationality was Italy when there were 62 points?
SELECT "League" FROM table_75974 WHERE "Nationality" = 'italy' AND "Points" = '62'
SELECT "League" FROM "table_75974" WHERE "Nationality" = 'italy' AND "Points" = '62'
0.082031
CREATE TABLE table_name_18 (runs VARCHAR, year VARCHAR)
How many runs happened in 2013?
SELECT runs FROM table_name_18 WHERE year = "2013"
SELECT "runs" FROM "table_name_18" WHERE "2013" = "year"
0.054688
CREATE TABLE table_26577 ("Processor" TEXT, "Brand name" TEXT, "Model ( list ) " TEXT, "Cores" FLOAT, "L2 Cache" TEXT, "Socket" TEXT, "TDP" TEXT)
Whats the processor for p9xxx?
SELECT "Processor" FROM table_26577 WHERE "Model (list)" = 'P9xxx'
SELECT "Processor" FROM "table_26577" WHERE "Model (list)" = 'P9xxx'
0.066406
CREATE TABLE head (name VARCHAR, born_state VARCHAR)
What are the names of the heads who are born outside the California state?
SELECT name FROM head WHERE born_state <> 'California'
SELECT "name" FROM "head" WHERE "born_state" <> 'California'
0.058594
CREATE TABLE table_16409 ("Pick #" FLOAT, "CFL Team" TEXT, "Player" TEXT, "Position" TEXT, "College" TEXT)
What is the cfl team with ryan folk?
SELECT "CFL Team" FROM table_16409 WHERE "Player" = 'Ryan Folk'
SELECT "CFL Team" FROM "table_16409" WHERE "Player" = 'Ryan Folk'
0.063477
CREATE TABLE table_name_71 (constructor VARCHAR, circuit VARCHAR)
Who is the constructor whose circuit was Oulton Park?
SELECT constructor FROM table_name_71 WHERE circuit = "oulton park"
SELECT "constructor" FROM "table_name_71" WHERE "circuit" = "oulton park"
0.071289
CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME)
has amio been administered to patient 030-42006 on 12/27/this year?
SELECT COUNT(*) > 0 FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-42006')) AND intakeoutput.cellpath LIKE '%intake%' AND intakeoutput.celllabel = 'amio' AND DATETIME(intakeoutput.intakeoutputtime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND STRFTIME('%m-%d', intakeoutput.intakeoutputtime) = '12-27'
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '030-42006' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid") SELECT COUNT(*) > 0 FROM "intakeoutput" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "intakeoutput"."patientunitstayid" WHERE "intakeoutput"."celllabel" = 'amio' AND "intakeoutput"."cellpath" LIKE '%intake%' AND DATETIME("intakeoutput"."intakeoutputtime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') AND NOT "_u_1"."" IS NULL AND STRFTIME('%m-%d', "intakeoutput"."intakeoutputtime") = '12-27'
0.756836
CREATE TABLE table_name_53 (road_team VARCHAR, home_team VARCHAR, result VARCHAR)
What is the road team of the game with Philadelphia as the home team with a result of 105-102?
SELECT road_team FROM table_name_53 WHERE home_team = "philadelphia" AND result = "105-102"
SELECT "road_team" FROM "table_name_53" WHERE "105-102" = "result" AND "home_team" = "philadelphia"
0.09668
CREATE TABLE Department_Stores (dept_store_id INT, dept_store_chain_id INT, store_name VARCHAR, store_address VARCHAR, store_phone VARCHAR, store_email VARCHAR) CREATE TABLE Order_Items (order_item_id INT, order_id INT, product_id INT) CREATE TABLE Customer_Addresses (customer_id INT, address_id INT, date_from DATETIME, date_to DATETIME) CREATE TABLE Department_Store_Chain (dept_store_chain_id INT, dept_store_chain_name VARCHAR) CREATE TABLE Products (product_id INT, product_type_code VARCHAR, product_name VARCHAR, product_price DECIMAL) CREATE TABLE Addresses (address_id INT, address_details VARCHAR) CREATE TABLE Staff (staff_id INT, staff_gender VARCHAR, staff_name VARCHAR) CREATE TABLE Customers (customer_id INT, payment_method_code VARCHAR, customer_code VARCHAR, customer_name VARCHAR, customer_address VARCHAR, customer_phone VARCHAR, customer_email VARCHAR) CREATE TABLE Supplier_Addresses (supplier_id INT, address_id INT, date_from DATETIME, date_to DATETIME) CREATE TABLE Customer_Orders (order_id INT, customer_id INT, order_status_code VARCHAR, order_date DATETIME) CREATE TABLE Product_Suppliers (product_id INT, supplier_id INT, date_supplied_from DATETIME, date_supplied_to DATETIME, total_amount_purchased VARCHAR, total_value_purchased DECIMAL) CREATE TABLE Staff_Department_Assignments (staff_id INT, department_id INT, date_assigned_from DATETIME, job_title_code VARCHAR, date_assigned_to DATETIME) CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR, supplier_phone VARCHAR) CREATE TABLE Departments (department_id INT, dept_store_id INT, department_name VARCHAR)
What is the lowest price of product, grouped by product type? Show a bar chart, and show by the X-axis from high to low.
SELECT product_type_code, MIN(product_price) FROM Products GROUP BY product_type_code ORDER BY product_type_code DESC
SELECT "product_type_code", MIN("product_price") FROM "Products" GROUP BY "product_type_code" ORDER BY "product_type_code" DESC NULLS LAST
0.134766
CREATE TABLE table_name_91 (date VARCHAR, catalog VARCHAR, country VARCHAR, format VARCHAR)
What is the Date when the Country shows uk, the Format is cd, and the Catalog of edcd 227?
SELECT date FROM table_name_91 WHERE country = "uk" AND format = "cd" AND catalog = "edcd 227"
SELECT "date" FROM "table_name_91" WHERE "catalog" = "edcd 227" AND "cd" = "format" AND "country" = "uk"
0.101563
CREATE TABLE d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE prescriptions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, startdate TIME, enddate TIME, drug TEXT, dose_val_rx TEXT, dose_unit_rx TEXT, route TEXT) CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) CREATE TABLE admissions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, admittime TIME, dischtime TIME, admission_type TEXT, admission_location TEXT, discharge_location TEXT, insurance TEXT, language TEXT, marital_status TEXT, ethnicity TEXT, age DECIMAL) CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT) CREATE TABLE chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE transfers (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, eventtype TEXT, careunit TEXT, wardid DECIMAL, intime TIME, outtime TIME) CREATE TABLE icustays (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, first_careunit TEXT, last_careunit TEXT, first_wardid DECIMAL, last_wardid DECIMAL, intime TIME, outtime TIME) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME) CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
when did patient 3273 get an intake, the last time on 10/14/last year?
SELECT inputevents_cv.charttime FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3273)) AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m-%d', inputevents_cv.charttime) = '10-14' ORDER BY inputevents_cv.charttime DESC LIMIT 1
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 3273 GROUP BY "hadm_id"), "_u_1" AS (SELECT "icustays"."icustay_id" FROM "icustays" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "icustays"."hadm_id" WHERE NOT "_u_0"."" IS NULL GROUP BY "icustay_id") SELECT "inputevents_cv"."charttime" FROM "inputevents_cv" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "inputevents_cv"."icustay_id" WHERE DATETIME("inputevents_cv"."charttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND NOT "_u_1"."" IS NULL AND STRFTIME('%m-%d', "inputevents_cv"."charttime") = '10-14' ORDER BY "inputevents_cv"."charttime" DESC NULLS LAST LIMIT 1
0.675781
CREATE TABLE PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL) CREATE TABLE SuggestedEdits (Id DECIMAL, PostId DECIMAL, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId DECIMAL, Comment TEXT, Text TEXT, Title TEXT, Tags TEXT, RevisionGUID other) CREATE TABLE ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN) CREATE TABLE TagSynonyms (Id DECIMAL, SourceTagName TEXT, TargetTagName TEXT, CreationDate TIME, OwnerUserId DECIMAL, AutoRenameCount DECIMAL, LastAutoRename TIME, Score DECIMAL, ApprovedByUserId DECIMAL, ApprovalDate TIME) CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME) CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL) CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL) CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT) CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT) CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT) CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE PostHistory (Id DECIMAL, PostHistoryTypeId DECIMAL, PostId DECIMAL, RevisionGUID other, CreationDate TIME, UserId DECIMAL, UserDisplayName TEXT, Comment TEXT, Text TEXT, ContentLicense TEXT) CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL) CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL) CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL) CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT) CREATE TABLE CloseAsOffTopicReasonTypes (Id DECIMAL, IsUniversal BOOLEAN, InputTitle TEXT, MarkdownInputGuidance TEXT, MarkdownPostOwnerGuidance TEXT, MarkdownPrivilegedUserGuidance TEXT, MarkdownConcensusDescription TEXT, CreationDate TIME, CreationModeratorId DECIMAL, ApprovalDate TIME, ApprovalModeratorId DECIMAL, DeactivationDate TIME, DeactivationModeratorId DECIMAL) CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT) CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Users (Id DECIMAL, Reputation DECIMAL, CreationDate TIME, DisplayName TEXT, LastAccessDate TIME, WebsiteUrl TEXT, Location TEXT, AboutMe TEXT, Views DECIMAL, UpVotes DECIMAL, DownVotes DECIMAL, ProfileImageUrl TEXT, EmailHash TEXT, AccountId DECIMAL) CREATE TABLE Posts (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE PostsWithDeleted (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId DECIMAL) CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL) CREATE TABLE PostTypes (Id DECIMAL, Name TEXT) CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
Users Who Favorited a Post.
SELECT U.DisplayName FROM Votes AS V INNER JOIN Users AS U ON V.UserId = U.Id WHERE V.PostId = 9395 AND V.VoteTypeId = 5
SELECT "U"."DisplayName" FROM "Votes" AS "V" JOIN "Users" AS "U" ON "U"."Id" = "V"."UserId" WHERE "V"."PostId" = 9395 AND "V"."VoteTypeId" = 5
0.138672
CREATE TABLE Products (Code INT, Name VARCHAR, Price DECIMAL, Manufacturer INT) CREATE TABLE Manufacturers (Code INT, Name VARCHAR, Headquarter VARCHAR, Founder VARCHAR, Revenue FLOAT)
What are the names and the accumulated prices of all products in the store Plot them as a bar chart, show by the total number from high to low please.
SELECT Name, SUM(Price) FROM Products GROUP BY Name ORDER BY SUM(Price) DESC
SELECT "Name", SUM("Price") FROM "Products" GROUP BY "Name" ORDER BY SUM("Price") DESC NULLS LAST
0.094727
CREATE TABLE Activity (actid INT, activity_name VARCHAR) CREATE TABLE Faculty_Participates_in (FacID INT, actid INT) CREATE TABLE Student (StuID INT, LName VARCHAR, Fname VARCHAR, Age INT, Sex VARCHAR, Major INT, Advisor INT, city_code VARCHAR) CREATE TABLE Faculty (FacID INT, Lname VARCHAR, Fname VARCHAR, Rank VARCHAR, Sex VARCHAR, Phone INT, Room VARCHAR, Building VARCHAR) CREATE TABLE Participates_in (stuid INT, actid INT)
A bar chart showing the number of male and female faculty.
SELECT Sex, COUNT(*) FROM Faculty GROUP BY Sex
SELECT "Sex", COUNT(*) FROM "Faculty" GROUP BY "Sex"
0.050781
CREATE TABLE table_17697 ("Year" FLOAT, "Winner" TEXT, "Winning Hand" TEXT, "Prize Money" TEXT, "Entrants" FLOAT, "Runner-Up" TEXT, "Losing Hand" TEXT)
When Fabrizio Baldassari is the runner-up what is the total prize money?
SELECT "Prize Money" FROM table_17697 WHERE "Runner-Up" = 'Fabrizio Baldassari'
SELECT "Prize Money" FROM "table_17697" WHERE "Runner-Up" = 'Fabrizio Baldassari'
0.079102
CREATE TABLE table_name_17 (call_sign VARCHAR, power__kw_ VARCHAR)
What's the call sign that has 20kw of power?
SELECT call_sign FROM table_name_17 WHERE power__kw_ = "20kw"
SELECT "call_sign" FROM "table_name_17" WHERE "20kw" = "power__kw_"
0.06543
CREATE TABLE table_7712 ("Season" TEXT, "Competition" TEXT, "Round" TEXT, "Opponent" TEXT, "Home" TEXT, "Away" TEXT, "Agg." TEXT)
What was the aggregate total for the match against Koper?
SELECT "Agg." FROM table_7712 WHERE "Opponent" = 'koper'
SELECT "Agg." FROM "table_7712" WHERE "Opponent" = 'koper'
0.056641
CREATE TABLE table_17228 ("State" TEXT, "Norwegian Americans ( 1980 ) " FLOAT, "Percent ( 1980 ) " TEXT, "Norwegian Americans ( 1990 ) " FLOAT, "Percent ( 1990 ) " TEXT, "Norwegian Americans ( 2000 ) " FLOAT, "Percent ( 2000 ) " TEXT, "Norwegian Americans ( 2009 ) " FLOAT, "Percent ( 2009 ) " TEXT)
what are all the percent (1990) where state is mississippi
SELECT "Percent (1990)" FROM table_17228 WHERE "State" = 'Mississippi'
SELECT "Percent (1990)" FROM "table_17228" WHERE "State" = 'Mississippi'
0.070313
CREATE TABLE stadium (ID INT, name TEXT, Capacity INT, City TEXT, Country TEXT, Opening_year INT) CREATE TABLE record (ID INT, Result TEXT, Swimmer_ID INT, Event_ID INT) CREATE TABLE event (ID INT, Name TEXT, Stadium_ID INT, Year TEXT) CREATE TABLE swimmer (ID INT, name TEXT, Nationality TEXT, meter_100 FLOAT, meter_200 TEXT, meter_300 TEXT, meter_400 TEXT, meter_500 TEXT, meter_600 TEXT, meter_700 TEXT, Time TEXT)
Give me the comparison about the average of meter_100 over the Nationality , and group by attribute Nationality by a bar chart, and display by the y-axis in ascending.
SELECT Nationality, AVG(meter_100) FROM swimmer GROUP BY Nationality ORDER BY AVG(meter_100)
SELECT "Nationality", AVG("meter_100") FROM "swimmer" GROUP BY "Nationality" ORDER BY AVG("meter_100") NULLS FIRST
0.111328
CREATE TABLE table_204_929 (id DECIMAL, "location" TEXT, "name of mill and\ grid reference" TEXT, "type" TEXT, "maps" TEXT, "first mention\ or built" TEXT, "last mention\ or demise" DECIMAL)
how many mills were mentioned or built before 1700 ?
SELECT COUNT(*) FROM table_204_929 WHERE "first mention\nor built" < 1700
SELECT COUNT(*) FROM "table_204_929" WHERE "first mention\nor built" < 1700
0.073242
CREATE TABLE table_51916 ("Home team" TEXT, "Home team score" TEXT, "Away team" TEXT, "Away team score" TEXT, "Venue" TEXT, "Crowd" FLOAT, "Date" TEXT)
Who was the away team when they scored 12.9 (81) at the game?
SELECT "Away team" FROM table_51916 WHERE "Away team score" = '12.9 (81)'
SELECT "Away team" FROM "table_51916" WHERE "Away team score" = '12.9 (81)'
0.073242
CREATE TABLE table_2400842_1 (directed_by VARCHAR, prod__number VARCHAR)
Who directed the epsiode with production number 109?
SELECT directed_by FROM table_2400842_1 WHERE prod__number = 109
SELECT "directed_by" FROM "table_2400842_1" WHERE "prod__number" = 109
0.068359
CREATE TABLE table_37507 ("Year" FLOAT, "Division" FLOAT, "League" TEXT, "Regular Season" TEXT, "Playoffs" TEXT)
What is the highest division for years earlier than 2011?
SELECT MAX("Division") FROM table_37507 WHERE "Year" < '2011'
SELECT MAX("Division") FROM "table_37507" WHERE "Year" < '2011'
0.061523
CREATE TABLE table_23813 ("Country" TEXT, "Contestant" TEXT, "Age" FLOAT, "Height ( cm ) " FLOAT, "Height ( ft ) " TEXT, "Hometown" TEXT)
How tall is the contestant from Ecuador?
SELECT "Height (ft)" FROM table_23813 WHERE "Country" = 'Ecuador'
SELECT "Height (ft)" FROM "table_23813" WHERE "Country" = 'Ecuador'
0.06543
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
what is minimum age of patients whose marital status is married and admission location is phys referral/normal deli?
SELECT MIN(demographic.age) FROM demographic WHERE demographic.marital_status = "MARRIED" AND demographic.admission_location = "PHYS REFERRAL/NORMAL DELI"
SELECT MIN("demographic"."age") FROM "demographic" WHERE "MARRIED" = "demographic"."marital_status" AND "PHYS REFERRAL/NORMAL DELI" = "demographic"."admission_location"
0.164063
CREATE TABLE PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL) CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL) CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN) CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT) CREATE TABLE SuggestedEdits (Id DECIMAL, PostId DECIMAL, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId DECIMAL, Comment TEXT, Text TEXT, Title TEXT, Tags TEXT, RevisionGUID other) CREATE TABLE Posts (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE CloseAsOffTopicReasonTypes (Id DECIMAL, IsUniversal BOOLEAN, InputTitle TEXT, MarkdownInputGuidance TEXT, MarkdownPostOwnerGuidance TEXT, MarkdownPrivilegedUserGuidance TEXT, MarkdownConcensusDescription TEXT, CreationDate TIME, CreationModeratorId DECIMAL, ApprovalDate TIME, ApprovalModeratorId DECIMAL, DeactivationDate TIME, DeactivationModeratorId DECIMAL) CREATE TABLE PostsWithDeleted (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL) CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME) CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL) CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT) CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL) CREATE TABLE PostTypes (Id DECIMAL, Name TEXT) CREATE TABLE Users (Id DECIMAL, Reputation DECIMAL, CreationDate TIME, DisplayName TEXT, LastAccessDate TIME, WebsiteUrl TEXT, Location TEXT, AboutMe TEXT, Views DECIMAL, UpVotes DECIMAL, DownVotes DECIMAL, ProfileImageUrl TEXT, EmailHash TEXT, AccountId DECIMAL) CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT) CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL) CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT) CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId DECIMAL) CREATE TABLE ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL) CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL) CREATE TABLE TagSynonyms (Id DECIMAL, SourceTagName TEXT, TargetTagName TEXT, CreationDate TIME, OwnerUserId DECIMAL, AutoRenameCount DECIMAL, LastAutoRename TIME, Score DECIMAL, ApprovedByUserId DECIMAL, ApprovalDate TIME) CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT) CREATE TABLE PostHistory (Id DECIMAL, PostHistoryTypeId DECIMAL, PostId DECIMAL, RevisionGUID other, CreationDate TIME, UserId DECIMAL, UserDisplayName TEXT, Comment TEXT, Text TEXT, ContentLicense TEXT) CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT)
Select top 50k posts by view count.
SELECT * FROM Posts WHERE Posts.ViewCount < 14329 ORDER BY Posts.ViewCount DESC LIMIT 50000
SELECT * FROM "Posts" WHERE "Posts"."ViewCount" < 14329 ORDER BY "Posts"."ViewCount" DESC NULLS LAST LIMIT 50000
0.109375
CREATE TABLE course (course_id INT, name VARCHAR, department VARCHAR, number VARCHAR, credits VARCHAR, advisory_requirement VARCHAR, enforced_requirement VARCHAR, description VARCHAR, num_semesters INT, num_enrolled INT, has_discussion VARCHAR, has_lab VARCHAR, has_projects VARCHAR, has_exams VARCHAR, num_reviews INT, clarity_score INT, easiness_score INT, helpfulness_score INT) CREATE TABLE requirement (requirement_id INT, requirement VARCHAR, college VARCHAR) CREATE TABLE program_course (program_id INT, course_id INT, workload INT, category VARCHAR) CREATE TABLE program (program_id INT, name VARCHAR, college VARCHAR, introduction VARCHAR) CREATE TABLE gsi (course_offering_id INT, student_id INT) CREATE TABLE student_record (student_id INT, course_id INT, semester INT, grade VARCHAR, how VARCHAR, transfer_source VARCHAR, earn_credit VARCHAR, repeat_term VARCHAR, test_id VARCHAR) CREATE TABLE ta (campus_job_id INT, student_id INT, location VARCHAR) CREATE TABLE student (student_id INT, lastname VARCHAR, firstname VARCHAR, program_id INT, declare_major VARCHAR, total_credit INT, total_gpa FLOAT, entered_as VARCHAR, admit_term INT, predicted_graduation_semester INT, degree VARCHAR, minor VARCHAR, internship VARCHAR) CREATE TABLE comment_instructor (instructor_id INT, student_id INT, score INT, comment_text VARCHAR) CREATE TABLE course_prerequisite (pre_course_id INT, course_id INT) CREATE TABLE offering_instructor (offering_instructor_id INT, offering_id INT, instructor_id INT) CREATE TABLE area (course_id INT, area VARCHAR) CREATE TABLE jobs (job_id INT, job_title VARCHAR, description VARCHAR, requirement VARCHAR, city VARCHAR, state VARCHAR, country VARCHAR, zip INT) CREATE TABLE instructor (instructor_id INT, name VARCHAR, uniqname VARCHAR) CREATE TABLE semester (semester_id INT, semester VARCHAR, year INT) CREATE TABLE program_requirement (program_id INT, category VARCHAR, min_credit INT, additional_req VARCHAR) CREATE TABLE course_offering (offering_id INT, course_id INT, semester INT, section_number INT, start_time TIME, end_time TIME, monday VARCHAR, tuesday VARCHAR, wednesday VARCHAR, thursday VARCHAR, friday VARCHAR, saturday VARCHAR, sunday VARCHAR, has_final_project VARCHAR, has_final_exam VARCHAR, textbook VARCHAR, class_address VARCHAR, allow_audit VARCHAR) CREATE TABLE course_tags_count (course_id INT, clear_grading INT, pop_quiz INT, group_projects INT, inspirational INT, long_lectures INT, extra_credit INT, few_tests INT, good_feedback INT, tough_tests INT, heavy_papers INT, cares_for_students INT, heavy_assignments INT, respected INT, participation INT, heavy_reading INT, tough_grader INT, hilarious INT, would_take_again INT, good_lecture INT, no_skip INT)
Which professors have given PSYCH minors a B- in their class ?
SELECT DISTINCT instructor.name FROM instructor INNER JOIN offering_instructor ON offering_instructor.instructor_id = instructor.instructor_id INNER JOIN student_record ON student_record.offering_id = offering_instructor.offering_id INNER JOIN student ON student.student_id = student_record.student_id WHERE (student_record.grade LIKE '%B-%' OR student_record.grade LIKE '%B-%') AND student.minor = 'PSYCH'
SELECT DISTINCT "instructor"."name" FROM "instructor" JOIN "offering_instructor" ON "instructor"."instructor_id" = "offering_instructor"."instructor_id" JOIN "student_record" ON "offering_instructor"."offering_id" = "student_record"."offering_id" AND "student_record"."grade" LIKE '%B-%' JOIN "student" ON "student"."minor" = 'PSYCH' AND "student"."student_id" = "student_record"."student_id"
0.382813
CREATE TABLE Apartments (apt_id INT, building_id INT, apt_type_code CHAR, apt_number CHAR, bathroom_count INT, bedroom_count INT, room_count CHAR) CREATE TABLE Apartment_Buildings (building_id INT, building_short_name CHAR, building_full_name VARCHAR, building_description VARCHAR, building_address VARCHAR, building_manager VARCHAR, building_phone VARCHAR) CREATE TABLE Apartment_Facilities (apt_id INT, facility_code CHAR) CREATE TABLE Apartment_Bookings (apt_booking_id INT, apt_id INT, guest_id INT, booking_status_code CHAR, booking_start_date DATETIME, booking_end_date DATETIME) CREATE TABLE Guests (guest_id INT, gender_code CHAR, guest_first_name VARCHAR, guest_last_name VARCHAR, date_of_birth DATETIME) CREATE TABLE View_Unit_Status (apt_id INT, apt_booking_id INT, status_date DATETIME, available_yn BIT)
Show the number of the facility codes of apartments with more than 4 bedrooms, and rank in descending by the X-axis please.
SELECT facility_code, COUNT(facility_code) FROM Apartment_Facilities AS T1 JOIN Apartments AS T2 ON T1.apt_id = T2.apt_id WHERE T2.bedroom_count > 4 GROUP BY facility_code ORDER BY facility_code DESC
SELECT "facility_code", COUNT("facility_code") FROM "Apartment_Facilities" AS "T1" JOIN "Apartments" AS "T2" ON "T1"."apt_id" = "T2"."apt_id" AND "T2"."bedroom_count" > 4 GROUP BY "facility_code" ORDER BY "facility_code" DESC NULLS LAST
0.230469
CREATE TABLE table_6436 ("Year" FLOAT, "Class" TEXT, "Vehicle" TEXT, "Position" TEXT, "Stages won" TEXT)
What year did he compete in the car class and win 0 stages?
SELECT "Year" FROM table_6436 WHERE "Class" = 'car' AND "Stages won" = '0'
SELECT "Year" FROM "table_6436" WHERE "Class" = 'car' AND "Stages won" = '0'
0.074219
CREATE TABLE people (People_ID INT, Sex TEXT, Name TEXT, Date_of_Birth TEXT, Height FLOAT, Weight FLOAT) CREATE TABLE candidate (Candidate_ID INT, People_ID INT, Poll_Source TEXT, Date TEXT, Support_rate FLOAT, Consider_rate FLOAT, Oppose_rate FLOAT, Unsure_rate FLOAT)
A bar chart shows the distribution of Sex and the average of Weight , and group by attribute Sex, and could you show in ascending by the X-axis?
SELECT Sex, AVG(Weight) FROM people GROUP BY Sex ORDER BY Sex
SELECT "Sex", AVG("Weight") FROM "people" GROUP BY "Sex" ORDER BY "Sex" NULLS FIRST
0.081055
CREATE TABLE table_17573 ("Condition" TEXT, "Prothrombin time" TEXT, "Partial thromboplastin time" TEXT, "Bleeding time" TEXT, "Platelet count" TEXT)
Is uremia affect prothrombin?
SELECT "Prothrombin time" FROM table_17573 WHERE "Condition" = 'Uremia'
SELECT "Prothrombin time" FROM "table_17573" WHERE "Condition" = 'Uremia'
0.071289
CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME)
what are the three most frequent procedures among the patients 40s until 2 years ago?
SELECT t1.treatmentname FROM (SELECT treatment.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM treatment WHERE treatment.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.age BETWEEN 40 AND 49) AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-2 year') GROUP BY treatment.treatmentname) AS t1 WHERE t1.c1 <= 3
WITH "_u_0" AS (SELECT "patient"."patientunitstayid" FROM "patient" WHERE "patient"."age" <= 49 AND "patient"."age" >= 40 GROUP BY "patientunitstayid"), "t1" AS (SELECT "treatment"."treatmentname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC NULLS LAST) AS "c1" FROM "treatment" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "treatment"."patientunitstayid" WHERE DATETIME("treatment"."treatmenttime") <= DATETIME(CURRENT_TIME(), '-2 year') AND NOT "_u_0"."" IS NULL GROUP BY "treatment"."treatmentname") SELECT "t1"."treatmentname" FROM "t1" AS "t1" WHERE "t1"."c1" <= 3
0.550781
CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT)
did patient 030-34260 receive s/p knee surgery - replacement diagnosis when they visited the hospital first time?
SELECT COUNT(*) > 0 FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '030-34260' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) AND diagnosis.diagnosisname = 's/p knee surgery - replacement'
SELECT COUNT(*) > 0 FROM "diagnosis" WHERE "diagnosis"."diagnosisname" = 's/p knee surgery - replacement' AND "diagnosis"."patientunitstayid" IN (SELECT "patient"."patientunitstayid" FROM "patient" WHERE "patient"."patienthealthsystemstayid" IN (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '030-34260' AND NOT "patient"."hospitaldischargetime" IS NULL ORDER BY "patient"."hospitaladmittime" NULLS FIRST LIMIT 1))
0.447266
CREATE TABLE table_31192 ("Skip ( Club ) " TEXT, "W" FLOAT, "L" FLOAT, "PF" FLOAT, "PA" FLOAT, "Ends Won" FLOAT, "Ends Lost" FLOAT, "Blank Ends" FLOAT, "Stolen Ends" FLOAT)
What is maximum loss record when the pa record is 47?
SELECT MAX("L") FROM table_31192 WHERE "PA" = '47'
SELECT MAX("L") FROM "table_31192" WHERE "PA" = '47'
0.050781
CREATE TABLE table_66404 ("Game" FLOAT, "Date" TEXT, "Opponent" TEXT, "Score" TEXT, "Location/Attendance" TEXT, "Series" TEXT)
What is the game number on April 7?
SELECT COUNT("Game") FROM table_66404 WHERE "Date" = 'april 7'
SELECT COUNT("Game") FROM "table_66404" WHERE "Date" = 'april 7'
0.0625
CREATE TABLE Apartment_Bookings (apt_booking_id INT, apt_id INT, guest_id INT, booking_status_code CHAR, booking_start_date DATETIME, booking_end_date DATETIME) CREATE TABLE Guests (guest_id INT, gender_code CHAR, guest_first_name VARCHAR, guest_last_name VARCHAR, date_of_birth DATETIME) CREATE TABLE Apartment_Facilities (apt_id INT, facility_code CHAR) CREATE TABLE Apartment_Buildings (building_id INT, building_short_name CHAR, building_full_name VARCHAR, building_description VARCHAR, building_address VARCHAR, building_manager VARCHAR, building_phone VARCHAR) CREATE TABLE View_Unit_Status (apt_id INT, apt_booking_id INT, status_date DATETIME, available_yn BIT) CREATE TABLE Apartments (apt_id INT, building_id INT, apt_type_code CHAR, apt_number CHAR, bathroom_count INT, bedroom_count INT, room_count CHAR)
Show the number of bookings for different guests and group by guest first name in a bar chart, rank by the total number from low to high.
SELECT guest_first_name, COUNT(guest_first_name) FROM Apartment_Bookings AS T1 JOIN Guests AS T2 ON T1.guest_id = T2.guest_id GROUP BY guest_first_name ORDER BY COUNT(guest_first_name)
SELECT "guest_first_name", COUNT("guest_first_name") FROM "Apartment_Bookings" AS "T1" JOIN "Guests" AS "T2" ON "T1"."guest_id" = "T2"."guest_id" GROUP BY "guest_first_name" ORDER BY COUNT("guest_first_name") NULLS FIRST
0.214844
CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME)
count the number of times patient 002-39247 has been tested for creatinine in labs since 51 months ago.
SELECT COUNT(*) FROM lab WHERE lab.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-39247')) AND lab.labname = 'creatinine' AND DATETIME(lab.labresulttime) >= DATETIME(CURRENT_TIME(), '-51 month')
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '002-39247' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid") SELECT COUNT(*) FROM "lab" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "lab"."patientunitstayid" WHERE "lab"."labname" = 'creatinine' AND DATETIME("lab"."labresulttime") >= DATETIME(CURRENT_TIME(), '-51 month') AND NOT "_u_1"."" IS NULL
0.578125
CREATE TABLE table_name_44 (format VARCHAR, date VARCHAR)
Which Format has a Date of may 24, 2008?
SELECT format FROM table_name_44 WHERE date = "may 24, 2008"
SELECT "format" FROM "table_name_44" WHERE "date" = "may 24, 2008"
0.064453
CREATE TABLE table_name_70 (city_location VARCHAR, pole_position VARCHAR, winning_driver VARCHAR)
Where did Rick Mears win, after starting in Pole Position?
SELECT city_location FROM table_name_70 WHERE pole_position = "rick mears" AND winning_driver = "rick mears"
SELECT "city_location" FROM "table_name_70" WHERE "pole_position" = "rick mears" AND "rick mears" = "winning_driver"
0.113281
CREATE TABLE table_name_79 (score VARCHAR, january VARCHAR, record VARCHAR)
Which Score has January larger than 18 and a Record of 35 15 1?
SELECT score FROM table_name_79 WHERE january > 18 AND record = "35–15–1"
SELECT "score" FROM "table_name_79" WHERE "35–15–1" = "record" AND "january" > 18
0.079102
CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT)
in this year, how many patients were prescribed with potassium chloride inj within 2 months after having undergone vte prophylaxis - compression boots.
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'vte prophylaxis - compression boots' AND DATETIME(treatment.treatmenttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT patient.uniquepid, medication.drugstarttime FROM medication JOIN patient ON medication.patientunitstayid = patient.patientunitstayid WHERE medication.drugname = 'potassium chloride inj' AND DATETIME(medication.drugstarttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 WHERE t1.treatmenttime < t2.drugstarttime AND DATETIME(t2.drugstarttime) BETWEEN DATETIME(t1.treatmenttime) AND DATETIME(t1.treatmenttime, '+2 month')
SELECT COUNT(DISTINCT "patient"."uniquepid") FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" JOIN "medication" ON "medication"."drugname" = 'potassium chloride inj' AND "medication"."drugstarttime" > "treatment"."treatmenttime" AND DATETIME("medication"."drugstarttime") <= DATETIME("treatment"."treatmenttime", '+2 month') AND DATETIME("medication"."drugstarttime") >= DATETIME("treatment"."treatmenttime") AND DATETIME("medication"."drugstarttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') JOIN "patient" AS "patient_2" ON "medication"."patientunitstayid" = "patient_2"."patientunitstayid" WHERE "treatment"."treatmentname" = 'vte prophylaxis - compression boots' AND DATETIME("treatment"."treatmenttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
0.84082
CREATE TABLE table_name_72 (fa_cup INT, name VARCHAR, total VARCHAR)
What is the average number of goals scored in the FA Cup by Whelan where he had more than 7 total goals?
SELECT AVG(fa_cup) FROM table_name_72 WHERE name = "whelan" AND total > 7
SELECT AVG("fa_cup") FROM "table_name_72" WHERE "name" = "whelan" AND "total" > 7
0.079102
CREATE TABLE table_35436 ("Team" TEXT, "Outgoing manager" TEXT, "Manner of departure" TEXT, "Date of vacancy" TEXT, "Last match" TEXT, "Replaced by" TEXT)
What is the name of the last match that had a sacked manner of departure and a geninho outgoing manner?
SELECT "Last match" FROM table_35436 WHERE "Manner of departure" = 'sacked' AND "Outgoing manager" = 'geninho'
SELECT "Last match" FROM "table_35436" WHERE "Manner of departure" = 'sacked' AND "Outgoing manager" = 'geninho'
0.109375
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
count the number of patients who were born before the year 2182 whose lab test fluid is joint fluid.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dob_year < "2182" AND lab.fluid = "Joint Fluid"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "Joint Fluid" = "lab"."fluid" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "2182" > "demographic"."dob_year"
0.193359
CREATE TABLE order_items (order_id DECIMAL, product_id DECIMAL, order_quantity TEXT) CREATE TABLE addresses (address_id DECIMAL, address_content TEXT, city TEXT, zip_postcode TEXT, state_province_county TEXT, country TEXT, other_address_details TEXT) CREATE TABLE customers (customer_id DECIMAL, payment_method TEXT, customer_name TEXT, date_became_customer TIME, other_customer_details TEXT) CREATE TABLE customer_contact_channels (customer_id DECIMAL, channel_code TEXT, active_from_date TIME, active_to_date TIME, contact_number TEXT) CREATE TABLE products (product_id DECIMAL, product_details TEXT) CREATE TABLE customer_orders (order_id DECIMAL, customer_id DECIMAL, order_status TEXT, order_date TIME, order_details TEXT) CREATE TABLE customer_addresses (customer_id DECIMAL, address_id DECIMAL, date_address_from TIME, address_type TEXT, date_address_to TIME)
Find the city with post code 255.
SELECT city FROM addresses WHERE zip_postcode = 255
SELECT "city" FROM "addresses" WHERE "zip_postcode" = 255
0.055664
CREATE TABLE table_24798489_2 (challenge VARCHAR, episode_number VARCHAR)
What was the challenge for episode 28?
SELECT challenge FROM table_24798489_2 WHERE episode_number = 28
SELECT "challenge" FROM "table_24798489_2" WHERE "episode_number" = 28
0.068359
CREATE TABLE table_name_66 (location VARCHAR, record VARCHAR)
I want to know the location that has a record of 3-0
SELECT location FROM table_name_66 WHERE record = "3-0"
SELECT "location" FROM "table_name_66" WHERE "3-0" = "record"
0.05957
CREATE TABLE table_7904 ("Round" FLOAT, "Pick" FLOAT, "Player" TEXT, "Nationality" TEXT, "College" TEXT)
What round was northeastern college player Reggie Lewis drafted in?
SELECT MIN("Round") FROM table_7904 WHERE "College" = 'northeastern' AND "Player" = 'reggie lewis'
SELECT MIN("Round") FROM "table_7904" WHERE "College" = 'northeastern' AND "Player" = 'reggie lewis'
0.097656
CREATE TABLE table_27565 ("Facility" TEXT, "Location" TEXT, "Year Opened" TEXT, "Major Facility" TEXT, "Population Gender" TEXT, "Capacity" FLOAT, "Custody Level ( s ) " TEXT)
What is the custody level of the facility in Shelton?
SELECT "Custody Level(s)" FROM table_27565 WHERE "Location" = 'Shelton'
SELECT "Custody Level(s)" FROM "table_27565" WHERE "Location" = 'Shelton'
0.071289
CREATE TABLE table_name_54 (chinese__traditional_ VARCHAR, label VARCHAR, english_title VARCHAR)
What traditional Chinese name would the Rock Records release Grown up Overnight be given?
SELECT chinese__traditional_ FROM table_name_54 WHERE label = "rock records" AND english_title = "grown up overnight"
SELECT "chinese__traditional_" FROM "table_name_54" WHERE "english_title" = "grown up overnight" AND "label" = "rock records"
0.12207
CREATE TABLE table_27978 ("No. in series" FLOAT, "Title" TEXT, "Directed by" TEXT, "Written by" TEXT, "Original air date" TEXT, "Production code" TEXT, "U.S. viewers ( million ) " TEXT)
What episode number in the series was viewed by 13.66 million people in the U.S.?
SELECT MAX("No. in series") FROM table_27978 WHERE "U.S. viewers (million)" = '13.66'
SELECT MAX("No. in series") FROM "table_27978" WHERE "U.S. viewers (million)" = '13.66'
0.084961
CREATE TABLE table_name_5 (total_freshwater_withdrawal__km_3__yr_ INT, industrial_use__m_3__p_yr__in__percentage_ VARCHAR, per_capita_withdrawal__m_3__p_yr_ VARCHAR)
What is the average Total Freshwater Withdrawal (km 3 /yr), when Industrial Use (m 3 /p/yr)(in %) is 337(63%), and when Per Capita Withdrawal (m 3 /p/yr) is greater than 535?
SELECT AVG(total_freshwater_withdrawal__km_3__yr_) FROM table_name_5 WHERE industrial_use__m_3__p_yr__in__percentage_ = "337(63%)" AND per_capita_withdrawal__m_3__p_yr_ > 535
SELECT AVG("total_freshwater_withdrawal__km_3__yr_") FROM "table_name_5" WHERE "337(63%)" = "industrial_use__m_3__p_yr__in__percentage_" AND "per_capita_withdrawal__m_3__p_yr_" > 535
0.177734
CREATE TABLE Manufacturers (Code INT, Name VARCHAR, Headquarter VARCHAR, Founder VARCHAR, Revenue FLOAT) CREATE TABLE Products (Code INT, Name VARCHAR, Price DECIMAL, Manufacturer INT)
Give me a bar chart to show the revenue of the company that earns the highest revenue in each headquarter city.
SELECT Headquarter, MAX(Revenue) FROM Manufacturers GROUP BY Headquarter
SELECT "Headquarter", MAX("Revenue") FROM "Manufacturers" GROUP BY "Headquarter"
0.078125
CREATE TABLE table_75095 ("Date" TEXT, "Opponent" TEXT, "Score" TEXT, "Loss" TEXT, "Save" TEXT)
The game that has a save of lynch (4) ended with what score?
SELECT "Score" FROM table_75095 WHERE "Save" = 'lynch (4)'
SELECT "Score" FROM "table_75095" WHERE "Save" = 'lynch (4)'
0.058594
CREATE TABLE CloseAsOffTopicReasonTypes (Id DECIMAL, IsUniversal BOOLEAN, InputTitle TEXT, MarkdownInputGuidance TEXT, MarkdownPostOwnerGuidance TEXT, MarkdownPrivilegedUserGuidance TEXT, MarkdownConcensusDescription TEXT, CreationDate TIME, CreationModeratorId DECIMAL, ApprovalDate TIME, ApprovalModeratorId DECIMAL, DeactivationDate TIME, DeactivationModeratorId DECIMAL) CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL) CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT) CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL) CREATE TABLE PostsWithDeleted (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL) CREATE TABLE PostHistory (Id DECIMAL, PostHistoryTypeId DECIMAL, PostId DECIMAL, RevisionGUID other, CreationDate TIME, UserId DECIMAL, UserDisplayName TEXT, Comment TEXT, Text TEXT, ContentLicense TEXT) CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT) CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL) CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL) CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL) CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT) CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE PostTypes (Id DECIMAL, Name TEXT) CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN) CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL) CREATE TABLE Posts (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT) CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME) CREATE TABLE ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId DECIMAL) CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Users (Id DECIMAL, Reputation DECIMAL, CreationDate TIME, DisplayName TEXT, LastAccessDate TIME, WebsiteUrl TEXT, Location TEXT, AboutMe TEXT, Views DECIMAL, UpVotes DECIMAL, DownVotes DECIMAL, ProfileImageUrl TEXT, EmailHash TEXT, AccountId DECIMAL) CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL) CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT) CREATE TABLE TagSynonyms (Id DECIMAL, SourceTagName TEXT, TargetTagName TEXT, CreationDate TIME, OwnerUserId DECIMAL, AutoRenameCount DECIMAL, LastAutoRename TIME, Score DECIMAL, ApprovedByUserId DECIMAL, ApprovalDate TIME) CREATE TABLE SuggestedEdits (Id DECIMAL, PostId DECIMAL, CreationDate TIME, ApprovalDate TIME, RejectionDate TIME, OwnerUserId DECIMAL, Comment TEXT, Text TEXT, Title TEXT, Tags TEXT, RevisionGUID other)
Post Vote History By Month.
SELECT years.number AS "year", months.number AS "month" FROM master.spt_values AS months CROSS JOIN master.spt_values AS years WHERE months.number BETWEEN 1 AND 12 AND months.type = 'P' AND years.type = 'P' AND years.number BETWEEN 2008 AND YEAR(CURRENT_TIMESTAMP())
SELECT "years"."number" AS "year", "months"."number" AS "month" FROM "master"."spt_values" AS "months" JOIN "master"."spt_values" AS "years" ON "years"."number" <= YEAR(CURRENT_TIMESTAMP()) AND "years"."number" >= 2008 AND "years"."type" = 'P' WHERE "months"."number" <= 12 AND "months"."number" >= 1 AND "months"."type" = 'P'
0.318359
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
specify the insurance and death status of patient id 8990?
SELECT demographic.insurance, demographic.expire_flag FROM demographic WHERE demographic.subject_id = "8990"
SELECT "demographic"."insurance", "demographic"."expire_flag" FROM "demographic" WHERE "8990" = "demographic"."subject_id"
0.119141
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
what is maximum age of patients whose admission type is emergency and days of hospital stay is 2?
SELECT MAX(demographic.age) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.days_stay = "2"
SELECT MAX("demographic"."age") FROM "demographic" WHERE "2" = "demographic"."days_stay" AND "EMERGENCY" = "demographic"."admission_type"
0.133789
CREATE TABLE table_49028 ("Week" FLOAT, "Date" TEXT, "Opponent" TEXT, "Result" TEXT, "Attendance" FLOAT)
What is the highest Attendance, when Result is l 26-16, and when Week is less than 12?
SELECT MAX("Attendance") FROM table_49028 WHERE "Result" = 'l 26-16' AND "Week" < '12'
SELECT MAX("Attendance") FROM "table_49028" WHERE "Result" = 'l 26-16' AND "Week" < '12'
0.085938
CREATE TABLE table_12303563_2 (runners_up VARCHAR, nation VARCHAR)
what's the runners-up with nation being malaysia
SELECT runners_up FROM table_12303563_2 WHERE nation = "Malaysia"
SELECT "runners_up" FROM "table_12303563_2" WHERE "Malaysia" = "nation"
0.069336
CREATE TABLE regions (REGION_ID DECIMAL, REGION_NAME VARCHAR) CREATE TABLE departments (DEPARTMENT_ID DECIMAL, DEPARTMENT_NAME VARCHAR, MANAGER_ID DECIMAL, LOCATION_ID DECIMAL) CREATE TABLE locations (LOCATION_ID DECIMAL, STREET_ADDRESS VARCHAR, POSTAL_CODE VARCHAR, CITY VARCHAR, STATE_PROVINCE VARCHAR, COUNTRY_ID VARCHAR) CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_ID DECIMAL) CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID DECIMAL) CREATE TABLE jobs (JOB_ID VARCHAR, JOB_TITLE VARCHAR, MIN_SALARY DECIMAL, MAX_SALARY DECIMAL) CREATE TABLE employees (EMPLOYEE_ID DECIMAL, FIRST_NAME VARCHAR, LAST_NAME VARCHAR, EMAIL VARCHAR, PHONE_NUMBER VARCHAR, HIRE_DATE DATE, JOB_ID VARCHAR, SALARY DECIMAL, COMMISSION_PCT DECIMAL, MANAGER_ID DECIMAL, DEPARTMENT_ID DECIMAL)
Group and count the state province attribute of the location table to visualize a bar chart, and show in descending by the y axis.
SELECT STATE_PROVINCE, COUNT(STATE_PROVINCE) FROM locations GROUP BY STATE_PROVINCE ORDER BY COUNT(STATE_PROVINCE) DESC
SELECT "STATE_PROVINCE", COUNT("STATE_PROVINCE") FROM "locations" GROUP BY "STATE_PROVINCE" ORDER BY COUNT("STATE_PROVINCE") DESC NULLS LAST
0.136719
CREATE TABLE table_20525 ("Channel" FLOAT, "Band" TEXT, "Video Frequency" TEXT, "Audio Frequency" TEXT, "Station" TEXT, "Network" TEXT, "Transmission" TEXT, "Format" TEXT, "Status" TEXT)
What station on the network is tv3?
SELECT "Network" FROM table_20525 WHERE "Station" = 'TV3'
SELECT "Network" FROM "table_20525" WHERE "Station" = 'TV3'
0.057617
CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME)
what change was in patient 009-5001's sao2 second measured on the current icu visit compared to the first value measured on the current icu visit?
SELECT (SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1 OFFSET 1) - (SELECT vitalperiodic.sao2 FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '009-5001') AND patient.unitdischargetime IS NULL) AND NOT vitalperiodic.sao2 IS NULL ORDER BY vitalperiodic.observationtime LIMIT 1)
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '009-5001' GROUP BY "patienthealthsystemstayid"), "_u_1" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE "patient"."unitdischargetime" IS NULL AND NOT "_u_0"."" IS NULL GROUP BY "patientunitstayid"), "_u_4" AS (SELECT "patient"."patientunitstayid" FROM "patient" LEFT JOIN "_u_0" AS "_u_3" ON "_u_3"."" = "patient"."patienthealthsystemstayid" WHERE "patient"."unitdischargetime" IS NULL AND NOT "_u_3"."" IS NULL GROUP BY "patientunitstayid") SELECT (SELECT "vitalperiodic"."sao2" FROM "vitalperiodic" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "vitalperiodic"."patientunitstayid" WHERE NOT "_u_1"."" IS NULL AND NOT "vitalperiodic"."sao2" IS NULL ORDER BY "vitalperiodic"."observationtime" NULLS FIRST LIMIT 1 OFFSET 1) - (SELECT "vitalperiodic"."sao2" FROM "vitalperiodic" LEFT JOIN "_u_4" AS "_u_4" ON "_u_4"."" = "vitalperiodic"."patientunitstayid" WHERE NOT "_u_4"."" IS NULL AND NOT "vitalperiodic"."sao2" IS NULL ORDER BY "vitalperiodic"."observationtime" NULLS FIRST LIMIT 1)
1.154297
CREATE TABLE table_76764 ("Date" TEXT, "Venue" TEXT, "Score" TEXT, "Result" TEXT, "Competition" TEXT)
What Competition had a Score of 2 0?
SELECT "Competition" FROM table_76764 WHERE "Score" = '2–0'
SELECT "Competition" FROM "table_76764" WHERE "Score" = '2–0'
0.05957
CREATE TABLE table_2562572_54 (population__2011_ INT, settlement VARCHAR)
What is the lowest population in 2011 for the settlement of ortanovci?
SELECT MIN(population__2011_) FROM table_2562572_54 WHERE settlement = "Čortanovci"
SELECT MIN("population__2011_") FROM "table_2562572_54" WHERE "settlement" = "Čortanovci"
0.086914
CREATE TABLE table_name_57 (chinese_title VARCHAR, album_number VARCHAR)
Album # of 3rd is what chinese title?
SELECT chinese_title FROM table_name_57 WHERE album_number = "3rd"
SELECT "chinese_title" FROM "table_name_57" WHERE "3rd" = "album_number"
0.070313
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
what is the maximum days of hospital stay for female patients ?
SELECT MAX(demographic.days_stay) FROM demographic WHERE demographic.gender = "F"
SELECT MAX("demographic"."days_stay") FROM "demographic" WHERE "F" = "demographic"."gender"
0.088867
CREATE TABLE table_4575 ("Commodity" TEXT, "2001-02" TEXT, "2002-03" TEXT, "2003-04" TEXT, "2004-05" TEXT, "2005-06" TEXT, "2006-07" TEXT)
What was the production in 2006-07 for the commodity that produced 2,601 in 2005-06?
SELECT "2006-07" FROM table_4575 WHERE "2005-06" = '2,601'
SELECT "2006-07" FROM "table_4575" WHERE "2005-06" = '2,601'
0.058594
CREATE TABLE table_54350 ("Round" FLOAT, "Pick" FLOAT, "Player" TEXT, "Position" TEXT, "Nationality" TEXT, "School/Club Team" TEXT)
What nationality is Demetris Nichols?
SELECT "Nationality" FROM table_54350 WHERE "Player" = 'demetris nichols'
SELECT "Nationality" FROM "table_54350" WHERE "Player" = 'demetris nichols'
0.073242
CREATE TABLE comment_instructor (instructor_id INT, student_id INT, score INT, comment_text VARCHAR) CREATE TABLE course_prerequisite (pre_course_id INT, course_id INT) CREATE TABLE jobs (job_id INT, job_title VARCHAR, description VARCHAR, requirement VARCHAR, city VARCHAR, state VARCHAR, country VARCHAR, zip INT) CREATE TABLE student_record (student_id INT, course_id INT, semester INT, grade VARCHAR, how VARCHAR, transfer_source VARCHAR, earn_credit VARCHAR, repeat_term VARCHAR, test_id VARCHAR) CREATE TABLE course_tags_count (course_id INT, clear_grading INT, pop_quiz INT, group_projects INT, inspirational INT, long_lectures INT, extra_credit INT, few_tests INT, good_feedback INT, tough_tests INT, heavy_papers INT, cares_for_students INT, heavy_assignments INT, respected INT, participation INT, heavy_reading INT, tough_grader INT, hilarious INT, would_take_again INT, good_lecture INT, no_skip INT) CREATE TABLE course_offering (offering_id INT, course_id INT, semester INT, section_number INT, start_time TIME, end_time TIME, monday VARCHAR, tuesday VARCHAR, wednesday VARCHAR, thursday VARCHAR, friday VARCHAR, saturday VARCHAR, sunday VARCHAR, has_final_project VARCHAR, has_final_exam VARCHAR, textbook VARCHAR, class_address VARCHAR, allow_audit VARCHAR) CREATE TABLE offering_instructor (offering_instructor_id INT, offering_id INT, instructor_id INT) CREATE TABLE gsi (course_offering_id INT, student_id INT) CREATE TABLE program_course (program_id INT, course_id INT, workload INT, category VARCHAR) CREATE TABLE instructor (instructor_id INT, name VARCHAR, uniqname VARCHAR) CREATE TABLE program (program_id INT, name VARCHAR, college VARCHAR, introduction VARCHAR) CREATE TABLE requirement (requirement_id INT, requirement VARCHAR, college VARCHAR) CREATE TABLE program_requirement (program_id INT, category VARCHAR, min_credit INT, additional_req VARCHAR) CREATE TABLE course (course_id INT, name VARCHAR, department VARCHAR, number VARCHAR, credits VARCHAR, advisory_requirement VARCHAR, enforced_requirement VARCHAR, description VARCHAR, num_semesters INT, num_enrolled INT, has_discussion VARCHAR, has_lab VARCHAR, has_projects VARCHAR, has_exams VARCHAR, num_reviews INT, clarity_score INT, easiness_score INT, helpfulness_score INT) CREATE TABLE semester (semester_id INT, semester VARCHAR, year INT) CREATE TABLE student (student_id INT, lastname VARCHAR, firstname VARCHAR, program_id INT, declare_major VARCHAR, total_credit INT, total_gpa FLOAT, entered_as VARCHAR, admit_term INT, predicted_graduation_semester INT, degree VARCHAR, minor VARCHAR, internship VARCHAR) CREATE TABLE ta (campus_job_id INT, student_id INT, location VARCHAR) CREATE TABLE area (course_id INT, area VARCHAR)
Which EECS upper-level classes are being offered this Summer ?
SELECT DISTINCT course.department, course.name, course.number FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND course.department = 'EECS' AND program_course.category LIKE '%ULCS%' AND program_course.course_id = course.course_id AND semester.semester = 'Summer' AND semester.semester_id = course_offering.semester AND semester.year = 2016
SELECT DISTINCT "course"."department", "course"."name", "course"."number" FROM "course" JOIN "course_offering" ON "course"."course_id" = "course_offering"."course_id" JOIN "program_course" ON "course"."course_id" = "program_course"."course_id" AND "program_course"."category" LIKE '%ULCS%' JOIN "semester" ON "course_offering"."semester" = "semester"."semester_id" AND "semester"."semester" = 'Summer' AND "semester"."year" = 2016 WHERE "course"."department" = 'EECS'
0.456055
CREATE TABLE architect (id TEXT, name TEXT, nationality TEXT, gender TEXT) CREATE TABLE bridge (architect_id DECIMAL, id DECIMAL, name TEXT, location TEXT, length_meters DECIMAL, length_feet DECIMAL) CREATE TABLE mill (architect_id DECIMAL, id DECIMAL, location TEXT, name TEXT, type TEXT, built_year DECIMAL, notes TEXT)
What are the ids, names and genders of the architects who built two bridges or one mill?
SELECT T1.id, T1.name, T1.gender FROM architect AS T1 JOIN bridge AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING COUNT(*) = 2 UNION SELECT T1.id, T1.name, T1.gender FROM architect AS T1 JOIN mill AS T2 ON T1.id = T2.architect_id GROUP BY T1.id HAVING COUNT(*) = 1
SELECT "T1"."id", "T1"."name", "T1"."gender" FROM "architect" AS "T1" JOIN "bridge" AS "T2" ON "T1"."id" = "T2"."architect_id" GROUP BY "T1"."id" HAVING COUNT(*) = 2 UNION SELECT "T1"."id", "T1"."name", "T1"."gender" FROM "architect" AS "T1" JOIN "mill" AS "T2" ON "T1"."id" = "T2"."architect_id" GROUP BY "T1"."id" HAVING COUNT(*) = 1
0.327148
CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL)
what is the three most frequent procedures that patients have received within the same hospital visit after they have been diagnosed with cellulitis until 2104?
SELECT t3.treatmentname FROM (SELECT t2.treatmentname, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'cellulitis' AND STRFTIME('%y', diagnosis.diagnosistime) <= '2104') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmentname, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE STRFTIME('%y', treatment.treatmenttime) <= '2104') AS t2 ON t1.uniquepid = t2.uniquepid WHERE t1.diagnosistime < t2.treatmenttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid GROUP BY t2.treatmentname) AS t3 WHERE t3.c1 <= 3
WITH "t2" AS (SELECT "patient"."uniquepid", "treatment"."treatmentname", "treatment"."treatmenttime", "patient"."patienthealthsystemstayid" FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" WHERE STRFTIME('%y', "treatment"."treatmenttime") <= '2104'), "t3" AS (SELECT "t2"."treatmentname", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC NULLS LAST) AS "c1" FROM "diagnosis" JOIN "patient" ON "diagnosis"."patientunitstayid" = "patient"."patientunitstayid" JOIN "t2" AS "t2" ON "diagnosis"."diagnosistime" < "t2"."treatmenttime" AND "patient"."patienthealthsystemstayid" = "t2"."patienthealthsystemstayid" AND "patient"."uniquepid" = "t2"."uniquepid" WHERE "diagnosis"."diagnosisname" = 'cellulitis' AND STRFTIME('%y', "diagnosis"."diagnosistime") <= '2104' GROUP BY "t2"."treatmentname") SELECT "t3"."treatmentname" FROM "t3" AS "t3" WHERE "t3"."c1" <= 3
0.876953
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
what is average age of patients whose gender is m and age is greater than or equal to 30?
SELECT AVG(demographic.age) FROM demographic WHERE demographic.gender = "M" AND demographic.age >= "30"
SELECT AVG("demographic"."age") FROM "demographic" WHERE "30" <= "demographic"."age" AND "M" = "demographic"."gender"
0.114258
CREATE TABLE Ref_Transaction_Types (transaction_type_description VARCHAR, transaction_type_code VARCHAR) CREATE TABLE TRANSACTIONS (transaction_type_code VARCHAR)
Show the description of the transaction type that occurs most frequently.
SELECT T1.transaction_type_description FROM Ref_Transaction_Types AS T1 JOIN TRANSACTIONS AS T2 ON T1.transaction_type_code = T2.transaction_type_code GROUP BY T1.transaction_type_code ORDER BY COUNT(*) DESC LIMIT 1
SELECT "T1"."transaction_type_description" FROM "Ref_Transaction_Types" AS "T1" JOIN "TRANSACTIONS" AS "T2" ON "T1"."transaction_type_code" = "T2"."transaction_type_code" GROUP BY "T1"."transaction_type_code" ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1
0.244141
CREATE TABLE table_54068 ("Name" TEXT, "Coaching career" TEXT, "Played" FLOAT, "Drawn" FLOAT, "Lost" FLOAT, "Win %" FLOAT, "Points per game" FLOAT)
How many games were lost where the win percentage is smaller than 16.7 and the played games is 3?
SELECT COUNT("Lost") FROM table_54068 WHERE "Win %" < '16.7' AND "Played" = '3'
SELECT COUNT("Lost") FROM "table_54068" WHERE "Played" = '3' AND "Win %" < '16.7'
0.079102
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
get me the number of patients born before 2103 who had atrial cardioversion procedure.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2103" AND procedures.short_title = "Atrial cardioversion"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "procedures" ON "Atrial cardioversion" = "procedures"."short_title" AND "demographic"."hadm_id" = "procedures"."hadm_id" WHERE "2103" > "demographic"."dob_year"
0.228516
CREATE TABLE table_name_94 (player VARCHAR, year_s__won VARCHAR)
Player than won in 2003?
SELECT player FROM table_name_94 WHERE year_s__won = "2003"
SELECT "player" FROM "table_name_94" WHERE "2003" = "year_s__won"
0.063477
CREATE TABLE enzyme (id DECIMAL, name TEXT, location TEXT, product TEXT, chromosome TEXT, omim DECIMAL, porphyria TEXT) CREATE TABLE medicine_enzyme_interaction (enzyme_id DECIMAL, medicine_id DECIMAL, interaction_type TEXT) CREATE TABLE medicine (id DECIMAL, name TEXT, trade_name TEXT, fda_approved TEXT)
What are the ids and names of the medicine that can interact with two or more enzymes?
SELECT T1.id, T1.name FROM medicine AS T1 JOIN medicine_enzyme_interaction AS T2 ON T2.medicine_id = T1.id GROUP BY T1.id HAVING COUNT(*) >= 2
SELECT "T1"."id", "T1"."name" FROM "medicine" AS "T1" JOIN "medicine_enzyme_interaction" AS "T2" ON "T1"."id" = "T2"."medicine_id" GROUP BY "T1"."id" HAVING COUNT(*) >= 2
0.166016
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
what is the number of patients who had other endoscopy of small intestine and died on or before 2115?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dod_year <= "2115.0" AND procedures.long_title = "Other endoscopy of small intestine"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "procedures" ON "Other endoscopy of small intestine" = "procedures"."long_title" AND "demographic"."hadm_id" = "procedures"."hadm_id" WHERE "2115.0" >= "demographic"."dod_year"
0.244141
CREATE TABLE View_Unit_Status (apt_id INT, apt_booking_id INT, status_date DATETIME, available_yn BIT) CREATE TABLE Apartment_Bookings (apt_booking_id INT, apt_id INT, guest_id INT, booking_status_code CHAR, booking_start_date DATETIME, booking_end_date DATETIME) CREATE TABLE Apartments (apt_id INT, building_id INT, apt_type_code CHAR, apt_number CHAR, bathroom_count INT, bedroom_count INT, room_count CHAR) CREATE TABLE Apartment_Buildings (building_id INT, building_short_name CHAR, building_full_name VARCHAR, building_description VARCHAR, building_address VARCHAR, building_manager VARCHAR, building_phone VARCHAR) CREATE TABLE Apartment_Facilities (apt_id INT, facility_code CHAR) CREATE TABLE Guests (guest_id INT, gender_code CHAR, guest_first_name VARCHAR, guest_last_name VARCHAR, date_of_birth DATETIME)
Show me a bar chart for what are the apartment number and the room count of each apartment?, list in asc by the bar.
SELECT apt_number, room_count FROM Apartments ORDER BY apt_number
SELECT "apt_number", "room_count" FROM "Apartments" ORDER BY "apt_number" NULLS FIRST
0.083008
CREATE TABLE table_11539 ("State" TEXT, "Interview" FLOAT, "Swimsuit" FLOAT, "Evening Gown" FLOAT, "Average" FLOAT)
What is the greatest interview that has a swimsuit less than 8.838?
SELECT MAX("Interview") FROM table_11539 WHERE "Swimsuit" < '8.838'
SELECT MAX("Interview") FROM "table_11539" WHERE "Swimsuit" < '8.838'
0.067383
CREATE TABLE table_56426 ("Home team" TEXT, "Home team score" TEXT, "Away team" TEXT, "Away team score" TEXT, "Venue" TEXT, "Crowd" FLOAT, "Date" TEXT)
Who was the home side at glenferrie oval?
SELECT "Home team" FROM table_56426 WHERE "Venue" = 'glenferrie oval'
SELECT "Home team" FROM "table_56426" WHERE "Venue" = 'glenferrie oval'
0.069336
CREATE TABLE table_26303 ("Vehicle code" TEXT, "Bore ( mm ) " TEXT, "Stroke ( mm ) " TEXT, "Capacity ( cm 3 ) " FLOAT, "Compression ratio" TEXT, "Torque ( N m ) " FLOAT, "Power ( HP ) " FLOAT)
what is the vehicle code where the bore is 79.4?
SELECT "Vehicle code" FROM table_26303 WHERE "Bore (mm)" = '79.4'
SELECT "Vehicle code" FROM "table_26303" WHERE "Bore (mm)" = '79.4'
0.06543
CREATE TABLE table_name_16 (year INT, gold VARCHAR)
What was the earliest year that Park Jung-Ah won the gold?
SELECT MIN(year) FROM table_name_16 WHERE gold = "park jung-ah"
SELECT MIN("year") FROM "table_name_16" WHERE "gold" = "park jung-ah"
0.067383