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 diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
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)
|
let me know the location of admission and days for which walter locher stayed in hospital.
|
SELECT demographic.days_stay, demographic.admission_location FROM demographic WHERE demographic.name = "Walter Locher"
|
SELECT "demographic"."days_stay", "demographic"."admission_location" FROM "demographic" WHERE "Walter Locher" = "demographic"."name"
| 0.128906 |
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 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)
CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime 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 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)
|
how many patients were diagnosed with hemorrhage in the same hospital visit after having undergone neurosurgery - drainage of hematoma-burr hole until 2 years ago?
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'neurosurgery - drainage of hematoma-burr hole' AND DATETIME(treatment.treatmenttime) <= DATETIME(CURRENT_TIME(), '-2 year')) AS t1 JOIN (SELECT patient.uniquepid, diagnosis.diagnosistime, patient.patienthealthsystemstayid FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'hemorrhage' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-2 year')) AS t2 WHERE t1.treatmenttime < t2.diagnosistime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
WITH "t2" AS (SELECT "diagnosis"."diagnosistime", "patient"."patienthealthsystemstayid" FROM "diagnosis" JOIN "patient" ON "diagnosis"."patientunitstayid" = "patient"."patientunitstayid" WHERE "diagnosis"."diagnosisname" = 'hemorrhage' AND DATETIME("diagnosis"."diagnosistime") <= DATETIME(CURRENT_TIME(), '-2 year')) SELECT COUNT(DISTINCT "patient"."uniquepid") FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" JOIN "t2" AS "t2" ON "patient"."patienthealthsystemstayid" = "t2"."patienthealthsystemstayid" AND "t2"."diagnosistime" > "treatment"."treatmenttime" WHERE "treatment"."treatmentname" = 'neurosurgery - drainage of hematoma-burr hole' AND DATETIME("treatment"."treatmenttime") <= DATETIME(CURRENT_TIME(), '-2 year')
| 0.756836 |
CREATE TABLE table_name_23 (track VARCHAR, time VARCHAR)
|
What track has a time of 2:30?
|
SELECT track FROM table_name_23 WHERE time = "2:30"
|
SELECT "track" FROM "table_name_23" WHERE "2:30" = "time"
| 0.055664 |
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
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)
|
how many of the male patients were diagnosed with sarcoidosis?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.gender = "M" AND diagnoses.long_title = "Sarcoidosis"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Sarcoidosis" = "diagnoses"."long_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "M" = "demographic"."gender"
| 0.210938 |
CREATE TABLE table_18047346_5 (airport_name VARCHAR, iata_code VARCHAR)
|
Which airport has an IATA Code of ORD?
|
SELECT airport_name FROM table_18047346_5 WHERE iata_code = "ORD"
|
SELECT "airport_name" FROM "table_18047346_5" WHERE "ORD" = "iata_code"
| 0.069336 |
CREATE TABLE table_204_337 (id DECIMAL, "festival" TEXT, "year" DECIMAL, "award" TEXT, "nominee" TEXT, "result" TEXT)
|
what is the name of the last festival ?
|
SELECT "festival" FROM table_204_337 ORDER BY "year" DESC LIMIT 1
|
SELECT "festival" FROM "table_204_337" ORDER BY "year" DESC NULLS LAST LIMIT 1
| 0.076172 |
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 d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto 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 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 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 labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom 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 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 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 d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT)
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 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 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)
|
how many times carbidopa-levodopa (25-100) was prescribed this year?
|
SELECT COUNT(*) FROM prescriptions WHERE prescriptions.drug = 'carbidopa-levodopa (25-100)' AND DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
|
SELECT COUNT(*) FROM "prescriptions" WHERE "prescriptions"."drug" = 'carbidopa-levodopa (25-100)' AND DATETIME("prescriptions"."startdate", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')
| 0.206055 |
CREATE TABLE table_37617 ("Goal" FLOAT, "Date" TEXT, "Venue" TEXT, "Score" TEXT, "Result" TEXT, "Competition" TEXT)
|
In what Venue was the game with a Friendly Competition and 1 Goal played?
|
SELECT "Venue" FROM table_37617 WHERE "Competition" = 'friendly' AND "Goal" = '1'
|
SELECT "Venue" FROM "table_37617" WHERE "Competition" = 'friendly' AND "Goal" = '1'
| 0.081055 |
CREATE TABLE table_11793221_4 (missing VARCHAR, commander VARCHAR)
|
What was the missing for lieutenant general sir thomas picton?
|
SELECT missing FROM table_11793221_4 WHERE commander = "Lieutenant General Sir Thomas Picton"
|
SELECT "missing" FROM "table_11793221_4" WHERE "Lieutenant General Sir Thomas Picton" = "commander"
| 0.09668 |
CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL)
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 d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title 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 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 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 chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT)
CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT)
CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL)
CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto 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 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 labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT)
CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
CREATE TABLE diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
|
how much insulin had been prescribed to patient 3929 in total this month?
|
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 3929) AND prescriptions.drug = 'insulin' AND DATETIME(prescriptions.startdate, 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month')
|
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 3929 GROUP BY "hadm_id") SELECT SUM("prescriptions"."dose_val_rx") FROM "prescriptions" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "prescriptions"."hadm_id" WHERE "prescriptions"."drug" = 'insulin' AND DATETIME("prescriptions"."startdate", 'start of month') = DATETIME(CURRENT_TIME(), 'start of month', '-0 month') AND NOT "_u_0"."" IS NULL
| 0.426758 |
CREATE TABLE table_200_12 (id DECIMAL, "year" TEXT, "award" TEXT, "category" TEXT, "nominated work" TEXT, "result" TEXT)
|
what award did once in a lifetime win ?
|
SELECT "category" FROM table_200_12 WHERE "nominated work" = 'once in a lifetime'
|
SELECT "category" FROM "table_200_12" WHERE "nominated work" = 'once in a lifetime'
| 0.081055 |
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 Ref_Locations (Location_Code CHAR, Location_Name VARCHAR, Location_Description VARCHAR)
CREATE TABLE Document_Locations (Document_ID INT, Location_Code CHAR, Date_in_Location_From DATETIME, Date_in_Locaton_To DATETIME)
CREATE TABLE Employees (Employee_ID INT, Role_Code CHAR, Employee_Name VARCHAR, Gender_MFU CHAR, Date_of_Birth DATETIME, Other_Details VARCHAR)
CREATE TABLE Roles (Role_Code CHAR, Role_Name VARCHAR, Role_Description VARCHAR)
CREATE TABLE Ref_Document_Types (Document_Type_Code CHAR, Document_Type_Name VARCHAR, Document_Type_Description VARCHAR)
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 Ref_Calendar (Calendar_Date DATETIME, Day_Number INT)
|
Return a histogram on what is the code of each role and the number of employees in each role?, sort x axis in desc order please.
|
SELECT Role_Code, COUNT(*) FROM Employees GROUP BY Role_Code ORDER BY Role_Code DESC
|
SELECT "Role_Code", COUNT(*) FROM "Employees" GROUP BY "Role_Code" ORDER BY "Role_Code" DESC NULLS LAST
| 0.100586 |
CREATE TABLE table_name_87 (record VARCHAR, visitor VARCHAR, date VARCHAR)
|
What was the team's record when they played visitor team Chicago Black Hawks on November 24?
|
SELECT record FROM table_name_87 WHERE visitor = "chicago black hawks" AND date = "november 24"
|
SELECT "record" FROM "table_name_87" WHERE "chicago black hawks" = "visitor" AND "date" = "november 24"
| 0.100586 |
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
|
how many of the male patients were diagnosed with malig neo tongue nec?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.gender = "M" AND diagnoses.short_title = "Malig neo tongue NEC"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "Malig neo tongue NEC" = "diagnoses"."short_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "M" = "demographic"."gender"
| 0.220703 |
CREATE TABLE table_67316 ("Date" TEXT, "Opponent" TEXT, "Score" TEXT, "Loss" TEXT, "Time" TEXT, "Att." TEXT, "Record" TEXT)
|
What was the record at the game against the Blue Jays with a loss of Batista (0 3)?
|
SELECT "Record" FROM table_67316 WHERE "Opponent" = 'blue jays' AND "Loss" = 'batista (0–3)'
|
SELECT "Record" FROM "table_67316" WHERE "Loss" = 'batista (0–3)' AND "Opponent" = 'blue jays'
| 0.091797 |
CREATE TABLE table_name_70 (player VARCHAR, to_par VARCHAR, score VARCHAR)
|
What is Player, when To Par is +1, and when Score is 72-70-72=214?
|
SELECT player FROM table_name_70 WHERE to_par = "+1" AND score = 72 - 70 - 72 = 214
|
SELECT "player" FROM "table_name_70" WHERE "+1" = "to_par" AND "score" = FALSE
| 0.076172 |
CREATE TABLE status (station_id INT, bikes_available INT, docks_available INT, time TEXT)
CREATE TABLE station (id INT, name TEXT, lat DECIMAL, long DECIMAL, dock_count INT, city TEXT, installation_date TEXT)
CREATE TABLE trip (id INT, duration INT, start_date TEXT, start_station_name TEXT, start_station_id INT, end_date TEXT, end_station_name TEXT, end_station_id INT, bike_id INT, subscription_type TEXT, zip_code INT)
CREATE TABLE weather (date TEXT, max_temperature_f INT, mean_temperature_f INT, min_temperature_f INT, max_dew_point_f INT, mean_dew_point_f INT, min_dew_point_f INT, max_humidity INT, mean_humidity INT, min_humidity INT, max_sea_level_pressure_inches DECIMAL, mean_sea_level_pressure_inches DECIMAL, min_sea_level_pressure_inches DECIMAL, max_visibility_miles INT, mean_visibility_miles INT, min_visibility_miles INT, max_wind_Speed_mph INT, mean_wind_speed_mph INT, max_gust_speed_mph INT, precipitation_inches INT, cloud_cover INT, events TEXT, wind_dir_degrees INT, zip_code INT)
|
Please give me a pie chart to show the proportion of end stations for the trips with the three smallest ids?
|
SELECT end_station_name, COUNT(end_station_name) FROM trip GROUP BY end_station_name ORDER BY id LIMIT 3
|
SELECT "end_station_name", COUNT("end_station_name") FROM "trip" GROUP BY "end_station_name" ORDER BY "id" NULLS FIRST LIMIT 3
| 0.123047 |
CREATE TABLE table_7725 ("Nat." TEXT, "Name" TEXT, "Moving from" TEXT, "Type" TEXT, "Transfer window" TEXT, "Ends" FLOAT, "Transfer fee" TEXT)
|
What was the transfer fee for the player ending in 2011 and moving from Thrasyvoulos?
|
SELECT "Transfer fee" FROM table_7725 WHERE "Ends" = '2011' AND "Moving from" = 'thrasyvoulos'
|
SELECT "Transfer fee" FROM "table_7725" WHERE "Ends" = '2011' AND "Moving from" = 'thrasyvoulos'
| 0.09375 |
CREATE TABLE table_name_13 (team_classification VARCHAR, points_classification VARCHAR, winner VARCHAR)
|
What is the team classification with a winner of Beat Zberg, and a points classification of Jos Mar a Jim nez.
|
SELECT team_classification FROM table_name_13 WHERE points_classification = "josé maría jiménez" AND winner = "beat zberg"
|
SELECT "team_classification" FROM "table_name_13" WHERE "beat zberg" = "winner" AND "josé maría jiménez" = "points_classification"
| 0.126953 |
CREATE TABLE table_52103 ("Week" FLOAT, "Date" TEXT, "Opponent" TEXT, "Result" TEXT, "Attendance" FLOAT)
|
Tell me the week for result of l 31-27, and an Attendance smaller than 85,865
|
SELECT AVG("Week") FROM table_52103 WHERE "Result" = 'l 31-27' AND "Attendance" < '85,865'
|
SELECT AVG("Week") FROM "table_52103" WHERE "Attendance" < '85,865' AND "Result" = 'l 31-27'
| 0.089844 |
CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME)
CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT)
CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL)
CREATE TABLE VoteTypes (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 Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
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 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 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 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 PostHistoryTypes (Id DECIMAL, Name TEXT)
CREATE TABLE PostTypes (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 CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL)
CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment 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 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 PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
CREATE TABLE PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL)
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)
|
Users with specific numbers of questions / answers.
|
SELECT userid AS "user_link", SUM(q) AS q, SUM(a) AS a FROM (SELECT OwnerUserId AS userid, COUNT(*) AS q, 0 AS a FROM Posts WHERE PostTypeId = 1 AND NOT OwnerUserId IS NULL GROUP BY OwnerUserId HAVING COUNT(*) > '##q##' UNION SELECT OwnerUserId, 0, COUNT(*) AS a FROM Posts WHERE PostTypeId = 2 AND NOT OwnerUserId IS NULL GROUP BY OwnerUserId HAVING COUNT(*) < '##a##') AS data GROUP BY userid HAVING SUM(q) > '##q##' AND SUM(a) < '##a##' ORDER BY SUM(a) DESC
|
WITH "data" AS (SELECT "OwnerUserId" AS "userid", COUNT(*) AS "q", 0 AS "a" FROM "Posts" WHERE "PostTypeId" = 1 AND NOT "OwnerUserId" IS NULL GROUP BY "OwnerUserId" HAVING COUNT(*) > '##q##' UNION SELECT "OwnerUserId", 0, COUNT(*) AS "a" FROM "Posts" WHERE "PostTypeId" = 2 AND NOT "OwnerUserId" IS NULL GROUP BY "OwnerUserId" HAVING COUNT(*) < '##a##') SELECT "userid" AS "user_link", SUM("q") AS "q", SUM("a") AS "a" FROM "data" AS "data" GROUP BY "userid" HAVING SUM("a") < '##a##' AND SUM("q") > '##q##' ORDER BY SUM("a") DESC NULLS LAST
| 0.52832 |
CREATE TABLE table_204_911 (id DECIMAL, "album / name" TEXT, "artist ( s ) " TEXT, "label" TEXT, "role/credit" TEXT, "date" TEXT, "chart#" TEXT)
|
who is the next artist after artist enomoto atsuko ?
|
SELECT "artist(s)" FROM table_204_911 WHERE "date" > (SELECT "date" FROM table_204_911 WHERE "artist(s)" = 'enomoto atsuko') ORDER BY "date" LIMIT 1
|
SELECT "artist(s)" FROM "table_204_911" WHERE "date" > (SELECT "date" FROM "table_204_911" WHERE "artist(s)" = 'enomoto atsuko') ORDER BY "date" NULLS FIRST LIMIT 1
| 0.160156 |
CREATE TABLE table_1748444_1 (builder VARCHAR, date_built VARCHAR)
|
Name the builder for date built is january 1910
|
SELECT builder FROM table_1748444_1 WHERE date_built = "January 1910"
|
SELECT "builder" FROM "table_1748444_1" WHERE "January 1910" = "date_built"
| 0.073242 |
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 PostTags (PostId DECIMAL, TagId 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 ReviewTaskResultTypes (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 PostHistory (Id DECIMAL, PostHistoryTypeId DECIMAL, PostId DECIMAL, RevisionGUID other, CreationDate TIME, UserId DECIMAL, UserDisplayName TEXT, Comment TEXT, Text TEXT, ContentLicense TEXT)
CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description 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 ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT)
CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT)
CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL)
CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
CREATE TABLE ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId DECIMAL)
CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL)
CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME)
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 PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL)
CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT)
CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId 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 PostTypes (Id DECIMAL, Name TEXT)
CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT)
CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
|
Top Tags for the month. This should give you the tags with the most questions per month, arranged in
|
SELECT t.TagName, COUNT(*) AS total FROM Posts AS p, Tags AS t, PostTags AS pt, PostTypes AS ptype WHERE pt.PostId = p.Id AND pt.TagId = t.Id AND p.PostTypeId = ptype.Id AND ptype.Name = 'Question' AND p.CreationDate >= '2015-10-01' AND p.CreationDate <= '2015-10-31' GROUP BY t.TagName ORDER BY total DESC
|
SELECT "t"."TagName", COUNT(*) AS "total" FROM "Posts" AS "p" JOIN "PostTags" AS "pt" ON "p"."Id" = "pt"."PostId" JOIN "PostTypes" AS "ptype" ON "p"."PostTypeId" = "ptype"."Id" AND "ptype"."Name" = 'Question' JOIN "Tags" AS "t" ON "pt"."TagId" = "t"."Id" WHERE "p"."CreationDate" <= '2015-10-31' AND "p"."CreationDate" >= '2015-10-01' GROUP BY "t"."TagName" ORDER BY "total" DESC NULLS LAST
| 0.380859 |
CREATE TABLE certificate (eid DECIMAL, aid DECIMAL)
CREATE TABLE employee (eid DECIMAL, name TEXT, salary DECIMAL)
CREATE TABLE flight (flno DECIMAL, origin TEXT, destination TEXT, distance DECIMAL, departure_date TIME, arrival_date TIME, price DECIMAL, aid DECIMAL)
CREATE TABLE aircraft (aid DECIMAL, name TEXT, distance DECIMAL)
|
What are the numbers of the shortest flights?
|
SELECT flno FROM flight ORDER BY distance LIMIT 3
|
SELECT "flno" FROM "flight" ORDER BY "distance" NULLS FIRST LIMIT 3
| 0.06543 |
CREATE TABLE table_48156 ("Season" TEXT, "Team" TEXT, "Country" TEXT, "Division" FLOAT, "Apps" FLOAT, "Goals" FLOAT)
|
What is the lowest Division, when Team is 'Benfica', and when Apps is 22?
|
SELECT MIN("Division") FROM table_48156 WHERE "Team" = 'benfica' AND "Apps" = '22'
|
SELECT MIN("Division") FROM "table_48156" WHERE "Apps" = '22' AND "Team" = 'benfica'
| 0.082031 |
CREATE TABLE table_name_88 (top_5 INT, cuts_made VARCHAR, events VARCHAR)
|
Which Top-5 is the lowest one that has Cuts made of 10, and Events larger than 10?
|
SELECT MIN(top_5) FROM table_name_88 WHERE cuts_made = 10 AND events > 10
|
SELECT MIN("top_5") FROM "table_name_88" WHERE "cuts_made" = 10 AND "events" > 10
| 0.079102 |
CREATE TABLE table_61437 ("Draft" FLOAT, "Round" FLOAT, "Pick" FLOAT, "Player" TEXT, "Nationality" TEXT)
|
What is the highest draft after round 2, is from the United States and has picked less than 113?
|
SELECT MAX("Draft") FROM table_61437 WHERE "Round" > '2' AND "Nationality" = 'united states' AND "Pick" < '113'
|
SELECT MAX("Draft") FROM "table_61437" WHERE "Nationality" = 'united states' AND "Pick" < '113' AND "Round" > '2'
| 0.110352 |
CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name 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 procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
CREATE TABLE patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME)
CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL)
CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label 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 cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL)
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 d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title 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 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 diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
CREATE TABLE d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT)
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)
CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT)
|
tell me the name of the medication that patient 14397 was last prescribed via the oral route during their last hospital visit?
|
SELECT prescriptions.drug FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 14397 AND NOT admissions.dischtime IS NULL ORDER BY admissions.admittime DESC LIMIT 1) AND prescriptions.route = 'oral' ORDER BY prescriptions.startdate DESC LIMIT 1
|
SELECT "prescriptions"."drug" FROM "prescriptions" WHERE "prescriptions"."hadm_id" IN (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 14397 AND NOT "admissions"."dischtime" IS NULL ORDER BY "admissions"."admittime" DESC NULLS LAST LIMIT 1) AND "prescriptions"."route" = 'oral' ORDER BY "prescriptions"."startdate" DESC NULLS LAST LIMIT 1
| 0.363281 |
CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL)
CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, 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 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 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 PostHistoryTypes (Id DECIMAL, Name TEXT)
CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL)
CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT)
CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
CREATE TABLE VoteTypes (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 ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT)
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 Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL)
CREATE TABLE PostTypes (Id DECIMAL, Name TEXT)
CREATE TABLE SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange 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 PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL)
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 ReviewTaskTypes (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 PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME)
CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
|
Question statistics for a single user.
|
SELECT 'Questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 UNION ALL SELECT 'Questions without accepted answer', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AcceptedAnswerId IS NULL UNION ALL SELECT 'Unanswered questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AnswerCount = 0 UNION ALL SELECT 'Resolved questions', COUNT(*) FROM Posts WHERE OwnerUserId = '##UserId:int##' AND PostTypeId = 1 AND AcceptedAnswerId > 0
|
SELECT 'Questions', COUNT(*) FROM "Posts" WHERE "OwnerUserId" = '##UserId:int##' AND "PostTypeId" = 1 UNION ALL SELECT 'Questions without accepted answer', COUNT(*) FROM "Posts" WHERE "AcceptedAnswerId" IS NULL AND "OwnerUserId" = '##UserId:int##' AND "PostTypeId" = 1 UNION ALL SELECT 'Unanswered questions', COUNT(*) FROM "Posts" WHERE "AnswerCount" = 0 AND "OwnerUserId" = '##UserId:int##' AND "PostTypeId" = 1 UNION ALL SELECT 'Resolved questions', COUNT(*) FROM "Posts" WHERE "AcceptedAnswerId" > 0 AND "OwnerUserId" = '##UserId:int##' AND "PostTypeId" = 1
| 0.547852 |
CREATE TABLE table_485 ("Season #" FLOAT, "Series #" FLOAT, "Title" TEXT, "Canadian airdate" TEXT, "U.S. airdate" TEXT, "Production code" FLOAT)
|
What is the total number of title with a u.s. air date of April 17, 2009
|
SELECT COUNT("Title") FROM table_485 WHERE "U.S. airdate" = 'April 17, 2009'
|
SELECT COUNT("Title") FROM "table_485" WHERE "U.S. airdate" = 'April 17, 2009'
| 0.076172 |
CREATE TABLE table_66286 ("Week" FLOAT, "Date" TEXT, "Opponent" TEXT, "Result" TEXT, "Attendance" FLOAT)
|
What was the highest week with a w 21-17 result, and more than 45,254 in attendance?
|
SELECT MAX("Week") FROM table_66286 WHERE "Result" = 'w 21-17' AND "Attendance" > '45,254'
|
SELECT MAX("Week") FROM "table_66286" WHERE "Attendance" > '45,254' AND "Result" = 'w 21-17'
| 0.089844 |
CREATE TABLE table_204_853 (id DECIMAL, "pos" DECIMAL, "grid" DECIMAL, "no." DECIMAL, "driver" TEXT, "team" TEXT, "manufacturer" TEXT, "laps" DECIMAL, "points" DECIMAL)
|
true of false . no drivers completed 160 laps ?
|
SELECT (SELECT COUNT("driver") FROM table_204_853 WHERE "laps" = 160) = 0
|
SELECT (SELECT COUNT("driver") FROM "table_204_853" WHERE "laps" = 160) = 0
| 0.073242 |
CREATE TABLE table_15235 ("Name" TEXT, "Years" TEXT, "A-League" TEXT, "Finals" TEXT, "Total" TEXT)
|
Which player had a total of 116 (22)?
|
SELECT "Name" FROM table_15235 WHERE "Total" = '116 (22)'
|
SELECT "Name" FROM "table_15235" WHERE "Total" = '116 (22)'
| 0.057617 |
CREATE TABLE table_73268 ("Gas name" TEXT, "Chemical formula" TEXT, "Lifetime ( years ) " TEXT, "20-yr" TEXT, "100-yr" TEXT, "500-yr" TEXT)
|
What is the 100 year when 500 year is 153?
|
SELECT "100-yr" FROM table_73268 WHERE "500-yr" = '153'
|
SELECT "100-yr" FROM "table_73268" WHERE "500-yr" = '153'
| 0.055664 |
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 Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT)
CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT)
CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT)
CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
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 ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
CREATE TABLE PostTypes (Id DECIMAL, Name TEXT)
CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL)
CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT)
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 SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange 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 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 CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT)
CREATE TABLE PostHistoryTypes (Id DECIMAL, Name 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 Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
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 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 PostTags (PostId DECIMAL, TagId DECIMAL)
CREATE TABLE ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT)
|
Up vs Down votes by hour of day of Question or Answer.
|
SELECT CASE WHEN PostTypeId = 1 THEN 'Question' ELSE 'Answer' END AS "post_type", TIME_TO_STR(p.CreationDate, '%-HOUR') AS Hour, COUNT(*) AS Amount, SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS UpVotes, SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS DownVotes, (CAST(SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS FLOAT) / CAST(SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS FLOAT)) AS UpVoteDownVoteRatio FROM Votes AS v JOIN Posts AS p ON v.PostId = p.Id WHERE PostTypeId IN (1, 2) AND VoteTypeId IN (2, 3) GROUP BY PostTypeId, TIME_TO_STR(p.CreationDate, '%-HOUR') ORDER BY PostTypeId, TIME_TO_STR(p.CreationDate, '%-HOUR')
|
SELECT CASE WHEN "PostTypeId" = 1 THEN 'Question' ELSE 'Answer' END AS "post_type", TO_CHAR(CAST("p"."CreationDate" AS TIMESTAMPNTZ), '%-HOUR') AS "Hour", COUNT(*) AS "Amount", SUM(CASE WHEN "VoteTypeId" = 2 THEN 1 ELSE 0 END) AS "UpVotes", SUM(CASE WHEN "VoteTypeId" = 3 THEN 1 ELSE 0 END) AS "DownVotes", CAST(SUM(CASE WHEN "VoteTypeId" = 2 THEN 1 ELSE 0 END) AS FLOAT) / NULLIF(CAST(SUM(CASE WHEN "VoteTypeId" = 3 THEN 1 ELSE 0 END) AS FLOAT), 0) AS "UpVoteDownVoteRatio" FROM "Votes" AS "v" JOIN "Posts" AS "p" ON "p"."Id" = "v"."PostId" WHERE "PostTypeId" IN (1, 2) AND "VoteTypeId" IN (2, 3) GROUP BY "PostTypeId", TO_CHAR(CAST("p"."CreationDate" AS TIMESTAMPNTZ), '%-HOUR') ORDER BY "PostTypeId" NULLS FIRST, TO_CHAR(CAST("p"."CreationDate" AS TIMESTAMPNTZ), '%-HOUR') NULLS FIRST
| 0.768555 |
CREATE TABLE table_10128185_2 (northern_ireland VARCHAR, total VARCHAR)
|
How many votes did Northern Ireland cast if the total was 35?
|
SELECT northern_ireland FROM table_10128185_2 WHERE total = 35
|
SELECT "northern_ireland" FROM "table_10128185_2" WHERE "total" = 35
| 0.066406 |
CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto 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 diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime 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 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 patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod 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 microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name 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 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 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 d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT)
CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL)
|
what are the five most frequently prescribed medicines since 5 years ago?
|
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE DATETIME(prescriptions.startdate) >= DATETIME(CURRENT_TIME(), '-5 year') GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
|
WITH "t1" AS (SELECT "prescriptions"."drug", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC NULLS LAST) AS "c1" FROM "prescriptions" WHERE DATETIME("prescriptions"."startdate") >= DATETIME(CURRENT_TIME(), '-5 year') GROUP BY "prescriptions"."drug") SELECT "t1"."drug" FROM "t1" AS "t1" WHERE "t1"."c1" <= 5
| 0.293945 |
CREATE TABLE table_name_17 (year_s__won VARCHAR, to_par VARCHAR)
|
The To par of +14 was won in what year(s)?
|
SELECT year_s__won FROM table_name_17 WHERE to_par = "+14"
|
SELECT "year_s__won" FROM "table_name_17" WHERE "+14" = "to_par"
| 0.0625 |
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE 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)
|
how many patients aged below 58 years have hypoxia as their primary disease?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "HYPOXIA" AND demographic.age < "58"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "58" > "demographic"."age" AND "HYPOXIA" = "demographic"."diagnosis"
| 0.139648 |
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE 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)
|
how many patients whose primary disease is transient ischemic attack?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "TRANSIENT ISCHEMIC ATTACK"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "TRANSIENT ISCHEMIC ATTACK" = "demographic"."diagnosis"
| 0.126953 |
CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime 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 lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME)
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 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 diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code 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)
|
how many patients received a reversal of neuromuscular blockade after the procedure of the glucocorticoid administration - parenteral in 2105 in the same hospital encounter?
|
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'glucocorticoid administration - parenteral' AND STRFTIME('%y', treatment.treatmenttime) = '2105') AS t1 JOIN (SELECT patient.uniquepid, treatment.treatmenttime, patient.patienthealthsystemstayid FROM treatment JOIN patient ON treatment.patientunitstayid = patient.patientunitstayid WHERE treatment.treatmentname = 'reversal of neuromuscular blockade' AND STRFTIME('%y', treatment.treatmenttime) = '2105') AS t2 WHERE t1.treatmenttime < t2.treatmenttime AND t1.patienthealthsystemstayid = t2.patienthealthsystemstayid
|
WITH "t2" AS (SELECT "treatment"."treatmenttime", "patient"."patienthealthsystemstayid" FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" WHERE "treatment"."treatmentname" = 'reversal of neuromuscular blockade' AND STRFTIME('%y', "treatment"."treatmenttime") = '2105') SELECT COUNT(DISTINCT "patient"."uniquepid") FROM "treatment" JOIN "patient" ON "patient"."patientunitstayid" = "treatment"."patientunitstayid" JOIN "t2" AS "t2" ON "patient"."patienthealthsystemstayid" = "t2"."patienthealthsystemstayid" AND "t2"."treatmenttime" > "treatment"."treatmenttime" WHERE "treatment"."treatmentname" = 'glucocorticoid administration - parenteral' AND STRFTIME('%y', "treatment"."treatmenttime") = '2105'
| 0.730469 |
CREATE TABLE table_68699 ("Res." TEXT, "Record" TEXT, "Opponent" TEXT, "Method" TEXT, "Event" TEXT, "Round" FLOAT, "Location" TEXT)
|
What round was the opponent Manny Gamburyan?
|
SELECT "Round" FROM table_68699 WHERE "Opponent" = 'manny gamburyan'
|
SELECT "Round" FROM "table_68699" WHERE "Opponent" = 'manny gamburyan'
| 0.068359 |
CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL)
CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT)
CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
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 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 patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME)
CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT)
CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title 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 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 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 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 microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT)
CREATE TABLE d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT)
|
let's count the number of patients who received a entral infus nutrit sub procedure within 2 months after receiving a contrast aortogram procedure until 2104.
|
SELECT COUNT(DISTINCT t1.subject_id) FROM (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'contrast aortogram') AND STRFTIME('%y', procedures_icd.charttime) <= '2104') AS t1 JOIN (SELECT admissions.subject_id, procedures_icd.charttime FROM procedures_icd JOIN admissions ON procedures_icd.hadm_id = admissions.hadm_id WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'entral infus nutrit sub') AND STRFTIME('%y', procedures_icd.charttime) <= '2104') AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t2.charttime) BETWEEN DATETIME(t1.charttime) AND DATETIME(t1.charttime, '+2 month')
|
WITH "t2" AS (SELECT "admissions"."subject_id", "procedures_icd"."charttime" FROM "procedures_icd" JOIN "d_icd_procedures" ON "d_icd_procedures"."icd9_code" = "procedures_icd"."icd9_code" AND "d_icd_procedures"."short_title" = 'entral infus nutrit sub' JOIN "admissions" ON "admissions"."hadm_id" = "procedures_icd"."hadm_id" WHERE STRFTIME('%y', "procedures_icd"."charttime") <= '2104') SELECT COUNT(DISTINCT "admissions"."subject_id") FROM "procedures_icd" JOIN "d_icd_procedures" ON "d_icd_procedures"."icd9_code" = "procedures_icd"."icd9_code" AND "d_icd_procedures"."short_title" = 'contrast aortogram' JOIN "admissions" ON "admissions"."hadm_id" = "procedures_icd"."hadm_id" JOIN "t2" AS "t2" ON "admissions"."subject_id" = "t2"."subject_id" AND "procedures_icd"."charttime" < "t2"."charttime" AND DATETIME("procedures_icd"."charttime") <= DATETIME("t2"."charttime") AND DATETIME("procedures_icd"."charttime", '+2 month') >= DATETIME("t2"."charttime") WHERE STRFTIME('%y', "procedures_icd"."charttime") <= '2104'
| 0.994141 |
CREATE TABLE match_season (POSITION VARCHAR, College VARCHAR)
|
Show the distinct position of players from college UCLA or Duke.
|
SELECT DISTINCT POSITION FROM match_season WHERE College = "UCLA" OR College = "Duke"
|
SELECT DISTINCT "POSITION" FROM "match_season" WHERE "College" = "Duke" OR "College" = "UCLA"
| 0.09082 |
CREATE TABLE table_55842 ("Year" FLOAT, "MRHMA" TEXT, "USCA" TEXT, "RTHK" TEXT, "Joint Music Award" TEXT, "Total" FLOAT)
|
How many Joint Music Awards were there with a RTHK of 1, in a Year before 2006?
|
SELECT "Joint Music Award" FROM table_55842 WHERE "Year" < '2006' AND "RTHK" = '1'
|
SELECT "Joint Music Award" FROM "table_55842" WHERE "RTHK" = '1' AND "Year" < '2006'
| 0.082031 |
CREATE TABLE table_1341577_34 (candidates VARCHAR, incumbent VARCHAR)
|
Who were all the candidates when incumbent was Tim Valentine?
|
SELECT candidates FROM table_1341577_34 WHERE incumbent = "Tim Valentine"
|
SELECT "candidates" FROM "table_1341577_34" WHERE "Tim Valentine" = "incumbent"
| 0.077148 |
CREATE TABLE Organisation_Types (organisation_type VARCHAR, organisation_type_description VARCHAR)
CREATE TABLE Project_Staff (staff_id DOUBLE, project_id INT, role_code VARCHAR, date_from DATETIME, date_to DATETIME, other_details VARCHAR)
CREATE TABLE Document_Types (document_type_code VARCHAR, document_description VARCHAR)
CREATE TABLE Projects (project_id INT, organisation_id INT, project_details VARCHAR)
CREATE TABLE Project_Outcomes (project_id INT, outcome_code VARCHAR, outcome_details VARCHAR)
CREATE TABLE Organisations (organisation_id INT, organisation_type VARCHAR, organisation_details VARCHAR)
CREATE TABLE Documents (document_id INT, document_type_code VARCHAR, grant_id INT, sent_date DATETIME, response_received_date DATETIME, other_details VARCHAR)
CREATE TABLE Research_Staff (staff_id INT, employer_organisation_id INT, staff_details VARCHAR)
CREATE TABLE Grants (grant_id INT, organisation_id INT, grant_amount DECIMAL, grant_start_date DATETIME, grant_end_date DATETIME, other_details VARCHAR)
CREATE TABLE Staff_Roles (role_code VARCHAR, role_description VARCHAR)
CREATE TABLE Tasks (task_id INT, project_id INT, task_details VARCHAR, "eg Agree Objectives" VARCHAR)
CREATE TABLE Research_Outcomes (outcome_code VARCHAR, outcome_description VARCHAR)
|
Plot how many date from by grouped by date from as a bar graph, list Y in asc order.
|
SELECT date_from, COUNT(date_from) FROM Project_Staff ORDER BY COUNT(date_from)
|
SELECT "date_from", COUNT("date_from") FROM "Project_Staff" ORDER BY COUNT("date_from") NULLS FIRST
| 0.09668 |
CREATE TABLE table_32849 ("Rank" FLOAT, "Nation" TEXT, "Gold" FLOAT, "Silver" FLOAT, "Bronze" FLOAT, "Total" FLOAT)
|
What is the average total when gold is 0, bronze is 0, and silver is smaller than 1?
|
SELECT AVG("Total") FROM table_32849 WHERE "Gold" = '0' AND "Bronze" = '0' AND "Silver" < '1'
|
SELECT AVG("Total") FROM "table_32849" WHERE "Bronze" = '0' AND "Gold" = '0' AND "Silver" < '1'
| 0.092773 |
CREATE TABLE table_203_42 (id DECIMAL, "model" TEXT, "class" TEXT, "length" TEXT, "fuel" TEXT, "starting price" TEXT)
|
is the vista more than the aspect ?
|
SELECT (SELECT "starting price" FROM table_203_42 WHERE "model" = 'vista') > (SELECT "starting price" FROM table_203_42 WHERE "model" = 'aspect')
|
SELECT (SELECT "starting price" FROM "table_203_42" WHERE "model" = 'aspect') < (SELECT "starting price" FROM "table_203_42" WHERE "model" = 'vista')
| 0.145508 |
CREATE TABLE table_16863 ("Player" TEXT, "No." TEXT, "Nationality" TEXT, "Position" TEXT, "Years for Jazz" TEXT, "School/Club Team" TEXT)
|
What is the position for player Blue Edwards?
|
SELECT "Position" FROM table_16863 WHERE "Player" = 'Blue Edwards'
|
SELECT "Position" FROM "table_16863" WHERE "Player" = 'Blue Edwards'
| 0.066406 |
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE 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)
|
Count the number of patients who were diagnosed with sternal wound infection and have hamatology as a lab test category.
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.diagnosis = "STERNAL WOUND INFECTION" AND lab."CATEGORY" = "Hematology"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "Hematology" = "lab"."CATEGORY" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "STERNAL WOUND INFECTION" = "demographic"."diagnosis"
| 0.214844 |
CREATE TABLE table_74364 ("Sl. No." FLOAT, "Train number" FLOAT, "Train name" TEXT, "Origin" TEXT, "Destination" TEXT, "Time" TEXT, "Service" TEXT, "Route/Via." TEXT)
|
What is the destination when the train number is 16526?
|
SELECT "Destination" FROM table_74364 WHERE "Train number" = '16526'
|
SELECT "Destination" FROM "table_74364" WHERE "Train number" = '16526'
| 0.068359 |
CREATE TABLE table_27801 ("Case" TEXT, "1st pers. sing." TEXT, "2nd pers. sing." TEXT, "3rd pers. sing." TEXT, "1st pers. pl" TEXT, "2nd pers. pl." TEXT, "3rd pers pl." TEXT)
|
Name the 1st person pl for
|
SELECT "1st pers. pl" FROM table_27801 WHERE "2nd pers. sing." = 'тонэ'
|
SELECT "1st pers. pl" FROM "table_27801" WHERE "2nd pers. sing." = 'тонэ'
| 0.071289 |
CREATE TABLE table_32611 ("Couple" TEXT, "Score" TEXT, "Dance" TEXT, "Music" TEXT, "Result" TEXT)
|
What is the Result for Couple Kelly & Alec when they have a Score of 22 (8, 7, 7)?
|
SELECT "Result" FROM table_32611 WHERE "Couple" = 'kelly & alec' AND "Score" = '22 (8, 7, 7)'
|
SELECT "Result" FROM "table_32611" WHERE "Couple" = 'kelly & alec' AND "Score" = '22 (8, 7, 7)'
| 0.092773 |
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
|
how many patients whose age is less than 49 and admission year is less than 2163?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.age < "49" AND demographic.admityear < "2163"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "2163" > "demographic"."admityear" AND "49" > "demographic"."age"
| 0.136719 |
CREATE TABLE table_80004 ("Name" TEXT, "Years" TEXT, "Gender" TEXT, "Area" TEXT, "Authority" TEXT, "Decile" FLOAT, "Roll" FLOAT)
|
How many deciles have Years of 9 13?
|
SELECT COUNT("Decile") FROM table_80004 WHERE "Years" = '9–13'
|
SELECT COUNT("Decile") FROM "table_80004" WHERE "Years" = '9–13'
| 0.0625 |
CREATE TABLE song (song_name VARCHAR, artist_name VARCHAR, country VARCHAR, f_id DECIMAL, genre_is VARCHAR, rating DECIMAL, languages VARCHAR, releasedate DATE, resolution DECIMAL)
CREATE TABLE genre (g_name VARCHAR, rating VARCHAR, most_popular_in VARCHAR)
CREATE TABLE artist (artist_name VARCHAR, country VARCHAR, gender VARCHAR, preferred_genre VARCHAR)
CREATE TABLE files (f_id DECIMAL, artist_name VARCHAR, file_size VARCHAR, duration VARCHAR, formats VARCHAR)
|
How many songs were released for each format Show bar chart, and display Y-axis in ascending order.
|
SELECT formats, COUNT(*) FROM files GROUP BY formats ORDER BY COUNT(*)
|
SELECT "formats", COUNT(*) FROM "files" GROUP BY "formats" ORDER BY COUNT(*) NULLS FIRST
| 0.085938 |
CREATE TABLE table_name_3 (games INT, name VARCHAR, rank VARCHAR)
|
How many Games has a Name of st phane dumas and a Rank larger than 5?
|
SELECT AVG(games) FROM table_name_3 WHERE name = "stéphane dumas" AND rank > 5
|
SELECT AVG("games") FROM "table_name_3" WHERE "name" = "stéphane dumas" AND "rank" > 5
| 0.083984 |
CREATE TABLE table_name_70 (earnings___ INT, wins INT)
|
How many earnings have Wins larger than 3?
|
SELECT SUM(earnings___) AS $__ FROM table_name_70 WHERE wins > 3
|
SELECT SUM("earnings___") AS $__ FROM "table_name_70" WHERE "wins" > 3
| 0.068359 |
CREATE TABLE record (ID INT, Result TEXT, Swimmer_ID INT, Event_ID INT)
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)
CREATE TABLE event (ID INT, Name TEXT, Stadium_ID INT, Year TEXT)
CREATE TABLE stadium (ID INT, name TEXT, Capacity INT, City TEXT, Country TEXT, Opening_year INT)
|
Show me about the distribution of meter_500 and meter_100 in a bar chart, I want to show by the y-axis from low to high.
|
SELECT meter_500, meter_100 FROM swimmer ORDER BY meter_100
|
SELECT "meter_500", "meter_100" FROM "swimmer" ORDER BY "meter_100" NULLS FIRST
| 0.077148 |
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 the number of patients less than 58 years who have nitroglycerin sl prescription?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "58" AND prescriptions.drug = "Nitroglycerin SL"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "Nitroglycerin SL" = "prescriptions"."drug" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "58" > "demographic"."age"
| 0.219727 |
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 TagSynonyms (Id DECIMAL, SourceTagName TEXT, TargetTagName TEXT, CreationDate TIME, OwnerUserId DECIMAL, AutoRenameCount DECIMAL, LastAutoRename TIME, Score DECIMAL, ApprovedByUserId DECIMAL, ApprovalDate TIME)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE PostTypes (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 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 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 PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME)
CREATE TABLE FlagTypes (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 ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId 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 PostHistoryTypes (Id DECIMAL, Name 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 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 PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
CREATE TABLE ReviewTaskTypes (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 PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL)
CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT)
CREATE TABLE Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, ContentLicense TEXT)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT)
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 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)
|
Number of tag-removals (per user).
|
WITH revisions_cte AS (SELECT DISTINCT p.Id AS pid, ph1.Id AS phId FROM PostHistory AS ph1 INNER JOIN Posts AS p ON ph1.PostId = p.Id WHERE ph1.PostHistoryTypeId IN (3, 6, 9) AND ph1.Text LIKE '%<##tagName##>%' AND NOT (p.Tags LIKE '%<##tagName##>%')), firstrev_cte AS (SELECT pid, MIN(ph2.Id) AS MinId FROM revisions_cte INNER JOIN PostHistory AS ph2 ON ph2.PostId = pid WHERE (ph2.Id > phId) AND ph2.PostHistoryTypeId IN (3, 6, 9) AND NOT (ph2.Text LIKE '%<##tagName##>%') GROUP BY pid), users_cte AS (SELECT PostId AS pid, UserId AS uid, UserDisplayName AS udn FROM PostHistory INNER JOIN firstrev_cte ON PostHistory.Id = MinId) SELECT COUNT(pid) AS Count, uid AS "user_link", udn FROM users_cte GROUP BY uid, udn ORDER BY COUNT(pid) DESC
|
WITH "revisions_cte" AS (SELECT DISTINCT "p"."Id" AS "pid", "ph1"."Id" AS "phId" FROM "PostHistory" AS "ph1" JOIN "Posts" AS "p" ON "p"."Id" = "ph1"."PostId" AND NOT "p"."Tags" LIKE '%<##tagName##>%' WHERE "ph1"."PostHistoryTypeId" IN (3, 6, 9) AND "ph1"."Text" LIKE '%<##tagName##>%'), "firstrev_cte" AS (SELECT MAX(1) AS "_" FROM "revisions_cte" JOIN "PostHistory" AS "ph2" ON "ph2"."Id" > "phId" AND "ph2"."PostHistoryTypeId" IN (3, 6, 9) AND "ph2"."PostId" = "pid" AND NOT "ph2"."Text" LIKE '%<##tagName##>%' GROUP BY "pid") SELECT COUNT("pid") AS "Count", "uid" AS "user_link", "udn" FROM "PostHistory" JOIN "firstrev_cte" ON "MinId" = "PostHistory"."Id" GROUP BY "uid", "udn" ORDER BY COUNT("pid") DESC NULLS LAST
| 0.702148 |
CREATE TABLE table_8882 ("Title" TEXT, "Writer" TEXT, "Doctor" TEXT, "Format" TEXT, "Company" TEXT, "release date" TEXT)
|
What is Title, when Release Date is 2011-12-01 December 2011?
|
SELECT "Title" FROM table_8882 WHERE "release date" = '2011-12-01 december 2011'
|
SELECT "Title" FROM "table_8882" WHERE "release date" = '2011-12-01 december 2011'
| 0.080078 |
CREATE TABLE table_name_49 (replaced_by VARCHAR, manner_of_departure VARCHAR, date_of_appointment VARCHAR)
|
What kind of Replaced has a Manner of departure of end of contract on dec. 16, 2008?
|
SELECT replaced_by FROM table_name_49 WHERE manner_of_departure = "end of contract" AND date_of_appointment = "dec. 16, 2008"
|
SELECT "replaced_by" FROM "table_name_49" WHERE "date_of_appointment" = "dec. 16, 2008" AND "end of contract" = "manner_of_departure"
| 0.129883 |
CREATE TABLE table_50308 ("Opposing Team" TEXT, "Against" FLOAT, "Date" TEXT, "Venue" TEXT, "Status" TEXT)
|
What is Venue, when Against is less than 30, and when Opposing Team is New South Wales?
|
SELECT "Venue" FROM table_50308 WHERE "Against" < '30' AND "Opposing Team" = 'new south wales'
|
SELECT "Venue" FROM "table_50308" WHERE "Against" < '30' AND "Opposing Team" = 'new south wales'
| 0.09375 |
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE 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)
|
what is admission time and discharge time of subject id 18112?
|
SELECT demographic.admittime, demographic.dischtime FROM demographic WHERE demographic.subject_id = "18112"
|
SELECT "demographic"."admittime", "demographic"."dischtime" FROM "demographic" WHERE "18112" = "demographic"."subject_id"
| 0.118164 |
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 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)
|
what number of patients who died in or before the year 2186 had lab test item id 50805?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE demographic.dod_year <= "2186.0" AND lab.itemid = "50805"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "lab" ON "50805" = "lab"."itemid" AND "demographic"."hadm_id" = "lab"."hadm_id" WHERE "2186.0" >= "demographic"."dod_year"
| 0.191406 |
CREATE TABLE table_38057 ("Region" TEXT, "Total Population" FLOAT, "Manchu" FLOAT, "Percentage in Manchu Population" TEXT, "Regional Percentage of Population" FLOAT)
|
What is the lowest population associated with a Regional Percentage of Population of 2.95?
|
SELECT MIN("Total Population") FROM table_38057 WHERE "Regional Percentage of Population" = '2.95'
|
SELECT MIN("Total Population") FROM "table_38057" WHERE "Regional Percentage of Population" = '2.95'
| 0.097656 |
CREATE TABLE table_name_86 (date VARCHAR, region VARCHAR, catalog VARCHAR)
|
On what date did the United Kingdom have a catalog of FT 507?
|
SELECT date FROM table_name_86 WHERE region = "united kingdom" AND catalog = "ft 507"
|
SELECT "date" FROM "table_name_86" WHERE "catalog" = "ft 507" AND "region" = "united kingdom"
| 0.09082 |
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 PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId 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 FlagTypes (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 CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress 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 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 ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
CREATE TABLE PostTypes (Id DECIMAL, Name TEXT)
CREATE TABLE ReviewTaskResultTypes (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 ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment 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 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 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 PostTags (PostId DECIMAL, TagId DECIMAL)
CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description 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 PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL)
CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
|
average time for obtaining accepted answers.
|
SELECT CAST((JULIANDAY(CreationDate) - JULIANDAY(pyt.CreationDate)) * 86400.0 AS INT) AS roznica FROM Posts AS pyt, Posts AS odp WHERE pyt.AcceptedAnswerId = odp.Id AND pyt.Id = odp.ParentId AND CAST((JULIANDAY(CreationDate) - JULIANDAY(pyt.CreationDate)) * 86400.0 AS INT) > 0 ORDER BY roznica
|
SELECT CAST((JULIANDAY("CreationDate") - JULIANDAY("pyt"."CreationDate")) * 86400.0 AS INT) AS "roznica" FROM "Posts" AS "pyt" JOIN "Posts" AS "odp" ON "odp"."Id" = "pyt"."AcceptedAnswerId" AND "odp"."ParentId" = "pyt"."Id" WHERE CAST((JULIANDAY("CreationDate") - JULIANDAY("pyt"."CreationDate")) * 86400.0 AS INT) > 0 ORDER BY "roznica" NULLS FIRST
| 0.34082 |
CREATE TABLE Institution (Institution_id TEXT, Institution TEXT, Location TEXT, Founded FLOAT, Type TEXT, Enrollment INT, Team TEXT, Primary_Conference TEXT, building_id TEXT)
CREATE TABLE building (building_id TEXT, Name TEXT, Street_address TEXT, Years_as_tallest TEXT, Height_feet INT, Floors INT)
CREATE TABLE protein (common_name TEXT, protein_name TEXT, divergence_from_human_lineage FLOAT, accession_number TEXT, sequence_length FLOAT, sequence_identity_to_human_protein TEXT, Institution_id TEXT)
|
Please compare the number of floors for all street address using a bar chart, and order by the number of floors.
|
SELECT Street_address, Floors FROM building ORDER BY Floors
|
SELECT "Street_address", "Floors" FROM "building" ORDER BY "Floors" NULLS FIRST
| 0.077148 |
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
|
what is the number of patients whose admission type is elective and diagnoses short title is b-complex defic nec?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "ELECTIVE" AND diagnoses.short_title = "B-complex defic NEC"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "B-complex defic NEC" = "diagnoses"."short_title" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "ELECTIVE" = "demographic"."admission_type"
| 0.234375 |
CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime 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 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 medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime 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 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 treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME)
|
calculate the duration of patient 002-56853's stay in the last icu.
|
SELECT STRFTIME('%j', patient.unitdischargetime) - STRFTIME('%j', patient.unitadmittime) FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '002-56853') AND NOT patient.unitadmittime IS NULL ORDER BY patient.unitadmittime DESC LIMIT 1
|
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '002-56853' GROUP BY "patienthealthsystemstayid") SELECT STRFTIME('%j', "patient"."unitdischargetime") - STRFTIME('%j', "patient"."unitadmittime") FROM "patient" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "patient"."patienthealthsystemstayid" WHERE NOT "_u_0"."" IS NULL AND NOT "patient"."unitadmittime" IS NULL ORDER BY "patient"."unitadmittime" DESC NULLS LAST LIMIT 1
| 0.464844 |
CREATE TABLE table_17340355_7 (high_assists VARCHAR, date VARCHAR)
|
Who had the high assist total on january 2?
|
SELECT high_assists FROM table_17340355_7 WHERE date = "January 2"
|
SELECT "high_assists" FROM "table_17340355_7" WHERE "January 2" = "date"
| 0.070313 |
CREATE TABLE Faculty (FacID INT, Lname VARCHAR, Fname VARCHAR, Rank VARCHAR, Sex VARCHAR, Phone INT, Room VARCHAR, Building VARCHAR)
CREATE TABLE Faculty_Participates_in (FacID INT, actid INT)
CREATE TABLE Activity (actid INT, activity_name VARCHAR)
CREATE TABLE Participates_in (stuid INT, actid INT)
CREATE TABLE Student (StuID INT, LName VARCHAR, Fname VARCHAR, Age INT, Sex VARCHAR, Major INT, Advisor INT, city_code VARCHAR)
|
Visualize a bar chart for how many male and female assistant professors do we have?, and sort from low to high by the names.
|
SELECT Sex, COUNT(*) FROM Faculty WHERE Rank = "AsstProf" GROUP BY Sex ORDER BY Sex
|
SELECT "Sex", COUNT(*) FROM "Faculty" WHERE "AsstProf" = "Rank" GROUP BY "Sex" ORDER BY "Sex" NULLS FIRST
| 0.102539 |
CREATE TABLE table_21501518_1 (week__number VARCHAR, theme VARCHAR)
|
Which week is the theme n/a
|
SELECT week__number FROM table_21501518_1 WHERE theme = "N/A"
|
SELECT "week__number" FROM "table_21501518_1" WHERE "N/A" = "theme"
| 0.06543 |
CREATE TABLE Sportsinfo (StuID VARCHAR, onscholarship VARCHAR)
CREATE TABLE Student (Lname VARCHAR, StuID VARCHAR)
|
Show last names for all student who are on scholarship.
|
SELECT T2.Lname FROM Sportsinfo AS T1 JOIN Student AS T2 ON T1.StuID = T2.StuID WHERE T1.onscholarship = 'Y'
|
SELECT "T2"."Lname" FROM "Sportsinfo" AS "T1" JOIN "Student" AS "T2" ON "T1"."StuID" = "T2"."StuID" WHERE "T1"."onscholarship" = 'Y'
| 0.128906 |
CREATE TABLE teachers (LastName TEXT, FirstName TEXT, Classroom INT)
CREATE TABLE list (LastName TEXT, FirstName TEXT, Grade INT, Classroom INT)
|
For each fourth-grade classroom, show the classroom number and the total number of students using it. Show the correlation.
|
SELECT Classroom, COUNT(*) FROM list WHERE Grade = "4" GROUP BY Classroom
|
SELECT "Classroom", COUNT(*) FROM "list" WHERE "4" = "Grade" GROUP BY "Classroom"
| 0.079102 |
CREATE TABLE student (stuid DECIMAL, lname TEXT, fname TEXT, age DECIMAL, sex TEXT, major DECIMAL, advisor DECIMAL, city_code TEXT)
CREATE TABLE allergy_type (allergy TEXT, allergytype TEXT)
CREATE TABLE has_allergy (stuid DECIMAL, allergy TEXT)
|
Show student ids for all male students.
|
SELECT stuid FROM student WHERE sex = 'M'
|
SELECT "stuid" FROM "student" WHERE "sex" = 'M'
| 0.045898 |
CREATE TABLE table_name_30 (position VARCHAR, surname VARCHAR)
|
Which Position did Ruzic play?
|
SELECT position FROM table_name_30 WHERE surname = "ruzic"
|
SELECT "position" FROM "table_name_30" WHERE "ruzic" = "surname"
| 0.0625 |
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 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 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 vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime 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 allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME)
|
what is the daily minimum of urine output of patient 033-3992 since 08/31/2104?
|
SELECT MIN(intakeoutput.cellvaluenumeric) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '033-3992')) AND intakeoutput.celllabel = 'urine' AND intakeoutput.cellpath LIKE '%output%' AND STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime) >= '2104-08-31' GROUP BY STRFTIME('%y-%m-%d', intakeoutput.intakeoutputtime)
|
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '033-3992' 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 MIN("intakeoutput"."cellvaluenumeric") FROM "intakeoutput" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "intakeoutput"."patientunitstayid" WHERE "intakeoutput"."celllabel" = 'urine' AND "intakeoutput"."cellpath" LIKE '%output%' AND NOT "_u_1"."" IS NULL AND STRFTIME('%y-%m-%d', "intakeoutput"."intakeoutputtime") >= '2104-08-31' GROUP BY STRFTIME('%y-%m-%d', "intakeoutput"."intakeoutputtime")
| 0.737305 |
CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL)
CREATE TABLE PostTags (PostId DECIMAL, TagId DECIMAL)
CREATE TABLE ReviewTaskStates (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE CloseReasonTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
CREATE TABLE PostNoticeTypes (Id DECIMAL, ClassId DECIMAL, Name TEXT, Body TEXT, IsHidden BOOLEAN, Predefined BOOLEAN, PostNoticeDurationId DECIMAL)
CREATE TABLE VoteTypes (Id DECIMAL, Name TEXT)
CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT)
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 ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId 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 ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment 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 Comments (Id DECIMAL, PostId DECIMAL, Score DECIMAL, Text TEXT, CreationDate TIME, UserDisplayName TEXT, UserId DECIMAL, 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 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 PostHistory (Id DECIMAL, PostHistoryTypeId DECIMAL, PostId DECIMAL, RevisionGUID other, CreationDate TIME, UserId DECIMAL, UserDisplayName TEXT, Comment TEXT, Text TEXT, ContentLicense TEXT)
CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME)
CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId DECIMAL)
CREATE TABLE PendingFlags (Id DECIMAL, FlagTypeId DECIMAL, PostId DECIMAL, CreationDate TIME, CloseReasonTypeId DECIMAL, CloseAsOffTopicReasonTypeId DECIMAL, DuplicateOfQuestionId DECIMAL, BelongsOnBaseHostAddress TEXT)
CREATE TABLE PostTypes (Id DECIMAL, Name TEXT)
CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL)
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 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 ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT)
CREATE TABLE PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL)
|
How many tags per question for top questions?.
|
SELECT p.Id AS "post_link", p.Tags FROM Posts AS p WHERE p.PostTypeId = 1 AND p.ViewCount > 10000 ORDER BY p.ViewCount
|
SELECT "p"."Id" AS "post_link", "p"."Tags" FROM "Posts" AS "p" WHERE "p"."PostTypeId" = 1 AND "p"."ViewCount" > 10000 ORDER BY "p"."ViewCount" NULLS FIRST
| 0.150391 |
CREATE TABLE table_name_32 (yards VARCHAR, player VARCHAR)
|
How many Yards did Player Rob Turner collect?
|
SELECT yards FROM table_name_32 WHERE player = "rob turner"
|
SELECT "yards" FROM "table_name_32" WHERE "player" = "rob turner"
| 0.063477 |
CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_ID DECIMAL)
CREATE TABLE locations (LOCATION_ID DECIMAL, STREET_ADDRESS VARCHAR, POSTAL_CODE VARCHAR, CITY VARCHAR, STATE_PROVINCE VARCHAR, COUNTRY_ID VARCHAR)
CREATE TABLE departments (DEPARTMENT_ID DECIMAL, DEPARTMENT_NAME VARCHAR, MANAGER_ID DECIMAL, LOCATION_ID DECIMAL)
CREATE TABLE regions (REGION_ID DECIMAL, REGION_NAME VARCHAR)
CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID 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)
CREATE TABLE jobs (JOB_ID VARCHAR, JOB_TITLE VARCHAR, MIN_SALARY DECIMAL, MAX_SALARY DECIMAL)
|
Can you list the employee's last name and the corresponding department id using a bar chart?, and could you display from high to low by the X?
|
SELECT LAST_NAME, DEPARTMENT_ID FROM employees ORDER BY LAST_NAME DESC
|
SELECT "LAST_NAME", "DEPARTMENT_ID" FROM "employees" ORDER BY "LAST_NAME" DESC NULLS LAST
| 0.086914 |
CREATE TABLE table_203_440 (id DECIMAL, "rank" DECIMAL, "player" TEXT, "from" TEXT, "to" TEXT, "transfer fee\ ( \\u20ac million ) " DECIMAL, "year" DECIMAL)
|
how many players had a transfer fee of at least 8 million ?
|
SELECT COUNT("player") FROM table_203_440 WHERE "transfer fee\n(\u20ac million)" >= 8
|
SELECT COUNT("player") FROM "table_203_440" WHERE "transfer fee\n(\u20ac million)" >= 8
| 0.084961 |
CREATE TABLE table_72057 ("Player" TEXT, "Solo" FLOAT, "Total" FLOAT, "Sacks" TEXT, "Fumble force" FLOAT, "Fumble rec" FLOAT)
|
How many tackles for the player with over 0 fumble recovries and 0 forced fumbles?
|
SELECT COUNT("Total") FROM table_72057 WHERE "Fumble rec" > '0' AND "Fumble force" = '0'
|
SELECT COUNT("Total") FROM "table_72057" WHERE "Fumble force" = '0' AND "Fumble rec" > '0'
| 0.087891 |
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, a bar chart shows the distribution of headquarter and the sum of manufacturer , and group by attribute headquarter, and could you rank from low to high by the x-axis?
|
SELECT Headquarter, SUM(Manufacturer) FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY Headquarter ORDER BY Headquarter
|
SELECT "Headquarter", SUM("Manufacturer") FROM "Products" AS "T1" JOIN "Manufacturers" AS "T2" ON "T1"."Manufacturer" = "T2"."Code" GROUP BY "Headquarter" ORDER BY "Headquarter" NULLS FIRST
| 0.18457 |
CREATE TABLE staff (staff_id DECIMAL, gender TEXT, first_name TEXT, last_name TEXT, email_address TEXT, phone_number TEXT)
CREATE TABLE products (product_id DECIMAL, parent_product_id DECIMAL, product_category_code TEXT, date_product_first_available TIME, date_product_discontinued TIME, product_name TEXT, product_description TEXT, product_price DECIMAL)
CREATE TABLE customers (customer_id DECIMAL, customer_type_code TEXT, address_line_1 TEXT, address_line_2 TEXT, town_city TEXT, state TEXT, email_address TEXT, phone_number TEXT)
CREATE TABLE complaints (complaint_id DECIMAL, product_id DECIMAL, customer_id DECIMAL, complaint_outcome_code TEXT, complaint_status_code TEXT, complaint_type_code TEXT, date_complaint_raised TIME, date_complaint_closed TIME, staff_id DECIMAL)
|
Find the emails of customers who has filed a complaints of the product with the most complaints.
|
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY COUNT(*) LIMIT 1
|
SELECT "t1"."email_address" FROM "customers" AS "t1" JOIN "complaints" AS "t2" ON "t1"."customer_id" = "t2"."customer_id" GROUP BY "t1"."customer_id" ORDER BY COUNT(*) NULLS FIRST LIMIT 1
| 0.182617 |
CREATE TABLE table_204_103 (id DECIMAL, "medal" TEXT, "name" TEXT, "sport" TEXT, "event" TEXT)
|
how many total sports had silver medals awarded ?
|
SELECT COUNT(DISTINCT "sport") FROM table_204_103
|
SELECT COUNT(DISTINCT "sport") FROM "table_204_103"
| 0.049805 |
CREATE TABLE table_22815568_2 (unemployment_rate VARCHAR, market_income_per_capita VARCHAR)
|
What is the unemployment rate for the county with a market income per capita of $20,958?
|
SELECT COUNT(unemployment_rate) FROM table_22815568_2 WHERE market_income_per_capita = "$20,958"
|
SELECT COUNT("unemployment_rate") FROM "table_22815568_2" WHERE "$20,958" = "market_income_per_capita"
| 0.099609 |
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT)
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
|
what is the number of patients whose year of death is less than or equal to 2112 and drug name is voriconazole?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.dod_year <= "2112.0" AND prescriptions.drug = "Voriconazole"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "Voriconazole" = "prescriptions"."drug" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "2112.0" >= "demographic"."dod_year"
| 0.225586 |
CREATE TABLE table_12119 ("Mininera DFL" TEXT, "Wins" FLOAT, "Byes" FLOAT, "Losses" FLOAT, "Draws" FLOAT, "Against" FLOAT)
|
WHAT IS THE HIGHEST WINS WITH AGAINST SMALLER THAN 924, LOSSES SMALLER THAN 2?
|
SELECT MAX("Wins") FROM table_12119 WHERE "Against" < '924' AND "Losses" < '2'
|
SELECT MAX("Wins") FROM "table_12119" WHERE "Against" < '924' AND "Losses" < '2'
| 0.078125 |
CREATE TABLE table_name_17 (city VARCHAR, mascot VARCHAR)
|
Mascot of blazers involves what city?
|
SELECT city FROM table_name_17 WHERE mascot = "blazers"
|
SELECT "city" FROM "table_name_17" WHERE "blazers" = "mascot"
| 0.05957 |
CREATE TABLE table_204_923 (id DECIMAL, "club" TEXT, "entered\ administration" TEXT, "exited\ administration" TEXT, "league ( s ) " TEXT, "deduction ( s ) " TEXT)
|
how many teams have received deductions thus far ?
|
SELECT COUNT("club") FROM table_204_923 WHERE NOT "deduction(s)" IS NULL
|
SELECT COUNT("club") FROM "table_204_923" WHERE NOT "deduction(s)" IS NULL
| 0.072266 |
CREATE TABLE table_name_51 (bike VARCHAR, laps VARCHAR, time VARCHAR)
|
What is the Bike with 18 laps and +41.280 as the time?
|
SELECT bike FROM table_name_51 WHERE laps = 18 AND time = "+41.280"
|
SELECT "bike" FROM "table_name_51" WHERE "+41.280" = "time" AND "laps" = 18
| 0.073242 |
CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT)
CREATE TABLE 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)
|
count the number of patients whose admission location is transfer from hosp/extram and diagnoses icd9 code is 4820?
|
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_location = "TRANSFER FROM HOSP/EXTRAM" AND diagnoses.icd9_code = "4820"
|
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "diagnoses" ON "4820" = "diagnoses"."icd9_code" AND "demographic"."hadm_id" = "diagnoses"."hadm_id" WHERE "TRANSFER FROM HOSP/EXTRAM" = "demographic"."admission_location"
| 0.238281 |
CREATE TABLE table_8394 ("Country" TEXT, "Title" TEXT, "Network" TEXT, "Games" TEXT, "Date aired" TEXT)
|
Which network aired the program Schlag den Raab?
|
SELECT "Network" FROM table_8394 WHERE "Title" = 'schlag den raab'
|
SELECT "Network" FROM "table_8394" WHERE "Title" = 'schlag den raab'
| 0.066406 |
CREATE TABLE table_56722 ("Round" FLOAT, "Pick" FLOAT, "Player" TEXT, "Position" TEXT, "Nationality" TEXT, "Team" TEXT, "College" TEXT)
|
What is the team with position G?
|
SELECT "Team" FROM table_56722 WHERE "Position" = 'g'
|
SELECT "Team" FROM "table_56722" WHERE "Position" = 'g'
| 0.053711 |
CREATE TABLE locations (LOCATION_ID DECIMAL, STREET_ADDRESS VARCHAR, POSTAL_CODE VARCHAR, CITY VARCHAR, STATE_PROVINCE VARCHAR, COUNTRY_ID VARCHAR)
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)
CREATE TABLE departments (DEPARTMENT_ID DECIMAL, DEPARTMENT_NAME VARCHAR, MANAGER_ID DECIMAL, LOCATION_ID DECIMAL)
CREATE TABLE jobs (JOB_ID VARCHAR, JOB_TITLE VARCHAR, MIN_SALARY DECIMAL, MAX_SALARY DECIMAL)
CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID DECIMAL)
CREATE TABLE regions (REGION_ID DECIMAL, REGION_NAME VARCHAR)
CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_ID DECIMAL)
|
Scatter. what is the average salary of employees who have a commission percentage that is not null?
|
SELECT DEPARTMENT_ID, AVG(SALARY) FROM employees WHERE COMMISSION_PCT <> "null" GROUP BY DEPARTMENT_ID
|
SELECT "DEPARTMENT_ID", AVG("SALARY") FROM "employees" WHERE "COMMISSION_PCT" <> "null" GROUP BY "DEPARTMENT_ID"
| 0.109375 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.