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 table_name_76 (record VARCHAR, loss VARCHAR)
What is the record when the loss is westbrook (1-6)?
SELECT record FROM table_name_76 WHERE loss = "westbrook (1-6)"
SELECT "record" FROM "table_name_76" WHERE "loss" = "westbrook (1-6)"
0.067383
CREATE TABLE table_name_23 (round VARCHAR, venue VARCHAR)
What is the Round din Ullevaal?
SELECT round FROM table_name_23 WHERE venue = "ullevaal"
SELECT "round" FROM "table_name_23" WHERE "ullevaal" = "venue"
0.060547
CREATE TABLE table_72663 ("Year" FLOAT, "Dates" TEXT, "Champion" TEXT, "Country" TEXT, "Score" TEXT, "To par" TEXT, "Margin of victory" TEXT, "Purse ( US$ ) " FLOAT, "Winners share" FLOAT)
What countries have a margin of victory at 6 strokes?
SELECT "Country" FROM table_72663 WHERE "Margin of victory" = '6 strokes'
SELECT "Country" FROM "table_72663" WHERE "Margin of victory" = '6 strokes'
0.073242
CREATE TABLE table_2509202_2 (sorata_municipality VARCHAR, quiabaya_municipality VARCHAR)
How many people in the sorata municipality when the quiabaya municipality has 33?
SELECT sorata_municipality FROM table_2509202_2 WHERE quiabaya_municipality = "33"
SELECT "sorata_municipality" FROM "table_2509202_2" WHERE "33" = "quiabaya_municipality"
0.085938
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 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 inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name 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 prescriptions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, startdate TIME, enddate TIME, drug TEXT, dose_val_rx TEXT, dose_unit_rx TEXT, route TEXT) CREATE TABLE admissions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, admittime TIME, dischtime TIME, admission_type TEXT, admission_location TEXT, discharge_location TEXT, insurance TEXT, language TEXT, marital_status TEXT, ethnicity TEXT, age DECIMAL) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom 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_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title 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 d_icd_procedures (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)
for patients 60 or above since 2102, what are the top five prescribed drugs?
SELECT t1.drug FROM (SELECT prescriptions.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.age >= 60) AND STRFTIME('%y', prescriptions.startdate) >= '2102' GROUP BY prescriptions.drug) AS t1 WHERE t1.c1 <= 5
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."age" >= 60 GROUP BY "hadm_id"), "t1" AS (SELECT "prescriptions"."drug", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC NULLS LAST) AS "c1" FROM "prescriptions" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "prescriptions"."hadm_id" WHERE NOT "_u_0"."" IS NULL AND STRFTIME('%y', "prescriptions"."startdate") >= '2102' GROUP BY "prescriptions"."drug") SELECT "t1"."drug" FROM "t1" AS "t1" WHERE "t1"."c1" <= 5
0.47168
CREATE TABLE table_24887326_7 (home_team VARCHAR, away_team VARCHAR)
Who was the home team when the away team was fulham?
SELECT home_team FROM table_24887326_7 WHERE away_team = "Fulham"
SELECT "home_team" FROM "table_24887326_7" WHERE "Fulham" = "away_team"
0.069336
CREATE TABLE table_1036 ("Player" TEXT, "Position" TEXT, "Starter" TEXT, "Touchdowns" FLOAT, "Extra points" FLOAT, "Field goals" FLOAT, "Points" FLOAT)
Which players have made a total of 12 extra points?
SELECT "Player" FROM table_1036 WHERE "Extra points" = '12'
SELECT "Player" FROM "table_1036" WHERE "Extra points" = '12'
0.05957
CREATE TABLE table_name_90 (ages VARCHAR, capacity VARCHAR, ofsted VARCHAR)
Which Ages have a Capacity larger than 21, and an Ofsted of 106168?
SELECT ages FROM table_name_90 WHERE capacity > 21 AND ofsted = 106168
SELECT "ages" FROM "table_name_90" WHERE "capacity" > 21 AND "ofsted" = 106168
0.076172
CREATE TABLE table_54207 ("Record" TEXT, "Date" TEXT, "Driver" TEXT, "Time" TEXT, "Speed/Avg. Speed" TEXT)
Which driver set the Qualifying record with a time of 24.761 seconds?
SELECT "Driver" FROM table_54207 WHERE "Record" = 'qualifying' AND "Time" = '24.761'
SELECT "Driver" FROM "table_54207" WHERE "Record" = 'qualifying' AND "Time" = '24.761'
0.083984
CREATE TABLE table_name_8 (goals INT, division VARCHAR, team VARCHAR, country VARCHAR)
What is the total number of goals that the Partizan team from the country of serbia had that was larger than 1?
SELECT SUM(goals) FROM table_name_8 WHERE team = "partizan" AND country = "serbia" AND division > 1
SELECT SUM("goals") FROM "table_name_8" WHERE "country" = "serbia" AND "division" > 1 AND "partizan" = "team"
0.106445
CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label 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 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 chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_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 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) 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 inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount 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 labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME)
how much bag is prescribed to patient 9338 in total until 07/2104?
SELECT SUM(prescriptions.dose_val_rx) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 9338) AND prescriptions.drug = 'bag' AND STRFTIME('%y-%m', prescriptions.startdate) <= '2104-07'
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 9338 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" = 'bag' AND NOT "_u_0"."" IS NULL AND STRFTIME('%y-%m', "prescriptions"."startdate") <= '2104-07'
0.371094
CREATE TABLE table_name_78 (year VARCHAR, day_of_week VARCHAR, rank VARCHAR)
What is the year of the movie with an opening day on Friday with a rank 10?
SELECT COUNT(year) FROM table_name_78 WHERE day_of_week = "friday" AND rank = 10
SELECT COUNT("year") FROM "table_name_78" WHERE "day_of_week" = "friday" AND "rank" = 10
0.085938
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, show me about the distribution of founder and the average of code , and group by attribute founder in a bar chart, rank x-axis from low to high order.
SELECT T2.Founder, T1.Code FROM Products AS T1 JOIN Manufacturers AS T2 ON T1.Manufacturer = T2.Code GROUP BY T2.Founder ORDER BY T2.Founder
SELECT "T2"."Founder", "T1"."Code" FROM "Products" AS "T1" JOIN "Manufacturers" AS "T2" ON "T1"."Manufacturer" = "T2"."Code" GROUP BY "T2"."Founder" ORDER BY "T2"."Founder" NULLS FIRST
0.179688
CREATE TABLE table_13044 ("Week" FLOAT, "Date" TEXT, "Opponent" TEXT, "Result" TEXT, "Attendance" TEXT)
What week was the December 24, 1994 game?
SELECT SUM("Week") FROM table_13044 WHERE "Date" = 'december 24, 1994'
SELECT SUM("Week") FROM "table_13044" WHERE "Date" = 'december 24, 1994'
0.070313
CREATE TABLE table_name_57 (engine VARCHAR, year VARCHAR, chassis VARCHAR)
Name the engine for years before 1990 and chassis of eurobrun er189
SELECT engine FROM table_name_57 WHERE year < 1990 AND chassis = "eurobrun er189"
SELECT "engine" FROM "table_name_57" WHERE "chassis" = "eurobrun er189" AND "year" < 1990
0.086914
CREATE TABLE table_28697228_4 (total_offense INT, opponent VARCHAR)
What is the number of total offense when the opponentis Penn State?
SELECT MAX(total_offense) FROM table_28697228_4 WHERE opponent = "Penn State"
SELECT MAX("total_offense") FROM "table_28697228_4" WHERE "Penn State" = "opponent"
0.081055
CREATE TABLE player_award (player_id TEXT, award_id TEXT, year INT, league_id TEXT, tie TEXT, notes TEXT) CREATE TABLE team_half (year INT, league_id TEXT, team_id TEXT, half INT, div_id TEXT, div_win TEXT, rank INT, g INT, w INT, l INT) CREATE TABLE pitching_postseason (player_id TEXT, year INT, round TEXT, team_id TEXT, league_id TEXT, w INT, l INT, g INT, gs INT, cg INT, sho INT, sv INT, ipouts INT, h INT, er INT, hr INT, bb INT, so INT, baopp TEXT, era DECIMAL, ibb DECIMAL, wp DECIMAL, hbp DECIMAL, bk DECIMAL, bfp DECIMAL, gf INT, r INT, sh DECIMAL, sf DECIMAL, g_idp DECIMAL) CREATE TABLE manager_award_vote (award_id TEXT, year INT, league_id TEXT, player_id TEXT, points_won INT, points_max INT, votes_first INT) CREATE TABLE all_star (player_id TEXT, year INT, game_num INT, game_id TEXT, team_id TEXT, league_id TEXT, gp DECIMAL, starting_pos DECIMAL) CREATE TABLE player (player_id TEXT, birth_year DECIMAL, birth_month DECIMAL, birth_day DECIMAL, birth_country TEXT, birth_state TEXT, birth_city TEXT, death_year DECIMAL, death_month DECIMAL, death_day DECIMAL, death_country TEXT, death_state TEXT, death_city TEXT, name_first TEXT, name_last TEXT, name_given TEXT, weight DECIMAL, height DECIMAL, bats TEXT, throws TEXT, debut TEXT, final_game TEXT, retro_id TEXT, bbref_id TEXT) CREATE TABLE postseason (year INT, round TEXT, team_id_winner TEXT, league_id_winner TEXT, team_id_loser TEXT, league_id_loser TEXT, wins INT, losses INT, ties INT) CREATE TABLE college (college_id TEXT, name_full TEXT, city TEXT, state TEXT, country TEXT) CREATE TABLE appearances (year INT, team_id TEXT, league_id TEXT, player_id TEXT, g_all DECIMAL, gs DECIMAL, g_batting INT, g_defense DECIMAL, g_p INT, g_c INT, g_1b INT, g_2b INT, g_3b INT, g_ss INT, g_lf INT, g_cf INT, g_rf INT, g_of INT, g_dh DECIMAL, g_ph DECIMAL, g_pr DECIMAL) CREATE TABLE fielding (player_id TEXT, year INT, stint INT, team_id TEXT, league_id TEXT, pos TEXT, g INT, gs DECIMAL, inn_outs DECIMAL, po DECIMAL, a DECIMAL, e DECIMAL, dp DECIMAL, pb DECIMAL, wp DECIMAL, sb DECIMAL, cs DECIMAL, zr DECIMAL) CREATE TABLE pitching (player_id TEXT, year INT, stint INT, team_id TEXT, league_id TEXT, w INT, l INT, g INT, gs INT, cg INT, sho INT, sv INT, ipouts DECIMAL, h INT, er INT, hr INT, bb INT, so INT, baopp DECIMAL, era DECIMAL, ibb DECIMAL, wp DECIMAL, hbp DECIMAL, bk INT, bfp DECIMAL, gf DECIMAL, r INT, sh DECIMAL, sf DECIMAL, g_idp DECIMAL) CREATE TABLE manager_half (player_id TEXT, year INT, team_id TEXT, league_id TEXT, inseason INT, half INT, g INT, w INT, l INT, rank INT) CREATE TABLE hall_of_fame (player_id TEXT, yearid INT, votedby TEXT, ballots DECIMAL, needed DECIMAL, votes DECIMAL, inducted TEXT, category TEXT, needed_note TEXT) CREATE TABLE batting_postseason (year INT, round TEXT, player_id TEXT, team_id TEXT, league_id TEXT, g INT, ab INT, r INT, h INT, double INT, triple INT, hr INT, rbi INT, sb INT, cs DECIMAL, bb INT, so INT, ibb DECIMAL, hbp DECIMAL, sh DECIMAL, sf DECIMAL, g_idp DECIMAL) CREATE TABLE manager_award (player_id TEXT, award_id TEXT, year INT, league_id TEXT, tie TEXT, notes DECIMAL) CREATE TABLE park (park_id TEXT, park_name TEXT, park_alias TEXT, city TEXT, state TEXT, country TEXT) CREATE TABLE team (year INT, league_id TEXT, team_id TEXT, franchise_id TEXT, div_id TEXT, rank INT, g INT, ghome DECIMAL, w INT, l INT, div_win TEXT, wc_win TEXT, lg_win TEXT, ws_win TEXT, r INT, ab INT, h INT, double INT, triple INT, hr INT, bb INT, so DECIMAL, sb DECIMAL, cs DECIMAL, hbp DECIMAL, sf DECIMAL, ra INT, er INT, era DECIMAL, cg INT, sho INT, sv INT, ipouts INT, ha INT, hra INT, bba INT, soa INT, e INT, dp DECIMAL, fp DECIMAL, name TEXT, park TEXT, attendance DECIMAL, bpf INT, ppf INT, team_id_br TEXT, team_id_lahman45 TEXT, team_id_retro TEXT) CREATE TABLE home_game (year INT, league_id TEXT, team_id TEXT, park_id TEXT, span_first TEXT, span_last TEXT, games INT, openings INT, attendance INT) CREATE TABLE salary (year INT, team_id TEXT, league_id TEXT, player_id TEXT, salary INT) CREATE TABLE player_college (player_id TEXT, college_id TEXT, year INT) CREATE TABLE batting (player_id TEXT, year INT, stint INT, team_id TEXT, league_id TEXT, g INT, ab DECIMAL, r DECIMAL, h DECIMAL, double DECIMAL, triple DECIMAL, hr DECIMAL, rbi DECIMAL, sb DECIMAL, cs DECIMAL, bb DECIMAL, so DECIMAL, ibb DECIMAL, hbp DECIMAL, sh DECIMAL, sf DECIMAL, g_idp DECIMAL) CREATE TABLE player_award_vote (award_id TEXT, year INT, league_id TEXT, player_id TEXT, points_won DECIMAL, points_max INT, votes_first DECIMAL) CREATE TABLE fielding_postseason (player_id TEXT, year INT, team_id TEXT, league_id TEXT, round TEXT, pos TEXT, g INT, gs DECIMAL, inn_outs DECIMAL, po INT, a INT, e INT, dp INT, tp INT, pb DECIMAL, sb DECIMAL, cs DECIMAL) CREATE TABLE manager (player_id TEXT, year INT, team_id TEXT, league_id TEXT, inseason INT, g INT, w INT, l INT, rank DECIMAL, plyr_mgr TEXT) CREATE TABLE fielding_outfield (player_id TEXT, year INT, stint INT, glf DECIMAL, gcf DECIMAL, grf DECIMAL) CREATE TABLE team_franchise (franchise_id TEXT, franchise_name TEXT, active TEXT, na_assoc TEXT)
For each year, bin the year into day of the week interval, and return the average of the number of times the team Boston Red Stockings won in the postseasons using a line chart, order X in desc order please.
SELECT year, AVG(COUNT(*)) FROM postseason AS T1 JOIN team AS T2 ON T1.team_id_winner = T2.team_id_br WHERE T2.name = 'Boston Red Stockings' ORDER BY year DESC
SELECT "year", AVG(COUNT(*)) FROM "postseason" AS "T1" JOIN "team" AS "T2" ON "T1"."team_id_winner" = "T2"."team_id_br" AND "T2"."name" = 'Boston Red Stockings' ORDER BY "year" DESC NULLS LAST
0.1875
CREATE TABLE table_28138035_20 (year_location VARCHAR, mens_doubles VARCHAR)
How many years did lin gaoyuan wu jiaji play mens doubles?
SELECT COUNT(year_location) FROM table_28138035_20 WHERE mens_doubles = "Lin Gaoyuan Wu Jiaji"
SELECT COUNT("year_location") FROM "table_28138035_20" WHERE "Lin Gaoyuan Wu Jiaji" = "mens_doubles"
0.097656
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 d_labitems (row_id DECIMAL, itemid DECIMAL, label 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 d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto 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 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 cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL) CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount 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 procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime 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 diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime 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 hours have passed since last time during their current hospital visit patient 68280 stayed in the ward 57?
SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', transfers.intime)) FROM transfers WHERE transfers.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 68280 AND admissions.dischtime IS NULL)) AND transfers.wardid = 57 ORDER BY transfers.intime DESC LIMIT 1
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."dischtime" IS NULL AND "admissions"."subject_id" = 68280 GROUP BY "hadm_id"), "_u_1" AS (SELECT "icustays"."icustay_id" FROM "icustays" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "icustays"."hadm_id" WHERE NOT "_u_0"."" IS NULL GROUP BY "icustay_id") SELECT 24 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', "transfers"."intime")) FROM "transfers" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "transfers"."icustay_id" WHERE "transfers"."wardid" = 57 AND NOT "_u_1"."" IS NULL ORDER BY "transfers"."intime" DESC NULLS LAST LIMIT 1
0.598633
CREATE TABLE aircraft (aid DECIMAL, name VARCHAR, distance DECIMAL) CREATE TABLE flight (flno DECIMAL, origin VARCHAR, destination VARCHAR, distance DECIMAL, departure_date DATE, arrival_date DATE, price DECIMAL, aid DECIMAL) CREATE TABLE employee (eid DECIMAL, name VARCHAR, salary DECIMAL) CREATE TABLE certificate (eid DECIMAL, aid DECIMAL)
Show all destinations and the number of flights to each destination Plot them as bar chart, list by the x axis in ascending.
SELECT destination, COUNT(*) FROM flight GROUP BY destination ORDER BY destination
SELECT "destination", COUNT(*) FROM "flight" GROUP BY "destination" ORDER BY "destination" NULLS FIRST
0.099609
CREATE TABLE table_36149 ("Week" FLOAT, "Date" TEXT, "Opponent" TEXT, "Result" TEXT, "Record" TEXT, "Game Site" TEXT, "Attendance" TEXT)
Who did the Colts play against on September 25, 1966?
SELECT "Opponent" FROM table_36149 WHERE "Date" = 'september 25, 1966'
SELECT "Opponent" FROM "table_36149" WHERE "Date" = 'september 25, 1966'
0.070313
CREATE TABLE projects (code TEXT, name TEXT, hours DECIMAL) CREATE TABLE assignedto (scientist DECIMAL, project TEXT) CREATE TABLE scientists (ssn DECIMAL, name TEXT)
How many different scientists are assigned to any project?
SELECT COUNT(DISTINCT scientist) FROM assignedto
SELECT COUNT(DISTINCT "scientist") FROM "assignedto"
0.050781
CREATE TABLE table_200_31 (id DECIMAL, "result" TEXT, "record" TEXT, "opponent" TEXT, "method" TEXT, "date" TEXT, "round" DECIMAL, "time" TEXT, "event" TEXT, "location" TEXT, "notes" TEXT)
who was the only person that scheider lost against ?
SELECT "opponent" FROM table_200_31 WHERE "result" = 'loss'
SELECT "opponent" FROM "table_200_31" WHERE "result" = 'loss'
0.05957
CREATE TABLE table_37058 ("Player" TEXT, "Team" TEXT, "Score" TEXT, "Versus" TEXT, "Year" FLOAT)
what team's score is 101?
SELECT "Team" FROM table_37058 WHERE "Score" = '101'
SELECT "Team" FROM "table_37058" WHERE "Score" = '101'
0.052734
CREATE TABLE table_56936 ("Episode" TEXT, "Rating" FLOAT, "Share" FLOAT, "18\\u201349 ( Rating/Share ) " TEXT, "Viewers ( m ) " FLOAT)
What is the average Viewers (m) for 'aka', with a Rating larger than 3.3?
SELECT AVG("Viewers (m)") FROM table_56936 WHERE "Episode" = 'aka' AND "Rating" > '3.3'
SELECT AVG("Viewers (m)") FROM "table_56936" WHERE "Episode" = 'aka' AND "Rating" > '3.3'
0.086914
CREATE TABLE table_50030 ("Date" TEXT, "Venue" TEXT, "Score" TEXT, "Result" TEXT, "Competition" TEXT)
What was the Venue in 2003?
SELECT "Venue" FROM table_50030 WHERE "Date" = '2003'
SELECT "Venue" FROM "table_50030" WHERE "Date" = '2003'
0.053711
CREATE TABLE table_name_6 (venue VARCHAR, away_team VARCHAR)
Which Venue has an Away team of footscray?
SELECT venue FROM table_name_6 WHERE away_team = "footscray"
SELECT "venue" FROM "table_name_6" WHERE "away_team" = "footscray"
0.064453
CREATE TABLE table_name_72 (rank INT, airport VARCHAR)
What is the highest rank of Tokyo International Airport?
SELECT MAX(rank) FROM table_name_72 WHERE airport = "tokyo international airport"
SELECT MAX("rank") FROM "table_name_72" WHERE "airport" = "tokyo international airport"
0.084961
CREATE TABLE Student_Tests_Taken (registration_id INT, date_test_taken DATETIME, test_result VARCHAR) CREATE TABLE Students (student_id INT, date_of_registration DATETIME, date_of_latest_logon DATETIME, login_name VARCHAR, password VARCHAR, personal_name VARCHAR, middle_name VARCHAR, family_name VARCHAR) CREATE TABLE Subjects (subject_id INT, subject_name VARCHAR) CREATE TABLE Student_Course_Enrolment (registration_id INT, student_id INT, course_id INT, date_of_enrolment DATETIME, date_of_completion DATETIME) CREATE TABLE Course_Authors_and_Tutors (author_id INT, author_tutor_ATB VARCHAR, login_name VARCHAR, password VARCHAR, personal_name VARCHAR, middle_name VARCHAR, family_name VARCHAR, gender_mf VARCHAR, address_line_1 VARCHAR) CREATE TABLE Courses (course_id INT, author_id INT, subject_id INT, course_name VARCHAR, course_description VARCHAR)
For each distinct test result, find the number of students who got the result.
SELECT test_result, COUNT(*) FROM Student_Tests_Taken GROUP BY test_result ORDER BY COUNT(*) DESC
SELECT "test_result", COUNT(*) FROM "Student_Tests_Taken" GROUP BY "test_result" ORDER BY COUNT(*) DESC NULLS LAST
0.111328
CREATE TABLE Customer_Orders (order_id INT, customer_id INT, order_status_code VARCHAR, shipping_method_code VARCHAR, order_placed_datetime DATETIME, order_delivered_datetime DATETIME, order_shipping_charges VARCHAR) CREATE TABLE Mailshot_Campaigns (mailshot_id INT, product_category VARCHAR, mailshot_name VARCHAR, mailshot_start_date DATETIME, mailshot_end_date DATETIME) CREATE TABLE Mailshot_Customers (mailshot_id INT, customer_id INT, outcome_code VARCHAR, mailshot_customer_date DATETIME) CREATE TABLE Order_Items (item_id INT, order_item_status_code VARCHAR, order_id INT, product_id INT, item_status_code VARCHAR, item_delivered_datetime DATETIME, item_order_quantity VARCHAR) CREATE TABLE Customers (customer_id INT, payment_method VARCHAR, customer_name VARCHAR, customer_phone VARCHAR, customer_email VARCHAR, customer_address VARCHAR, customer_login VARCHAR, customer_password VARCHAR) CREATE TABLE Premises (premise_id INT, premises_type VARCHAR, premise_details VARCHAR) CREATE TABLE Products (product_id INT, product_category VARCHAR, product_name VARCHAR) CREATE TABLE Customer_Addresses (customer_id INT, premise_id INT, date_address_from DATETIME, address_type_code VARCHAR, date_address_to DATETIME)
Show me the total number by outcome code in a histogram, sort by the X in ascending.
SELECT outcome_code, COUNT(*) FROM Mailshot_Customers GROUP BY outcome_code ORDER BY outcome_code
SELECT "outcome_code", COUNT(*) FROM "Mailshot_Customers" GROUP BY "outcome_code" ORDER BY "outcome_code" NULLS FIRST
0.114258
CREATE TABLE table_204_602 (id DECIMAL, "name" TEXT, "position" TEXT, "height" TEXT, "weight" DECIMAL, "date of birth" TEXT, "current/last known team" TEXT)
which all time player is after derek cockroft ?
SELECT "name" FROM table_204_602 WHERE id = (SELECT id FROM table_204_602 WHERE "name" = 'derek cockroft') + 1
SELECT "name" FROM "table_204_602" WHERE "id" = (SELECT "id" FROM "table_204_602" WHERE "name" = 'derek cockroft') + 1
0.115234
CREATE TABLE table_58817 ("Tie no" TEXT, "Home team" TEXT, "Score" TEXT, "Away team" TEXT, "Date" TEXT)
What is the away team playing at Everton?
SELECT "Away team" FROM table_58817 WHERE "Home team" = 'everton'
SELECT "Away team" FROM "table_58817" WHERE "Home team" = 'everton'
0.06543
CREATE TABLE table_203_293 (id DECIMAL, "years of appearance" TEXT, "title" TEXT, "network" TEXT, "character name" TEXT, "actor" TEXT, "notes" TEXT)
who was the first character on abc to be hiv positive ?
SELECT "character name" FROM table_203_293 WHERE "network" = 'abc' ORDER BY "years of appearance" LIMIT 1
SELECT "character name" FROM "table_203_293" WHERE "network" = 'abc' ORDER BY "years of appearance" NULLS FIRST LIMIT 1
0.116211
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 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 outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL) CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) 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 cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE admissions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, admittime TIME, dischtime TIME, admission_type TEXT, admission_location TEXT, discharge_location TEXT, insurance TEXT, language TEXT, marital_status TEXT, ethnicity TEXT, age DECIMAL) CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto 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 d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) 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 patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME) 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)
for the first time, what procedure did until 2103 patient 78221 receive?
SELECT d_icd_procedures.short_title FROM d_icd_procedures WHERE d_icd_procedures.icd9_code IN (SELECT procedures_icd.icd9_code FROM procedures_icd WHERE procedures_icd.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 78221) AND STRFTIME('%y', procedures_icd.charttime) <= '2103' ORDER BY procedures_icd.charttime LIMIT 1)
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 78221 GROUP BY "hadm_id") SELECT "d_icd_procedures"."short_title" FROM "d_icd_procedures" WHERE "d_icd_procedures"."icd9_code" IN (SELECT "procedures_icd"."icd9_code" FROM "procedures_icd" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "procedures_icd"."hadm_id" WHERE NOT "_u_0"."" IS NULL AND STRFTIME('%y', "procedures_icd"."charttime") <= '2103' ORDER BY "procedures_icd"."charttime" NULLS FIRST LIMIT 1)
0.489258
CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE 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)
count the number of patients less than 44 years who take drug via nu route.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.age < "44" AND prescriptions.route = "NU"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" JOIN "prescriptions" ON "NU" = "prescriptions"."route" AND "demographic"."hadm_id" = "prescriptions"."hadm_id" WHERE "44" > "demographic"."age"
0.207031
CREATE TABLE table_43955 ("Constellation" TEXT, "Largest component , fractional share" FLOAT, "Other components , fractional shares" TEXT, "N , Laakso-Taagepera" FLOAT, "N , Golosov" FLOAT)
What is the average Largest Component, Fractional Share, when N, Laakso-Taagepera is 1.98, and when N, Golosov is greater than 1.82?
SELECT AVG("Largest component, fractional share") FROM table_43955 WHERE "N, Laakso-Taagepera" = '1.98' AND "N, Golosov" > '1.82'
SELECT AVG("Largest component, fractional share") FROM "table_43955" WHERE "N, Golosov" > '1.82' AND "N, Laakso-Taagepera" = '1.98'
0.12793
CREATE TABLE table_39224 ("District" TEXT, "Incumbent" TEXT, "Party" TEXT, "First elected" FLOAT, "Result" TEXT)
In the Ohio 4 district, that is the first elected date that has a result of re-elected?
SELECT SUM("First elected") FROM table_39224 WHERE "Result" = 're-elected' AND "District" = 'ohio 4'
SELECT SUM("First elected") FROM "table_39224" WHERE "District" = 'ohio 4' AND "Result" = 're-elected'
0.099609
CREATE TABLE table_36800 ("Player" TEXT, "Attempts" FLOAT, "Yards" FLOAT, "Average" FLOAT, "Long" FLOAT, "Touchdowns" FLOAT)
What is the least amount of yards when the average is less than 2.6?
SELECT MIN("Yards") FROM table_36800 WHERE "Average" < '2.6'
SELECT MIN("Yards") FROM "table_36800" WHERE "Average" < '2.6'
0.060547
CREATE TABLE patients (row_id DECIMAL, subject_id DECIMAL, gender TEXT, dob TIME, dod TIME) CREATE TABLE d_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE 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 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 chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_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 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 inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) 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 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 procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL)
what are the top four most frequent medications that followed during the same hospital visit for patients who were given entral infus nutrit sub during this year?
SELECT t3.drug FROM (SELECT t2.drug, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM (SELECT admissions.subject_id, procedures_icd.charttime, admissions.hadm_id 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 DATETIME(procedures_icd.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t1 JOIN (SELECT admissions.subject_id, prescriptions.drug, prescriptions.startdate, admissions.hadm_id FROM prescriptions JOIN admissions ON prescriptions.hadm_id = admissions.hadm_id WHERE DATETIME(prescriptions.startdate, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.startdate AND t1.hadm_id = t2.hadm_id GROUP BY t2.drug) AS t3 WHERE t3.c1 <= 4
WITH "t2" AS (SELECT "admissions"."subject_id", "prescriptions"."drug", "prescriptions"."startdate", "admissions"."hadm_id" FROM "prescriptions" JOIN "admissions" ON "admissions"."hadm_id" = "prescriptions"."hadm_id" WHERE DATETIME("prescriptions"."startdate", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year')), "t3" AS (SELECT "t2"."drug", DENSE_RANK() OVER (ORDER BY COUNT(*) DESC NULLS LAST) AS "c1" 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" JOIN "t2" AS "t2" ON "admissions"."hadm_id" = "t2"."hadm_id" AND "admissions"."subject_id" = "t2"."subject_id" AND "procedures_icd"."charttime" < "t2"."startdate" WHERE DATETIME("procedures_icd"."charttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-0 year') GROUP BY "t2"."drug") SELECT "t3"."drug" FROM "t3" AS "t3" WHERE "t3"."c1" <= 4
1.009766
CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_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 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) CREATE TABLE transfers (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, eventtype TEXT, careunit TEXT, wardid DECIMAL, intime TIME, outtime TIME) CREATE TABLE chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL) CREATE TABLE d_icd_diagnoses (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 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 d_icd_procedures (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) 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 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 microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT)
count the number of patients who have received a opn mitral valvuloplasty procedure in the same month after having had a left heart cardiac cath procedure since 6 years ago.
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 = 'left heart cardiac cath') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year')) 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 = 'opn mitral valvuloplasty') AND DATETIME(procedures_icd.charttime) >= DATETIME(CURRENT_TIME(), '-6 year')) AS t2 ON t1.subject_id = t2.subject_id WHERE t1.charttime < t2.charttime AND DATETIME(t1.charttime, 'start of month') = DATETIME(t2.charttime, 'start of month')
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" = 'opn mitral valvuloplasty' JOIN "admissions" ON "admissions"."hadm_id" = "procedures_icd"."hadm_id" WHERE DATETIME("procedures_icd"."charttime") >= DATETIME(CURRENT_TIME(), '-6 year')) 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" = 'left heart cardiac cath' 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", 'start of month') = DATETIME("t2"."charttime", 'start of month') WHERE DATETIME("procedures_icd"."charttime") >= DATETIME(CURRENT_TIME(), '-6 year')
0.996094
CREATE TABLE table_name_72 (to_par VARCHAR, player VARCHAR)
What is To par, when Player is 'Greg Turner'?
SELECT to_par FROM table_name_72 WHERE player = "greg turner"
SELECT "to_par" FROM "table_name_72" WHERE "greg turner" = "player"
0.06543
CREATE TABLE table_name_21 (attendance VARCHAR, game_site VARCHAR)
What was the attendance of the Cup Quarterfinals game?
SELECT attendance FROM table_name_21 WHERE game_site = "cup quarterfinals"
SELECT "attendance" FROM "table_name_21" WHERE "cup quarterfinals" = "game_site"
0.078125
CREATE TABLE table_name_72 (placings VARCHAR, total VARCHAR, name VARCHAR)
How many placings did Jacqueline du Bief earn where her total score is greater than 131.26?
SELECT placings FROM table_name_72 WHERE total > 131.26 AND name = "jacqueline du bief"
SELECT "placings" FROM "table_name_72" WHERE "jacqueline du bief" = "name" AND "total" > 131.26
0.092773
CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) 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 patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME)
what was the name of the drug to which patient 015-7988 had an allergic reaction?
SELECT allergy.drugname FROM allergy WHERE allergy.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '015-7988'))
WITH "_u_0" AS (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '015-7988' 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 "allergy"."drugname" FROM "allergy" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "allergy"."patientunitstayid" WHERE NOT "_u_1"."" IS NULL
0.487305
CREATE TABLE table_name_73 (score VARCHAR, away_team VARCHAR)
What did the Melbourne Tigers score when they were the away team?
SELECT score FROM table_name_73 WHERE away_team = "melbourne tigers"
SELECT "score" FROM "table_name_73" WHERE "away_team" = "melbourne tigers"
0.072266
CREATE TABLE table_1276 ("Con- gress" TEXT, "District" TEXT, "Vacator" TEXT, "Election date" TEXT, "Successor" TEXT, "Took seat" TEXT)
Name the vacator for took seat being january 29, 1813
SELECT "Vacator" FROM table_1276 WHERE "Took seat" = 'January 29, 1813'
SELECT "Vacator" FROM "table_1276" WHERE "Took seat" = 'January 29, 1813'
0.071289
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_items (row_id DECIMAL, itemid DECIMAL, label TEXT, linksto TEXT) CREATE TABLE chartevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE cost (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, event_type TEXT, event_id DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE labevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, itemid DECIMAL, charttime TIME, valuenum DECIMAL, valueuom TEXT) CREATE TABLE d_labitems (row_id DECIMAL, itemid DECIMAL, label TEXT) CREATE TABLE microbiologyevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, charttime TIME, spec_type_desc TEXT, org_name TEXT) CREATE TABLE 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 prescriptions (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, startdate TIME, enddate TIME, drug TEXT, dose_val_rx TEXT, dose_unit_rx TEXT, route TEXT) CREATE TABLE inputevents_cv (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, amount DECIMAL) CREATE TABLE d_icd_diagnoses (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE diagnoses_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE d_icd_procedures (row_id DECIMAL, icd9_code TEXT, short_title TEXT, long_title 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 procedures_icd (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icd9_code TEXT, charttime TIME) CREATE TABLE outputevents (row_id DECIMAL, subject_id DECIMAL, hadm_id DECIMAL, icustay_id DECIMAL, charttime TIME, itemid DECIMAL, value DECIMAL)
in 02/last year had patient 26195 had any intake of lactated ringers?
SELECT COUNT(*) > 0 FROM inputevents_cv WHERE inputevents_cv.icustay_id IN (SELECT icustays.icustay_id FROM icustays WHERE icustays.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 26195)) AND inputevents_cv.itemid IN (SELECT d_items.itemid FROM d_items WHERE d_items.label = 'lactated ringers' AND d_items.linksto = 'inputevents_cv') AND DATETIME(inputevents_cv.charttime, 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND STRFTIME('%m', inputevents_cv.charttime) = '02'
WITH "_u_0" AS (SELECT "admissions"."hadm_id" FROM "admissions" WHERE "admissions"."subject_id" = 26195 GROUP BY "hadm_id"), "_u_1" AS (SELECT "icustays"."icustay_id" FROM "icustays" LEFT JOIN "_u_0" AS "_u_0" ON "_u_0"."" = "icustays"."hadm_id" WHERE NOT "_u_0"."" IS NULL GROUP BY "icustay_id"), "_u_2" AS (SELECT "d_items"."itemid" FROM "d_items" WHERE "d_items"."label" = 'lactated ringers' AND "d_items"."linksto" = 'inputevents_cv' GROUP BY "itemid") SELECT COUNT(*) > 0 FROM "inputevents_cv" LEFT JOIN "_u_1" AS "_u_1" ON "_u_1"."" = "inputevents_cv"."icustay_id" LEFT JOIN "_u_2" AS "_u_2" ON "_u_2"."" = "inputevents_cv"."itemid" WHERE DATETIME("inputevents_cv"."charttime", 'start of year') = DATETIME(CURRENT_TIME(), 'start of year', '-1 year') AND NOT "_u_1"."" IS NULL AND NOT "_u_2"."" IS NULL AND STRFTIME('%m', "inputevents_cv"."charttime") = '02'
0.842773
CREATE TABLE PostFeedback (Id DECIMAL, PostId DECIMAL, IsAnonymous BOOLEAN, VoteTypeId DECIMAL, CreationDate TIME) CREATE TABLE ReviewRejectionReasons (Id DECIMAL, Name TEXT, Description TEXT, PostTypeId DECIMAL) CREATE TABLE PostHistoryTypes (Id DECIMAL, Name TEXT) CREATE TABLE FlagTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE Tags (Id DECIMAL, TagName TEXT, Count DECIMAL, ExcerptPostId DECIMAL, WikiPostId 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 PostLinks (Id DECIMAL, CreationDate TIME, PostId DECIMAL, RelatedPostId DECIMAL, LinkTypeId DECIMAL) CREATE TABLE PostsWithDeleted (Id DECIMAL, PostTypeId DECIMAL, AcceptedAnswerId DECIMAL, ParentId DECIMAL, CreationDate TIME, DeletionDate TIME, Score DECIMAL, ViewCount DECIMAL, Body TEXT, OwnerUserId DECIMAL, OwnerDisplayName TEXT, LastEditorUserId DECIMAL, LastEditorDisplayName TEXT, LastEditDate TIME, LastActivityDate TIME, Title TEXT, Tags TEXT, AnswerCount DECIMAL, CommentCount DECIMAL, FavoriteCount DECIMAL, ClosedDate TIME, CommunityOwnedDate TIME, ContentLicense TEXT) CREATE TABLE 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 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 VoteTypes (Id DECIMAL, Name TEXT) CREATE TABLE ReviewTaskTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE ReviewTaskResultTypes (Id DECIMAL, Name TEXT, Description TEXT) CREATE TABLE ReviewTaskStates (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 CloseReasonTypes (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 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 SuggestedEditVotes (Id DECIMAL, SuggestedEditId DECIMAL, UserId DECIMAL, VoteTypeId DECIMAL, CreationDate TIME, TargetUserId DECIMAL, TargetRepChange DECIMAL) 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 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 PostTags (PostId DECIMAL, TagId DECIMAL) CREATE TABLE PostNotices (Id DECIMAL, PostId DECIMAL, PostNoticeTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ExpiryDate TIME, Body TEXT, OwnerUserId DECIMAL, DeletionUserId DECIMAL) CREATE TABLE Votes (Id DECIMAL, PostId DECIMAL, VoteTypeId DECIMAL, UserId DECIMAL, CreationDate TIME, BountyAmount DECIMAL) CREATE TABLE ReviewTaskResults (Id DECIMAL, ReviewTaskId DECIMAL, ReviewTaskResultTypeId DECIMAL, CreationDate TIME, RejectionReasonId DECIMAL, Comment TEXT) CREATE TABLE ReviewTasks (Id DECIMAL, ReviewTaskTypeId DECIMAL, CreationDate TIME, DeletionDate TIME, ReviewTaskStateId DECIMAL, PostId DECIMAL, SuggestedEditId DECIMAL, CompletedByReviewTaskId DECIMAL) CREATE TABLE Badges (Id DECIMAL, UserId DECIMAL, Name TEXT, Date TIME, Class DECIMAL, TagBased BOOLEAN)
Edits by a given user with edit summary containing given work.
SELECT PostId AS "post_link", Comment, UserId AS "user_link", CreationDate, url = 'site://posts/' + CAST(PostId AS TEXT) + '/revisions' FROM PostHistory WHERE UserId = '##id##' ORDER BY CreationDate
SELECT "PostId" AS "post_link", "Comment", "UserId" AS "user_link", "CreationDate", "url" = CONCAT(CONCAT('site://posts/', CAST("PostId" AS TEXT)), '/revisions') FROM "PostHistory" WHERE "UserId" = '##id##' ORDER BY "CreationDate" NULLS FIRST
0.236328
CREATE TABLE table_32869 ("Home team" TEXT, "Home team score" TEXT, "Away team" TEXT, "Away team score" TEXT, "Venue" TEXT, "Crowd" FLOAT, "Date" TEXT)
What was the away team when the home team scored 10.10 (70)?
SELECT "Away team" FROM table_32869 WHERE "Home team score" = '10.10 (70)'
SELECT "Away team" FROM "table_32869" WHERE "Home team score" = '10.10 (70)'
0.074219
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 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)
what is the maximum age of patients whose admission location is phys referral/normal delivery and stayed in hospital for 27 days?
SELECT MAX(demographic.age) FROM demographic WHERE demographic.admission_location = "PHYS REFERRAL/NORMAL DELI" AND demographic.days_stay = "27"
SELECT MAX("demographic"."age") FROM "demographic" WHERE "27" = "demographic"."days_stay" AND "PHYS REFERRAL/NORMAL DELI" = "demographic"."admission_location"
0.154297
CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID DECIMAL) CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_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 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 locations (LOCATION_ID DECIMAL, STREET_ADDRESS VARCHAR, POSTAL_CODE VARCHAR, CITY VARCHAR, STATE_PROVINCE VARCHAR, COUNTRY_ID VARCHAR) CREATE TABLE regions (REGION_ID DECIMAL, REGION_NAME VARCHAR)
For those employees whose salary is in the range of 8000 and 12000 and commission is not null or department number does not equal to 40, find job_id and the average of employee_id , and group by attribute job_id, and visualize them by a bar chart, I want to display from low to high by the y axis.
SELECT JOB_ID, AVG(EMPLOYEE_ID) FROM employees WHERE SALARY BETWEEN 8000 AND 12000 AND COMMISSION_PCT <> "null" OR DEPARTMENT_ID <> 40 GROUP BY JOB_ID ORDER BY AVG(EMPLOYEE_ID)
SELECT "JOB_ID", AVG("EMPLOYEE_ID") FROM "employees" WHERE ("COMMISSION_PCT" <> "null" OR "DEPARTMENT_ID" <> 40) AND ("DEPARTMENT_ID" <> 40 OR "SALARY" <= 12000) AND ("DEPARTMENT_ID" <> 40 OR "SALARY" >= 8000) GROUP BY "JOB_ID" ORDER BY AVG("EMPLOYEE_ID") NULLS FIRST
0.260742
CREATE TABLE table_26250253_1 (order__number VARCHAR, week__number VARCHAR)
The order # is what for the week # Top 10?
SELECT order__number FROM table_26250253_1 WHERE week__number = "Top 10"
SELECT "order__number" FROM "table_26250253_1" WHERE "Top 10" = "week__number"
0.076172
CREATE TABLE table_name_55 (seats INT, share_of_votes VARCHAR)
What is the lowest number of seats from the election with 27.0% of votes?
SELECT MIN(seats) FROM table_name_55 WHERE share_of_votes = "27.0%"
SELECT MIN("seats") FROM "table_name_55" WHERE "27.0%" = "share_of_votes"
0.071289
CREATE TABLE table_671 ("Year" FLOAT, "Finish position" TEXT, "1st day" TEXT, "2nd day" TEXT, "3rd day" TEXT, "4th Day" TEXT)
what is the maximum year with 3rd day being rowed-over
SELECT MAX("Year") FROM table_671 WHERE "3rd day" = 'rowed-over'
SELECT MAX("Year") FROM "table_671" WHERE "3rd day" = 'rowed-over'
0.064453
CREATE TABLE table_38160 ("City" TEXT, "Country" TEXT, "IATA" TEXT, "ICAO" TEXT, "Airport" TEXT)
What is the ICAO when the IATA shows mfm?
SELECT "ICAO" FROM table_38160 WHERE "IATA" = 'mfm'
SELECT "ICAO" FROM "table_38160" WHERE "IATA" = 'mfm'
0.051758
CREATE TABLE microlab (microlabid DECIMAL, patientunitstayid DECIMAL, culturesite TEXT, organism TEXT, culturetakentime TIME) CREATE TABLE diagnosis (diagnosisid DECIMAL, patientunitstayid DECIMAL, diagnosisname TEXT, diagnosistime TIME, icd9code TEXT) CREATE TABLE treatment (treatmentid DECIMAL, patientunitstayid DECIMAL, treatmentname TEXT, treatmenttime TIME) CREATE TABLE cost (costid DECIMAL, uniquepid TEXT, patienthealthsystemstayid DECIMAL, eventtype TEXT, eventid DECIMAL, chargetime TIME, cost DECIMAL) CREATE TABLE lab (labid DECIMAL, patientunitstayid DECIMAL, labname TEXT, labresult DECIMAL, labresulttime TIME) CREATE TABLE patient (uniquepid TEXT, patienthealthsystemstayid DECIMAL, patientunitstayid DECIMAL, gender TEXT, age TEXT, ethnicity TEXT, hospitalid DECIMAL, wardid DECIMAL, admissionheight DECIMAL, admissionweight DECIMAL, dischargeweight DECIMAL, hospitaladmittime TIME, hospitaladmitsource TEXT, unitadmittime TIME, unitdischargetime TIME, hospitaldischargetime TIME, hospitaldischargestatus TEXT) CREATE TABLE intakeoutput (intakeoutputid DECIMAL, patientunitstayid DECIMAL, cellpath TEXT, celllabel TEXT, cellvaluenumeric DECIMAL, intakeoutputtime TIME) CREATE TABLE vitalperiodic (vitalperiodicid DECIMAL, patientunitstayid DECIMAL, temperature DECIMAL, sao2 DECIMAL, heartrate DECIMAL, respiration DECIMAL, systemicsystolic DECIMAL, systemicdiastolic DECIMAL, systemicmean DECIMAL, observationtime TIME) CREATE TABLE medication (medicationid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, dosage TEXT, routeadmin TEXT, drugstarttime TIME, drugstoptime TIME) CREATE TABLE allergy (allergyid DECIMAL, patientunitstayid DECIMAL, drugname TEXT, allergyname TEXT, allergytime TIME)
what was patient 010-39202 diagnosed with first time during the first hospital visit.
SELECT diagnosis.diagnosisname FROM diagnosis WHERE diagnosis.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '010-39202' AND NOT patient.hospitaldischargetime IS NULL ORDER BY patient.hospitaladmittime LIMIT 1)) ORDER BY diagnosis.diagnosistime LIMIT 1
SELECT "diagnosis"."diagnosisname" FROM "diagnosis" WHERE "diagnosis"."patientunitstayid" IN (SELECT "patient"."patientunitstayid" FROM "patient" WHERE "patient"."patienthealthsystemstayid" IN (SELECT "patient"."patienthealthsystemstayid" FROM "patient" WHERE "patient"."uniquepid" = '010-39202' AND NOT "patient"."hospitaldischargetime" IS NULL ORDER BY "patient"."hospitaladmittime" NULLS FIRST LIMIT 1)) ORDER BY "diagnosis"."diagnosistime" NULLS FIRST LIMIT 1
0.452148
CREATE TABLE DEPARTMENT (DEPT_CODE VARCHAR, DEPT_NAME VARCHAR, SCHOOL_CODE VARCHAR, EMP_NUM INT, DEPT_ADDRESS VARCHAR, DEPT_EXTENSION VARCHAR) CREATE TABLE EMPLOYEE (EMP_NUM INT, EMP_LNAME VARCHAR, EMP_FNAME VARCHAR, EMP_INITIAL VARCHAR, EMP_JOBCODE VARCHAR, EMP_HIREDATE DATETIME, EMP_DOB DATETIME) CREATE TABLE ENROLL (CLASS_CODE VARCHAR, STU_NUM INT, ENROLL_GRADE VARCHAR) CREATE TABLE COURSE (CRS_CODE VARCHAR, DEPT_CODE VARCHAR, CRS_DESCRIPTION VARCHAR, CRS_CREDIT FLOAT) CREATE TABLE PROFESSOR (EMP_NUM INT, DEPT_CODE VARCHAR, PROF_OFFICE VARCHAR, PROF_EXTENSION VARCHAR, PROF_HIGH_DEGREE VARCHAR) CREATE TABLE CLASS (CLASS_CODE VARCHAR, CRS_CODE VARCHAR, CLASS_SECTION VARCHAR, CLASS_TIME VARCHAR, CLASS_ROOM VARCHAR, PROF_NUM INT) CREATE TABLE STUDENT (STU_NUM INT, STU_LNAME VARCHAR, STU_FNAME VARCHAR, STU_INIT VARCHAR, STU_DOB DATETIME, STU_HRS INT, STU_CLASS VARCHAR, STU_GPA FLOAT, STU_TRANSFER DECIMAL, DEPT_CODE VARCHAR, STU_PHONE VARCHAR, PROF_NUM INT)
Find the max gpa of all students in each department with a bar chart.
SELECT DEPT_CODE, MAX(STU_GPA) FROM STUDENT GROUP BY DEPT_CODE
SELECT "DEPT_CODE", MAX("STU_GPA") FROM "STUDENT" GROUP BY "DEPT_CODE"
0.068359
CREATE TABLE table_name_9 (year INT, reg_season VARCHAR)
Which Year has a Reg Season of 3rd, western?
SELECT AVG(year) FROM table_name_9 WHERE reg_season = "3rd, western"
SELECT AVG("year") FROM "table_name_9" WHERE "3rd, western" = "reg_season"
0.072266
CREATE TABLE table_79650 ("Class" TEXT, "Wheel arrangement" TEXT, "Fleet number ( s ) " TEXT, "Manufacturer" TEXT, "Serial numbers" TEXT, "Year made" TEXT, "Quantity made" TEXT, "Quantity preserved" TEXT)
what is the year made when the manufacturer is 2-6-2 oooo mogul?
SELECT "Year made" FROM table_79650 WHERE "Manufacturer" = '2-6-2 — oooo — mogul'
SELECT "Year made" FROM "table_79650" WHERE "Manufacturer" = '2-6-2 — oooo — mogul'
0.081055
CREATE TABLE table_61692 ("Date From" TEXT, "Date To" TEXT, "Position" TEXT, "Name" TEXT, "From" TEXT)
What is the date for Watford and player Lionel Ainsworth?
SELECT "Date To" FROM table_61692 WHERE "From" = 'watford' AND "Name" = 'lionel ainsworth'
SELECT "Date To" FROM "table_61692" WHERE "From" = 'watford' AND "Name" = 'lionel ainsworth'
0.089844
CREATE TABLE employee (eid DECIMAL, name VARCHAR, salary DECIMAL) CREATE TABLE certificate (eid DECIMAL, aid DECIMAL) CREATE TABLE aircraft (aid DECIMAL, name VARCHAR, distance DECIMAL) CREATE TABLE flight (flno DECIMAL, origin VARCHAR, destination VARCHAR, distance DECIMAL, departure_date DATE, arrival_date DATE, price DECIMAL, aid DECIMAL)
Draw a bar chart for what are the destinations and number of flights to each one?, and I want to display in desc by the x axis.
SELECT destination, COUNT(*) FROM flight GROUP BY destination ORDER BY destination DESC
SELECT "destination", COUNT(*) FROM "flight" GROUP BY "destination" ORDER BY "destination" DESC NULLS LAST
0.103516
CREATE TABLE table_75562 ("Name" TEXT, "Pada 1" TEXT, "Pada 2" TEXT, "Pada 3" TEXT, "Pada 4" TEXT)
Which Pada 3 has a Pada 1 of te?
SELECT "Pada 3" FROM table_75562 WHERE "Pada 1" = 'टे te'
SELECT "Pada 3" FROM "table_75562" WHERE "Pada 1" = 'टे te'
0.057617
CREATE TABLE Residents_Services (resident_id INT, service_id INT, date_moved_in DATETIME, property_id INT, date_requested DATETIME, date_provided DATETIME, other_details VARCHAR) CREATE TABLE Services (service_id INT, organization_id INT, service_type_code CHAR, service_details VARCHAR) CREATE TABLE Organizations (organization_id INT, parent_organization_id INT, organization_details VARCHAR) CREATE TABLE Timed_Locations_of_Things (thing_id INT, Date_and_Time DATETIME, Location_Code CHAR) CREATE TABLE Customer_Events (Customer_Event_ID INT, customer_id INT, date_moved_in DATETIME, property_id INT, resident_id INT, thing_id INT) CREATE TABLE Customers (customer_id INT, customer_details VARCHAR) CREATE TABLE Properties (property_id INT, property_type_code CHAR, property_address VARCHAR, other_details VARCHAR) CREATE TABLE Timed_Status_of_Things (thing_id INT, Date_and_Date DATETIME, Status_of_Thing_Code CHAR) CREATE TABLE Things (thing_id INT, organization_id INT, Type_of_Thing_Code CHAR, service_type_code CHAR, service_details VARCHAR) CREATE TABLE Residents (resident_id INT, property_id INT, date_moved_in DATETIME, date_moved_out DATETIME, other_details VARCHAR) CREATE TABLE Customer_Event_Notes (Customer_Event_Note_ID INT, Customer_Event_ID INT, service_type_code CHAR, resident_id INT, property_id INT, date_moved_in DATETIME)
Compare the number of items in the type of each thing using a bar chart, list in asc by the Y please.
SELECT Type_of_Thing_Code, COUNT(Type_of_Thing_Code) FROM Things GROUP BY Type_of_Thing_Code ORDER BY COUNT(Type_of_Thing_Code)
SELECT "Type_of_Thing_Code", COUNT("Type_of_Thing_Code") FROM "Things" GROUP BY "Type_of_Thing_Code" ORDER BY COUNT("Type_of_Thing_Code") NULLS FIRST
0.145508
CREATE TABLE table_58375 ("Date" TEXT, "Visitor" TEXT, "Score" TEXT, "Home" TEXT, "Record" TEXT)
What team was visiting on February 15?
SELECT "Visitor" FROM table_58375 WHERE "Date" = 'february 15'
SELECT "Visitor" FROM "table_58375" WHERE "Date" = 'february 15'
0.0625
CREATE TABLE table_204_399 (id DECIMAL, "outcome" TEXT, "no." DECIMAL, "year" DECIMAL, "championship" TEXT, "opponent in the final" TEXT, "score" TEXT)
in what year did he win the most titles ?
SELECT "year" FROM table_204_399 WHERE "outcome" = 'winner' GROUP BY "year" ORDER BY COUNT(*) DESC LIMIT 1
SELECT "year" FROM "table_204_399" WHERE "outcome" = 'winner' GROUP BY "year" ORDER BY COUNT(*) DESC NULLS LAST LIMIT 1
0.116211
CREATE TABLE table_name_73 (issue_price INT, special_notes VARCHAR, mintage VARCHAR)
What is the average issue price with from Toronto maple leafs gift set, and a Mintage of 3527?
SELECT AVG(issue_price) FROM table_name_73 WHERE special_notes = "from toronto maple leafs gift set" AND mintage = "3527"
SELECT AVG("issue_price") FROM "table_name_73" WHERE "3527" = "mintage" AND "from toronto maple leafs gift set" = "special_notes"
0.125977
CREATE TABLE table_53189 ("Home team" TEXT, "Home team score" TEXT, "Away team" TEXT, "Away team score" TEXT, "Venue" TEXT, "Crowd" FLOAT, "Date" TEXT)
What away team score also has a Home team score of 12.15 (87)?
SELECT "Away team score" FROM table_53189 WHERE "Home team score" = '12.15 (87)'
SELECT "Away team score" FROM "table_53189" WHERE "Home team score" = '12.15 (87)'
0.080078
CREATE TABLE table_35519 ("Rank" FLOAT, "Name" TEXT, "Height ft ( m ) " TEXT, "Floors ( Stories ) " FLOAT, "Year Completed" FLOAT)
Which is the highest ranked building with more than 15 floors?
SELECT MAX("Rank") FROM table_35519 WHERE "Floors (Stories)" > '15'
SELECT MAX("Rank") FROM "table_35519" WHERE "Floors (Stories)" > '15'
0.067383
CREATE TABLE table_name_98 (year INT, drivers VARCHAR, poles VARCHAR, fast_laps VARCHAR)
What is the average Year during which the Driver Adrian Quaife-Hobbs has fewer than 2 Poles, and 0 Fast laps?
SELECT AVG(year) FROM table_name_98 WHERE poles < 2 AND fast_laps = 0 AND drivers = "adrian quaife-hobbs"
SELECT AVG("year") FROM "table_name_98" WHERE "adrian quaife-hobbs" = "drivers" AND "fast_laps" = 0 AND "poles" < 2
0.112305
CREATE TABLE Department_Store_Chain (dept_store_chain_id INT, dept_store_chain_name VARCHAR) CREATE TABLE Staff_Department_Assignments (staff_id INT, department_id INT, date_assigned_from DATETIME, job_title_code VARCHAR, date_assigned_to DATETIME) CREATE TABLE Customer_Addresses (customer_id INT, address_id INT, date_from DATETIME, date_to DATETIME) CREATE TABLE Customers (customer_id INT, payment_method_code VARCHAR, customer_code VARCHAR, customer_name VARCHAR, customer_address VARCHAR, customer_phone VARCHAR, customer_email VARCHAR) CREATE TABLE Departments (department_id INT, dept_store_id INT, department_name VARCHAR) CREATE TABLE Order_Items (order_item_id INT, order_id INT, product_id INT) CREATE TABLE Department_Stores (dept_store_id INT, dept_store_chain_id INT, store_name VARCHAR, store_address VARCHAR, store_phone VARCHAR, store_email VARCHAR) CREATE TABLE Supplier_Addresses (supplier_id INT, address_id INT, date_from DATETIME, date_to DATETIME) CREATE TABLE Products (product_id INT, product_type_code VARCHAR, product_name VARCHAR, product_price DECIMAL) CREATE TABLE Suppliers (supplier_id INT, supplier_name VARCHAR, supplier_phone VARCHAR) CREATE TABLE Customer_Orders (order_id INT, customer_id INT, order_status_code VARCHAR, order_date DATETIME) CREATE TABLE Product_Suppliers (product_id INT, supplier_id INT, date_supplied_from DATETIME, date_supplied_to DATETIME, total_amount_purchased VARCHAR, total_value_purchased DECIMAL) CREATE TABLE Staff (staff_id INT, staff_gender VARCHAR, staff_name VARCHAR) CREATE TABLE Addresses (address_id INT, address_details VARCHAR)
Return the average price for each product type. Plot them as pie chart.
SELECT product_type_code, AVG(product_price) FROM Products GROUP BY product_type_code
SELECT "product_type_code", AVG("product_price") FROM "Products" GROUP BY "product_type_code"
0.09082
CREATE TABLE table_train_246 ("id" INT, "allergy_to_dapagliflozin" BOOLEAN, "allergy_to_exenatide" BOOLEAN, "estimated_glomerular_filtration_rate_egfr" INT, "fasting_c_peptide" FLOAT, "urine_albumin_to_creatinine_ratio_uacr" INT, "fasting_triglyceride" INT, "NOUSE" FLOAT)
fasting c _ peptide < 0.8 ng / ml
SELECT * FROM table_train_246 WHERE fasting_c_peptide < 0.8
SELECT * FROM "table_train_246" WHERE "fasting_c_peptide" < 0.8
0.061523
CREATE TABLE table_46075 ("Rank" FLOAT, "Nation" TEXT, "Gold" FLOAT, "Silver" FLOAT, "Bronze" FLOAT, "Total" FLOAT)
What is the total rank of Hungary (HUN) when the bronze medals were less than 0?
SELECT SUM("Rank") FROM table_46075 WHERE "Nation" = 'hungary (hun)' AND "Bronze" < '0'
SELECT SUM("Rank") FROM "table_46075" WHERE "Bronze" < '0' AND "Nation" = 'hungary (hun)'
0.086914
CREATE TABLE table_30265 ("Pick #" FLOAT, "CFL Team" TEXT, "Player" TEXT, "Position" TEXT, "College" TEXT)
What position was the player who was drafted by Edmonton?
SELECT "Position" FROM table_30265 WHERE "CFL Team" = 'Edmonton'
SELECT "Position" FROM "table_30265" WHERE "CFL Team" = 'Edmonton'
0.064453
CREATE TABLE lab (subject_id TEXT, hadm_id TEXT, itemid TEXT, charttime TEXT, flag TEXT, value_unit TEXT, label TEXT, fluid TEXT) CREATE TABLE demographic (subject_id TEXT, hadm_id TEXT, name TEXT, marital_status TEXT, age TEXT, dob TEXT, gender TEXT, language TEXT, religion TEXT, admission_type TEXT, days_stay TEXT, insurance TEXT, ethnicity TEXT, expire_flag TEXT, admission_location TEXT, discharge_location TEXT, diagnosis TEXT, dod TEXT, dob_year TEXT, dod_year TEXT, admittime TEXT, dischtime TEXT, admityear TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT)
find out the patients with primary disease s/p hanging having long term care hospital discharge.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.discharge_location = "LONG TERM CARE HOSPITAL" AND demographic.diagnosis = "S/P HANGING"
SELECT COUNT(DISTINCT "demographic"."subject_id") FROM "demographic" WHERE "LONG TERM CARE HOSPITAL" = "demographic"."discharge_location" AND "S/P HANGING" = "demographic"."diagnosis"
0.178711
CREATE TABLE table_204_243 (id DECIMAL, "year" DECIMAL, "album" TEXT, "song" TEXT, "duration" TEXT, "artist" TEXT)
was the song healing or the song boys and girls with trax ?
SELECT "song" FROM table_204_243 WHERE "song" IN ('"healing"', '"boys & girls"') AND "artist" = 'with trax'
SELECT "song" FROM "table_204_243" WHERE "artist" = 'with trax' AND "song" IN ('"healing"', '"boys & girls"')
0.106445
CREATE TABLE table_53950 ("Nation" TEXT, "Skip" TEXT, "Third" TEXT, "Second" TEXT, "Lead" TEXT, "Alternate" TEXT)
Which Skip will play Joan Mccusker?
SELECT "Skip" FROM table_53950 WHERE "Second" = 'joan mccusker'
SELECT "Skip" FROM "table_53950" WHERE "Second" = 'joan mccusker'
0.063477
CREATE TABLE table_21740 ("Number" TEXT, "Builder" TEXT, "Type" TEXT, "Date built" TEXT, "Heritage" TEXT, "Disposition" TEXT, "Notes" TEXT)
Name the number of builders for number 96
SELECT COUNT("Builder") FROM table_21740 WHERE "Number" = '96'
SELECT COUNT("Builder") FROM "table_21740" WHERE "Number" = '96'
0.0625
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 regions (REGION_ID DECIMAL, REGION_NAME VARCHAR) CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_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 locations (LOCATION_ID DECIMAL, STREET_ADDRESS VARCHAR, POSTAL_CODE VARCHAR, CITY VARCHAR, STATE_PROVINCE VARCHAR, COUNTRY_ID VARCHAR) CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID DECIMAL)
For those employees who did not have any job in the past, visualize a bar chart about the distribution of job_id and the sum of department_id , and group by attribute job_id, I want to show by the bar from high to low.
SELECT JOB_ID, SUM(DEPARTMENT_ID) FROM employees WHERE NOT EMPLOYEE_ID IN (SELECT EMPLOYEE_ID FROM job_history) GROUP BY JOB_ID ORDER BY JOB_ID DESC
SELECT "JOB_ID", SUM("DEPARTMENT_ID") FROM "employees" WHERE NOT "EMPLOYEE_ID" IN (SELECT "EMPLOYEE_ID" FROM "job_history") GROUP BY "JOB_ID" ORDER BY "JOB_ID" DESC NULLS LAST
0.170898
CREATE TABLE table_name_53 (weight VARCHAR, team VARCHAR)
What is the weight of the player from the Philadelphia 76ers?
SELECT COUNT(weight) FROM table_name_53 WHERE team = "philadelphia 76ers"
SELECT COUNT("weight") FROM "table_name_53" WHERE "philadelphia 76ers" = "team"
0.077148
CREATE TABLE countries (COUNTRY_ID VARCHAR, COUNTRY_NAME VARCHAR, REGION_ID DECIMAL) CREATE TABLE regions (REGION_ID DECIMAL, REGION_NAME VARCHAR) 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 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) CREATE TABLE job_history (EMPLOYEE_ID DECIMAL, START_DATE DATE, END_DATE DATE, JOB_ID VARCHAR, DEPARTMENT_ID DECIMAL)
For those employees who was hired before 2002-06-21, return a bar chart about the distribution of hire_date and the average of department_id bin hire_date by time, and list y axis in desc order.
SELECT HIRE_DATE, AVG(DEPARTMENT_ID) FROM employees WHERE HIRE_DATE < '2002-06-21' ORDER BY AVG(DEPARTMENT_ID) DESC
SELECT "HIRE_DATE", AVG("DEPARTMENT_ID") FROM "employees" WHERE "HIRE_DATE" < '2002-06-21' ORDER BY AVG("DEPARTMENT_ID") DESC NULLS LAST
0.132813
CREATE TABLE table_27861 ("Settlement" TEXT, "Cyrillic Name Other Names" TEXT, "Type" TEXT, "Population ( 2011 ) " TEXT, "Largest ethnic group ( 2002 ) " TEXT, "Dominant religion ( 2002 ) " TEXT)
How many settlements have as their cyrillic name and other names ?
SELECT "Settlement" FROM table_27861 WHERE "Cyrillic Name Other Names" = 'Панонија'
SELECT "Settlement" FROM "table_27861" WHERE "Cyrillic Name Other Names" = 'Панонија'
0.083008
CREATE TABLE table_name_41 (votes VARCHAR, candidate VARCHAR)
Candidate of riikka manner has how many votes?
SELECT votes FROM table_name_41 WHERE candidate = "riikka manner"
SELECT "votes" FROM "table_name_41" WHERE "candidate" = "riikka manner"
0.069336
CREATE TABLE table_65830 ("Internet Explorer" TEXT, "Firefox , Other Mozilla" TEXT, "Chrome" TEXT, "Safari" TEXT, "Opera" TEXT)
What percentage of browsers were using Safari during the period in which 2.05% were using Chrome?
SELECT "Safari" FROM table_65830 WHERE "Chrome" = '2.05%'
SELECT "Safari" FROM "table_65830" WHERE "Chrome" = '2.05%'
0.057617
CREATE TABLE table_6804 ("Round" TEXT, "Year" FLOAT, "Team" TEXT, "Opponent" TEXT, "Goals" FLOAT, "Behinds" FLOAT)
What is the goals for Round 15?
SELECT "Goals" FROM table_6804 WHERE "Round" = 'round 15'
SELECT "Goals" FROM "table_6804" WHERE "Round" = 'round 15'
0.057617
CREATE TABLE table_76349 ("Club" TEXT, "Played" TEXT, "Drawn" TEXT, "Lost" TEXT, "Points for" TEXT, "Points against" TEXT, "Tries for" TEXT, "Tries against" TEXT, "Try bonus" TEXT, "Losing bonus" TEXT, "Points" TEXT)
what is the points against when the losing bonus is 0 and the club is banwen rfc?
SELECT "Points against" FROM table_76349 WHERE "Losing bonus" = '0' AND "Club" = 'banwen rfc'
SELECT "Points against" FROM "table_76349" WHERE "Club" = 'banwen rfc' AND "Losing bonus" = '0'
0.092773
CREATE TABLE table_16729076_1 (attendance INT, game_site VARCHAR)
what is the attendance where the game site is kingdome?
SELECT MIN(attendance) FROM table_16729076_1 WHERE game_site = "Kingdome"
SELECT MIN("attendance") FROM "table_16729076_1" WHERE "Kingdome" = "game_site"
0.077148
CREATE TABLE table_1299 ("Country" TEXT, "Uranium required 2006-08" TEXT, "% of world demand" TEXT, "Indigenous mining production 2006" TEXT, "Deficit ( -surplus ) " TEXT)
What is the deficit (-surplus) of France?
SELECT "Deficit (-surplus)" FROM table_1299 WHERE "Country" = 'France'
SELECT "Deficit (-surplus)" FROM "table_1299" WHERE "Country" = 'France'
0.070313
CREATE TABLE table_204_903 (id DECIMAL, "title" TEXT, "character" TEXT, "broadcaster" TEXT, "episodes" DECIMAL, "date" DECIMAL)
what is the total number of shows sophie colguhoun appeared in ?
SELECT COUNT(*) FROM table_204_903
SELECT COUNT(*) FROM "table_204_903"
0.035156
CREATE TABLE table_name_58 (date VARCHAR, pitcher VARCHAR)
I want the date for an bal s nchez
SELECT date FROM table_name_58 WHERE pitcher = "aníbal sánchez"
SELECT "date" FROM "table_name_58" WHERE "aníbal sánchez" = "pitcher"
0.067383
CREATE TABLE table_name_50 (country VARCHAR, score VARCHAR)
What is Country, when Score is 70-73=143?
SELECT country FROM table_name_50 WHERE score = 70 - 73 = 143
SELECT "country" FROM "table_name_50" WHERE "score" = FALSE
0.057617
CREATE TABLE table_name_51 (venue VARCHAR, home_team VARCHAR)
When the home team is Cairns Taipans, at which venue do they play?
SELECT venue FROM table_name_51 WHERE home_team = "cairns taipans"
SELECT "venue" FROM "table_name_51" WHERE "cairns taipans" = "home_team"
0.070313
CREATE TABLE table_18910 ("Cost" TEXT, "2400 kWh/kWp\\u2022y" TEXT, "2200 kWh/kWp\\u2022y" TEXT, "2000 kWh/kWp\\u2022y" TEXT, "1800 kWh/kWp\\u2022y" TEXT, "1600 kWh/kWp\\u2022y" TEXT, "1400 kWh/kWp\\u2022y" TEXT, "1200 kWh/kWp\\u2022y" TEXT, "1000 kWh/kWp\\u2022y" TEXT, "800 kWh/kWp\\u2022y" TEXT)
At the rate where 1600kwh/kwp y is 26.3, what is the value of 2200 kwh/kwp y?
SELECT "2200 kWh/kWp\u2022y" FROM table_18910 WHERE "1600 kWh/kWp\u2022y" = '26.3'
SELECT "2200 kWh/kWp\u2022y" FROM "table_18910" WHERE "1600 kWh/kWp\u2022y" = '26.3'
0.082031
CREATE TABLE table_name_2 (status VARCHAR, opposing_team VARCHAR)
What status has gauteng falcons as the opposing team?
SELECT status FROM table_name_2 WHERE opposing_team = "gauteng falcons"
SELECT "status" FROM "table_name_2" WHERE "gauteng falcons" = "opposing_team"
0.075195
CREATE TABLE table_17474 ("Year" FLOAT, "Division" TEXT, "League" TEXT, "Regular Season" TEXT, "Playoffs" TEXT, "Open Cup" TEXT)
What was the result of the playoffs when the regular season was 7th, southeast
SELECT "Playoffs" FROM table_17474 WHERE "Regular Season" = '7th, Southeast'
SELECT "Playoffs" FROM "table_17474" WHERE "Regular Season" = '7th, Southeast'
0.076172
CREATE TABLE table_14277 ("Game" FLOAT, "Date" TEXT, "Opponent" TEXT, "Score" TEXT, "Location" TEXT, "Record" TEXT)
What is the highest game with a 3-2 record?
SELECT MAX("Game") FROM table_14277 WHERE "Record" = '3-2'
SELECT MAX("Game") FROM "table_14277" WHERE "Record" = '3-2'
0.058594
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 diagnoses (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE procedures (subject_id TEXT, hadm_id TEXT, icd9_code TEXT, short_title TEXT, long_title TEXT) CREATE TABLE prescriptions (subject_id TEXT, hadm_id TEXT, icustay_id TEXT, drug_type TEXT, drug TEXT, formulary_drug_cd TEXT, route TEXT, drug_dose TEXT)
what is average age of patients whose marital status is single and primary disease is sepsis?
SELECT AVG(demographic.age) FROM demographic WHERE demographic.marital_status = "SINGLE" AND demographic.diagnosis = "SEPSIS"
SELECT AVG("demographic"."age") FROM "demographic" WHERE "SEPSIS" = "demographic"."diagnosis" AND "SINGLE" = "demographic"."marital_status"
0.135742
CREATE TABLE table_204_951 (id DECIMAL, "candidate" TEXT, "votes" DECIMAL, "percentage" TEXT, "counties" DECIMAL, "delegates" DECIMAL)
how many candidates received over 10 % of the vote ?
SELECT COUNT("candidate") FROM table_204_951 WHERE "percentage" > 10
SELECT COUNT("candidate") FROM "table_204_951" WHERE "percentage" > 10
0.068359
CREATE TABLE table_13070 ("Actor/actress" TEXT, "Character" TEXT, "Rank" TEXT, "Tenure" TEXT, "Episodes" TEXT)
What Character has a Rank of intelligence officer?
SELECT "Character" FROM table_13070 WHERE "Rank" = 'intelligence officer'
SELECT "Character" FROM "table_13070" WHERE "Rank" = 'intelligence officer'
0.073242
CREATE TABLE table_2668347_14 (party VARCHAR, candidates VARCHAR)
how many times were the candidates thomas h. hubbard (dr) 51.5% simeon ford (f) 48.4%?
SELECT COUNT(party) FROM table_2668347_14 WHERE candidates = "Thomas H. Hubbard (DR) 51.5% Simeon Ford (F) 48.4%"
SELECT COUNT("party") FROM "table_2668347_14" WHERE "Thomas H. Hubbard (DR) 51.5% Simeon Ford (F) 48.4%" = "candidates"
0.116211
CREATE TABLE table_22196 ("Year" FLOAT, "Date" TEXT, "Type" TEXT, "Species" TEXT, "Author Species" TEXT, "Value" TEXT, "Afinsa" FLOAT, "Scott" TEXT, "Mitchell" FLOAT, "Yvert" TEXT, "Sta. & Gib." FLOAT, "Order" TEXT, "Family" TEXT)
What is every species when Afinsa is 639?
SELECT "Species" FROM table_22196 WHERE "Afinsa" = '639'
SELECT "Species" FROM "table_22196" WHERE "Afinsa" = '639'
0.056641