context
stringlengths
11
9.12k
question
stringlengths
0
1.06k
SQL
stringlengths
2
4.44k
source
stringclasses
28 values
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 ) C...
find the number of patients who have montelukast sodium drug prescription and were admitted before 2176.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN prescriptions ON demographic.hadm_id = prescriptions.hadm_id WHERE demographic.admityear < "2176" AND prescriptions.drug = "Montelukast Sodium"
mimicsql_data
CREATE TABLE table_17001658_8 ( location_attendance VARCHAR, game VARCHAR )
Name the location attendance for game 55
SELECT location_attendance FROM table_17001658_8 WHERE game = 55
sql_create_context
CREATE TABLE table_14941284_1 ( game_site VARCHAR, date VARCHAR )
When it is October 18, 1981 where is the game site?
SELECT game_site FROM table_14941284_1 WHERE date = "October 18, 1981"
sql_create_context
CREATE TABLE PostHistory ( Id number, PostHistoryTypeId number, PostId number, RevisionGUID other, CreationDate time, UserId number, UserDisplayName text, Comment text, Text text, ContentLicense text ) CREATE TABLE PostTags ( PostId number, TagId number ) CREATE TABLE R...
Select questions of a given age, with no answer and a descent score.
SELECT p.Id AS "post_link", Title, p.Tags AS Tags, p.ViewCount AS "Views", p.Score AS "Score", p.AnswerCount AS "Answers", DATEDIFF(day, p.CreationDate, GETDATE()) AS "Age (days)", p.AcceptedAnswerId AS "Answer Accepted?" FROM Posts AS p WHERE p.AnswerCount = 0 AND DATEDIFF(day, p.CreationDate, GETDATE()) < '##maxage:i...
sede
CREATE TABLE airports ( apid integer, name text, city text, country text, x real, y real, elevation bigint, iata character varchar(3), icao character varchar(4) ) CREATE TABLE routes ( rid integer, dst_apid integer, dst_ap varchar(4), src_apid bigint, src_ap varc...
Find the country of the airlines whose name starts with 'Orbit', and count them by a bar chart, rank from high to low by the y-axis.
SELECT country, COUNT(country) FROM airlines WHERE name LIKE 'Orbit%' GROUP BY country ORDER BY COUNT(country) DESC
nvbench
CREATE TABLE admissions ( row_id number, subject_id number, hadm_id number, admittime time, dischtime time, admission_type text, admission_location text, discharge_location text, insurance text, language text, marital_status text, ethnicity text, age number ) CREATE ...
how many days have elapsed since patient 40059 had his first propoxyphene nap.-apap (n-100) prescription during the current hospital visit?
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', prescriptions.startdate)) FROM prescriptions WHERE prescriptions.hadm_id IN (SELECT admissions.hadm_id FROM admissions WHERE admissions.subject_id = 40059 AND admissions.dischtime IS NULL) AND prescriptions.drug = 'propoxyphene nap.-apap (n-100)' ORDER BY pres...
mimic_iii
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 procedures ( ...
give me the number of patients whose admission type is emergency and age is less than 68?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.admission_type = "EMERGENCY" AND demographic.age < "68"
mimicsql_data
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 procedures ( ...
Provide me the number of patients born in or before 2179 who have left internal jugular vein thrombosis; left arm edema primary disease.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic WHERE demographic.diagnosis = "LEFT INTERNAL JUGULAR VEIN THROMBOSIS;LEFT ARM EDEMA" AND demographic.dod_year <= "2179.0"
mimicsql_data
CREATE TABLE table_54779 ( "NGC number" real, "Object type" text, "Constellation" text, "Right ascension ( J2000 )" text, "Declination ( J2000 )" text, "Apparent magnitude" real )
What Constellation has a Object type of globular cluster and a NGC number of 5986?
SELECT "Constellation" FROM table_54779 WHERE "Object type" = 'globular cluster' AND "NGC number" = '5986'
wikisql
CREATE TABLE table_name_13 ( district VARCHAR, constituency_number VARCHAR )
What is the district with 79 constituency number?
SELECT district FROM table_name_13 WHERE constituency_number = "79"
sql_create_context
CREATE TABLE table_72051 ( "Year" real, "Office" text, "Candidate" text, "Popular Votes" real, "Percentage" text )
What percentage did chris wright receive?
SELECT "Percentage" FROM table_72051 WHERE "Candidate" = 'chris wright'
wikisql
CREATE TABLE patient ( PCP VARCHAR ) CREATE TABLE physician ( name VARCHAR, employeeid VARCHAR )
Find the name of physicians who are in charge of more than one patient.
SELECT T1.name FROM physician AS T1 JOIN patient AS T2 ON T1.employeeid = T2.PCP GROUP BY T1.employeeid HAVING COUNT(*) > 1
sql_create_context
CREATE TABLE table_204_140 ( id number, "round" number, "#" number, "player" text, "position" text, "nationality" text, "college/junior/club team (league)" text )
which player is from the united states and played on the springfield jr. blues ?
SELECT "player" FROM table_204_140 WHERE "nationality" = 'united states' AND "college/junior/club team (league)" = 'springfield jr. blues'
squall
CREATE TABLE table_7438 ( "Week" real, "Date" text, "Opponent" text, "Result" text, "Attendance" real )
What is the Attendance with a Date that is october 31, 1965?
SELECT "Attendance" FROM table_7438 WHERE "Date" = 'october 31, 1965'
wikisql
CREATE TABLE table_56937 ( "Rank" real, "Name" text, "Nation" text, "Points" real, "Placings" real )
What is the highest placing for marie mcneil / robert mccall, with less than 168.58?
SELECT MAX("Placings") FROM table_56937 WHERE "Name" = 'marie mcneil / robert mccall' AND "Points" < '168.58'
wikisql
CREATE TABLE table_79965 ( "Year" real, "Tournament" text, "Venue" text, "Result" text, "Extra" text )
Where was the 1984 Olympics hosted?
SELECT "Tournament" FROM table_79965 WHERE "Year" = '1984'
wikisql
CREATE TABLE table_34651 ( "Season" text, "Total TD's" real, "Total TC's" real, "Total STC's" real, "Strongest storm" text, "Deaths" text )
What is the average total TCs of the season where the strongest storm was Zoe and the season was totals?
SELECT AVG("Total TC's") FROM table_34651 WHERE "Strongest storm" = 'zoe' AND "Season" = 'totals'
wikisql
CREATE TABLE table_12379297_4 ( branding VARCHAR, location VARCHAR )
What is the branding of metro manila?
SELECT branding FROM table_12379297_4 WHERE location = "Metro Manila"
sql_create_context
CREATE TABLE table_5251 ( "Subject" text, "Grade" real, "2004" real, "2005" real, "2006" real, "2007" real, "2008" real, "2009" real, "2010" real )
Which 2005 is the lowest one that has a Grade smaller than 6, and a 2008 smaller than 80, and a 2006 larger than 72?
SELECT MIN("2005") FROM table_5251 WHERE "Grade" < '6' AND "2008" < '80' AND "2006" > '72'
wikisql
CREATE TABLE chartevents ( row_id number, subject_id number, hadm_id number, icustay_id number, itemid number, charttime time, valuenum number, valueuom text ) CREATE TABLE diagnoses_icd ( row_id number, subject_id number, hadm_id number, icd9_code text, charttime ti...
how much do charge for a permanent ileostomy nec?
SELECT DISTINCT cost.cost FROM cost WHERE cost.event_type = 'procedures_icd' AND cost.event_id IN (SELECT procedures_icd.row_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'permanent ileostomy nec'))
mimic_iii
CREATE TABLE table_name_79 ( date VARCHAR, record VARCHAR )
On what date was the record 21-25?
SELECT date FROM table_name_79 WHERE record = "21-25"
sql_create_context
CREATE TABLE ReviewTaskTypes ( Id number, Name text, Description text ) CREATE TABLE CloseReasonTypes ( Id number, Name text, Description text ) CREATE TABLE PostNotices ( Id number, PostId number, PostNoticeTypeId number, CreationDate time, DeletionDate time, ExpiryDat...
Average total score of users depending on number of posts.
WITH postgroups_cte AS (SELECT u.Id AS uid, SUM(p.Score) AS sco, CAST(COUNT(p.Id) / '##mult?100##' AS INT) AS pgroup FROM Users AS u INNER JOIN Posts AS p ON p.OwnerUserId = u.Id GROUP BY u.Id) SELECT pgroup, AVG(CAST(sco AS FLOAT)) AS Average FROM postgroups_cte GROUP BY pgroup ORDER BY pgroup DESC
sede
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 ) C...
what is the number of patients whose hospital stay is above 4 days with procedure angioplasty of other non-coronary vessels?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.days_stay > "4" AND procedures.long_title = "Angioplasty of other non-coronary vessel(s)"
mimicsql_data
CREATE TABLE jybgb ( BBCJBW text, BBDM text, BBMC text, BBZT number, BGDH text, BGJGDM text, BGJGMC text, BGRGH text, BGRQ time, BGRXM text, BGSJ time, CJRQ time, JSBBRQSJ time, JSBBSJ time, JYBBH text, JYJGMC text, JYJSGH text, JYJSQM text, JY...
在06年7月8日到08年9月2日内多少人是医生21789346看的门诊?
SELECT COUNT(*) FROM wdmzjzjlb WHERE wdmzjzjlb.ZZYSGH = '21789346' AND wdmzjzjlb.JZKSRQ BETWEEN '2006-07-08' AND '2008-09-02' UNION SELECT COUNT(*) FROM bdmzjzjlb WHERE bdmzjzjlb.ZZYSGH = '21789346' AND bdmzjzjlb.JZKSRQ BETWEEN '2006-07-08' AND '2008-09-02'
css
CREATE TABLE flight_leg ( flight_id int, leg_number int, leg_flight int ) CREATE TABLE flight_stop ( flight_id int, stop_number int, stop_days text, stop_airport text, arrival_time int, arrival_airline text, arrival_flight_number int, departure_time int, departure_airlin...
i'd like a flight from DETROIT to ST. PETERSBURG for tuesday
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, city AS CITY_0, city AS CITY_1, date_day, days, flight WHERE (CITY_1.city_code = AIRPORT_SERVICE_1.city_code AND CITY_1.city_name = 'ST. PETERSBURG' AND date_day.day_number = 22 AND date_day.month_number = ...
atis
CREATE TABLE table_25561560_3 ( sail_number VARCHAR, yacht VARCHAR )
What was the sail number of Two True?
SELECT sail_number FROM table_25561560_3 WHERE yacht = "Two True"
sql_create_context
CREATE TABLE program_requirement ( program_id int, category varchar, min_credit int, additional_req varchar ) CREATE TABLE semester ( semester_id int, semester varchar, year int ) CREATE TABLE area ( course_id int, area varchar ) CREATE TABLE offering_instructor ( offering_ins...
What upper level CS classes are available next semester ?
SELECT DISTINCT course.department, course.name, course.number FROM course INNER JOIN program_course ON program_course.course_id = course.course_id INNER JOIN course_offering ON course.course_id = course_offering.course_id INNER JOIN semester ON semester.semester_id = course_offering.semester WHERE program_course.catego...
advising
CREATE TABLE table_75331 ( "Rank" real, "Player" text, "Country" text, "Earnings ( $ )" real, "Events" real, "Wins" real )
How many events have earnings less than 1,030,717?
SELECT COUNT("Events") FROM table_75331 WHERE "Earnings ( $ )" < '1,030,717'
wikisql
CREATE TABLE table_165732_2 ( title VARCHAR, episode__number VARCHAR )
How many titles does Episode 2 have
SELECT COUNT(title) FROM table_165732_2 WHERE episode__number = 2
sql_create_context
CREATE TABLE table_1341640_14 ( first_elected VARCHAR, incumbent VARCHAR )
What year was incumbent phil crane first elected?
SELECT first_elected FROM table_1341640_14 WHERE incumbent = "Phil Crane"
sql_create_context
CREATE TABLE cost ( costid number, uniquepid text, patienthealthsystemstayid number, eventtype text, eventid number, chargetime time, cost number ) CREATE TABLE diagnosis ( diagnosisid number, patientunitstayid number, diagnosisname text, diagnosistime time, icd9code tex...
what is the number of days that have passed since the last time patient 005-87465 received a ogt intake on the current icu visit?
SELECT 1 * (STRFTIME('%j', CURRENT_TIME()) - STRFTIME('%j', intakeoutput.intakeoutputtime)) FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid =...
eicu
CREATE TABLE table_name_70 ( avg_finish INTEGER, position VARCHAR, top_5 VARCHAR )
WHAT IS THE LOWEST AVERAGE FINISH FOR 40TH POSITION, WITH A TOP 5 LARGER THAN 0?
SELECT MIN(avg_finish) FROM table_name_70 WHERE position = "40th" AND top_5 > 0
sql_create_context
CREATE TABLE table_name_47 ( type VARCHAR, surname VARCHAR, rank VARCHAR, number_of_bearers_2008 VARCHAR )
What is Type, when Rank is greater than 6, when Number of Bearers 2008 is greater than 13.815, and when Surname is Eriksen?
SELECT type FROM table_name_47 WHERE rank > 6 AND number_of_bearers_2008 > 13.815 AND surname = "eriksen"
sql_create_context
CREATE TABLE table_8584 ( "DVD title" text, "Season" text, "Aspect ratio" text, "Episode count" real, "Time length" text, "Release date" text )
What is the aspect ratio for the September 1, 2009 release?
SELECT "Aspect ratio" FROM table_8584 WHERE "Release date" = 'september 1, 2009'
wikisql
CREATE TABLE table_73398 ( "State (class)" text, "Vacator" text, "Reason for change" text, "Successor" text, "Date of successors formal installation" text )
What are all the states (class) when the reason for change was resigned November 26, 1798 and the vacator was John Hunter ( DR )?
SELECT "State (class)" FROM table_73398 WHERE "Reason for change" = 'Resigned November 26, 1798' AND "Vacator" = 'John Hunter ( DR )'
wikisql
CREATE TABLE table_name_91 ( rank INTEGER, total VARCHAR, gold VARCHAR, bronze VARCHAR )
Which Rank has a Gold of 3, and a Bronze of 4, and a Total larger than 8?
SELECT MIN(rank) FROM table_name_91 WHERE gold = 3 AND bronze = 4 AND total > 8
sql_create_context
CREATE TABLE table_name_40 ( world_record VARCHAR, press VARCHAR )
Which 92.5 holds the world record?
SELECT world_record FROM table_name_40 WHERE press = "925"
sql_create_context
CREATE TABLE jyjgzbb ( BGDH text, BGRQ time, CKZFWDX text, CKZFWSX number, CKZFWXX number, JCFF text, JCRGH text, JCRXM text, JCXMMC text, JCZBDM text, JCZBJGDL number, JCZBJGDW text, JCZBJGDX text, JCZBMC text, JLDW text, JYRQ time, JYZBLSH text, ...
从07年9月27日起到08年1月4日为止号码是5309668的医院在门诊就诊中开出大于等于20张检验报告单的科室有多少个科室?
SELECT COUNT(*) FROM (SELECT jybgb.KSBM FROM mzjzjlb JOIN jybgb JOIN hz_info_mzjzjlb ON hz_info_mzjzjlb.YLJGDM = jybgb.YLJGDM_MZJZJLB AND mzjzjlb.JZLSH = jybgb.JZLSH_MZJZJLB AND hz_info_mzjzjlb.JZLSH = mzjzjlb.JZLSH AND hz_info_mzjzjlb.YLJGDM = hz_info_mzjzjlb.YLJGDM AND hz_info_mzjzjlb.JZLSH = mzjzjlb.JZLSH AND hz_inf...
css
CREATE TABLE table_name_60 ( category VARCHAR, year VARCHAR, role_episode VARCHAR )
Which Category was from before 2009 with a Role/Episode of Libby Goldstein and Junie Lowry-Johnson?
SELECT category FROM table_name_60 WHERE year < 2009 AND role_episode = "libby goldstein and junie lowry-johnson"
sql_create_context
CREATE TABLE hz_info ( KH text, KLX number, RYBH text, YLJGDM text ) CREATE TABLE zyjzjlb ( CYBQDM text, CYBQMC text, CYCWH text, CYKSDM text, CYKSMC text, CYSJ time, CYZTDM number, HZXM text, JZKSDM text, JZKSMC text, JZLSH text, KH text, KLX number,...
在医院7400991就诊的病号尤安晏其就诊的科室名称包含肝胆科的全部门诊就诊记录的流水号是什么?
SELECT zzmzjzjlb.JZLSH FROM person_info JOIN hz_info JOIN zzmzjzjlb ON person_info.RYBH = hz_info.RYBH AND hz_info.YLJGDM = zzmzjzjlb.YLJGDM AND hz_info.KH = zzmzjzjlb.KH AND hz_info.KLX = zzmzjzjlb.KLX WHERE person_info.XM = '尤安晏' AND hz_info.YLJGDM = '7400991' AND zzmzjzjlb.JZKSMC LIKE '%肝胆科%' UNION SELECT fzzmzjzjlb...
css
CREATE TABLE jybgb ( BBCJBW text, BBDM text, BBMC text, BBZT number, BGDH text, BGJGDM text, BGJGMC text, BGRGH text, BGRQ time, BGRXM text, BGSJ time, CJRQ time, JSBBRQSJ time, JSBBSJ time, JYBBH text, JYJGMC text, JYJSGH text, JYJSQM text, JY...
哪些工号及姓名的医务人员在患者魏乐志就诊过程中为他检测指标977450的,时间是从一二年九月十七日到二一年五月十七日
SELECT jyjgzbb.JCRGH, jyjgzbb.JCRXM FROM person_info JOIN hz_info JOIN mzjzjlb JOIN jybgb JOIN jyjgzbb JOIN hz_info_mzjzjlb ON person_info.RYBH = hz_info.RYBH AND hz_info.YLJGDM = hz_info_mzjzjlb.YLJGDM AND hz_info.KH = mzjzjlb.KH AND hz_info.KLX = mzjzjlb.KLX AND hz_info_mzjzjlb.YLJGDM = jybgb.YLJGDM_MZJZJLB AND mzjzj...
css
CREATE TABLE table_21634403_2 ( us_viewers__millions_ VARCHAR, directed_by VARCHAR )
How many U.S. viewers watched the episode directed by Frank Waldeck?
SELECT us_viewers__millions_ FROM table_21634403_2 WHERE directed_by = "Frank Waldeck"
sql_create_context
CREATE TABLE table_45879 ( "Round" real, "Player" text, "Position" text, "Nationality" text, "College/junior/club team (league)" text )
What player is from Russia?
SELECT "Player" FROM table_45879 WHERE "Nationality" = 'russia'
wikisql
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 ) C...
what is the number of patients whose primary disease is infected right thigh graft and procedure short title is coronar arteriogr-1 cath?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.diagnosis = "INFECTED RIGHT THIGH GRAFT" AND procedures.short_title = "Coronar arteriogr-1 cath"
mimicsql_data
CREATE TABLE ReviewRejectionReasons ( Id number, Name text, Description text, PostTypeId number ) CREATE TABLE ReviewTaskStates ( Id number, Name text, Description text ) CREATE TABLE ReviewTaskTypes ( Id number, Name text, Description text ) CREATE TABLE Comments ( Id num...
Fraction of closed first questions as function of account age.
WITH Q1 AS (SELECT MIN(Id) AS Id, OwnerUserId FROM Posts WHERE PostTypeId = 1 GROUP BY OwnerUserId) SELECT ROUND(LOG(10, CAST((JULIANDAY(CreationDate) - JULIANDAY(Users.CreationDate)) AS INT)), 1) AS "log_delta-t", SUM(CASE WHEN NOT ClosedDate IS NULL THEN 1 ELSE 0 END) AS "closed", COUNT(*) AS "total", SUM(CASE WHEN N...
sede
CREATE TABLE table_203_655 ( id number, "goal" number, "date" text, "venue" text, "opponent" text, "score" text, "result" text, "competition" text )
what was the number of goals scored against faroe islands ?
SELECT "score" FROM table_203_655 WHERE "opponent" = 'faroe islands'
squall
CREATE TABLE table_27755603_8 ( high_rebounds VARCHAR, date VARCHAR )
Name the high rebounds for january 14
SELECT high_rebounds FROM table_27755603_8 WHERE date = "January 14"
sql_create_context
CREATE TABLE microlab ( microlabid number, patientunitstayid number, culturesite text, organism text, culturetakentime time ) CREATE TABLE intakeoutput ( intakeoutputid number, patientunitstayid number, cellpath text, celllabel text, cellvaluenumeric number, intakeoutputtime...
when was the last time that patient 005-76912 since 481 days ago had the maximum respiration value.
SELECT vitalperiodic.observationtime FROM vitalperiodic WHERE vitalperiodic.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '005-76912')) AND NOT vitalperiodic.respiration IS N...
eicu
CREATE TABLE ReviewTaskResultTypes ( Id number, Name text, Description text ) CREATE TABLE SuggestedEditVotes ( Id number, SuggestedEditId number, UserId number, VoteTypeId number, CreationDate time, TargetUserId number, TargetRepChange number ) CREATE TABLE FlagTypes ( Id ...
Posts that were deleted but not undeleted.
SELECT p.Id AS "post_link" FROM Posts AS p JOIN PostHistory AS h ON h.PostId = p.Id JOIN PostHistoryTypes AS pht ON pht.Id = h.PostHistoryTypeId WHERE h.PostHistoryTypeId = 12 AND NOT EXISTS(SELECT Id FROM PostHistory WHERE PostId = h.PostId AND PostHistoryTypeId = 13) ORDER BY p.CreationDate
sede
CREATE TABLE hz_info ( KH text, KLX number, YLJGDM text ) CREATE TABLE zyjzjlb ( CYBQDM text, CYBQMC text, CYCWH text, CYKSDM text, CYKSMC text, CYSJ time, CYZTDM number, HZXM text, JZKSDM text, JZKSMC text, JZLSH text, KH text, KLX number, MZBMLX num...
列出吴英华这名患者在医院9013968的诊断信息不含循环的就诊记录
SELECT * FROM person_info JOIN hz_info JOIN mzjzjlb JOIN person_info_hz_info ON person_info.RYBH = person_info_hz_info.RYBH AND hz_info.YLJGDM = mzjzjlb.YLJGDM AND hz_info.KH = mzjzjlb.KH AND hz_info.KLX = mzjzjlb.KLX AND person_info_hz_info.KH = hz_info.KH AND person_info_hz_info.KLX = hz_info.KLX AND person_info_hz_i...
css
CREATE TABLE cost ( costid number, uniquepid text, patienthealthsystemstayid number, eventtype text, eventid number, chargetime time, cost number ) CREATE TABLE diagnosis ( diagnosisid number, patientunitstayid number, diagnosisname text, diagnosistime time, icd9code tex...
count the numbers of patients who were prescribed hydromorphone 1 mg/1 ml syr within 2 months after having been diagnosed with chronic kidney disease - stage 3 (gfr 30-59) since 1 year ago.
SELECT COUNT(DISTINCT t1.uniquepid) FROM (SELECT patient.uniquepid, diagnosis.diagnosistime FROM diagnosis JOIN patient ON diagnosis.patientunitstayid = patient.patientunitstayid WHERE diagnosis.diagnosisname = 'chronic kidney disease - stage 3 (gfr 30-59)' AND DATETIME(diagnosis.diagnosistime) >= DATETIME(CURRENT_TIME...
eicu
CREATE TABLE table_40152 ( "Branding" text, "Callsign" text, "Frequency" text, "Power (kW)" text, "Coverage" text )
What is the branding for the station with a frequency of 93.1mhz and a coverage of Zamboanga?
SELECT "Branding" FROM table_40152 WHERE "Frequency" = '93.1mhz' AND "Coverage" = 'zamboanga'
wikisql
CREATE TABLE table_name_13 ( number INTEGER, year_start VARCHAR, year_end VARCHAR )
Which Number has a Year Start smaller than 1874, and a Year End larger than 1873?
SELECT MAX(number) FROM table_name_13 WHERE year_start < 1874 AND year_end > 1873
sql_create_context
CREATE TABLE table_name_22 ( lema_sublema VARCHAR, votes VARCHAR, ch_of_deputies VARCHAR )
Which LEMA/SUBLEMA that has Votes smaller than 218656, and a Ch of Deputies of 0?
SELECT lema_sublema FROM table_name_22 WHERE votes < 218656 AND ch_of_deputies = "0"
sql_create_context
CREATE TABLE table_27743 ( "Rd." text, "Event" text, "Circuit" text, "City / State" text, "Date" text, "Championship" text, "Challenge" text, "Production" text )
In what round was the circuit Eastern Creek Raceway?
SELECT "Rd." FROM table_27743 WHERE "Circuit" = 'Eastern Creek Raceway'
wikisql
CREATE TABLE fare ( fare_id int, from_airport varchar, to_airport varchar, fare_basis_code text, fare_airline text, restriction_code text, one_direction_cost int, round_trip_cost int, round_trip_required varchar ) CREATE TABLE time_zone ( time_zone_code text, time_zone_name ...
show me FIRST class round trip flights from NEW YORK to MIAMI i want the cheapest FIRST class fare please
SELECT DISTINCT flight.flight_id FROM airport_service AS AIRPORT_SERVICE_0, airport_service AS AIRPORT_SERVICE_1, airport_service AS AIRPORT_SERVICE_2, airport_service AS AIRPORT_SERVICE_3, city AS CITY_0, city AS CITY_1, city AS CITY_2, city AS CITY_3, fare, fare_basis, flight, flight_fare WHERE (((CITY_2.city_code = ...
atis
CREATE TABLE table_name_56 ( human_resources_ VARCHAR, _operations VARCHAR, academic_ VARCHAR, _university_affairs VARCHAR )
Who was in Human Resources & Operations when David Hornsby was in Academic & University Affairs?
SELECT human_resources_ & _operations FROM table_name_56 WHERE academic_ & _university_affairs = "david hornsby"
sql_create_context
CREATE TABLE table_28925058_1 ( date VARCHAR, grand_prix VARCHAR )
What is the date of the Italian Grand Prix?
SELECT date FROM table_28925058_1 WHERE grand_prix = "Italian grand_prix"
sql_create_context
CREATE TABLE table_name_23 ( co_drivers VARCHAR, pos VARCHAR, team VARCHAR )
Which co drivers are 3rd in Joest racing?
SELECT co_drivers FROM table_name_23 WHERE pos = "3rd" AND team = "joest racing"
sql_create_context
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 t...
find the number of patients who were diagnosed with subarachnoid hemorrhage following injury without mention of open intracranial wound, with loss of consciousness of unspecified duration and were admitted in hospital on an emergency basis.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.admission_type = "EMERGENCY" AND diagnoses.long_title = "Subarachnoid hemorrhage following injury without mention of open intracranial wound, with loss of consciousness of uns...
mimicsql_data
CREATE TABLE cost ( costid number, uniquepid text, patienthealthsystemstayid number, eventtype text, eventid number, chargetime time, cost number ) CREATE TABLE intakeoutput ( intakeoutputid number, patientunitstayid number, cellpath text, celllabel text, cellvaluenumeri...
what was the name of the intake that patient 006-157753 had a first today?
SELECT intakeoutput.celllabel FROM intakeoutput WHERE intakeoutput.patientunitstayid IN (SELECT patient.patientunitstayid FROM patient WHERE patient.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.uniquepid = '006-157753')) AND intakeoutput.cellpath LIKE '%intake%' AND ...
eicu
CREATE TABLE table_name_80 ( opening_date VARCHAR, hotel_rooms VARCHAR )
When did the hotel with 727 rooms open?
SELECT opening_date FROM table_name_80 WHERE hotel_rooms = 727
sql_create_context
CREATE TABLE table_31920 ( "Outcome" text, "Year" real, "Championship" text, "Opponent in the final" text, "Score (l) = score in legs, (s) = score in sets." text )
Tell me the outcome for premier league darts
SELECT "Outcome" FROM table_31920 WHERE "Championship" = 'premier league darts'
wikisql
CREATE TABLE table_48266 ( "Name" text, "in \u00d7 in" text, "mm \u00d7 mm" text, "Ratio" real, "Similar ISO A size" text )
Which Ratio has a Name of ansi e?
SELECT MIN("Ratio") FROM table_48266 WHERE "Name" = 'ansi e'
wikisql
CREATE TABLE table_name_40 ( years VARCHAR, assist VARCHAR, games VARCHAR )
Which year or years did a team win 174 games and had an assist number less than 17?
SELECT years FROM table_name_40 WHERE assist < 17 AND games = 174
sql_create_context
CREATE TABLE table_8006 ( "Game" real, "Date" text, "Team" text, "Score" text, "High points" text, "High rebounds" text, "High assists" text, "Location Attendance" text, "Series" text )
Which High rebounds have a Game larger than 2, and a Team of @ denver, and High assists of kobe bryant (5)?
SELECT "High rebounds" FROM table_8006 WHERE "Game" > '2' AND "Team" = '@ denver' AND "High assists" = 'kobe bryant (5)'
wikisql
CREATE TABLE table_name_61 ( country VARCHAR, time VARCHAR )
What country has a time of 8:03.61?
SELECT country FROM table_name_61 WHERE time = "8:03.61"
sql_create_context
CREATE TABLE screen_mode ( graphics_mode number, char_cells text, pixels text, hardware_colours number, used_kb number, map text, type text ) CREATE TABLE chip_model ( model_name text, launch_year number, ram_mib number, rom_mib number, slots text, wifi text, blu...
List the hardware model name for the phons that were produced by 'Nokia Corporation' but whose screen mode type is not Text.
SELECT DISTINCT T2.hardware_model_name FROM screen_mode AS T1 JOIN phone AS T2 ON T1.graphics_mode = T2.screen_mode WHERE t2.company_name = "Nokia Corporation" AND T1.type <> "Text"
spider
CREATE TABLE diagnoses ( subject_id text, hadm_id text, icd9_code text, short_title text, long_title text ) CREATE TABLE lab ( subject_id text, hadm_id text, itemid text, charttime text, flag text, value_unit text, label text, fluid text ) CREATE TABLE demographic (...
what is the number of patients whose discharge location is disch-tran to psych hosp and diagnoses long title is poisoning by other opiates and related narcotics?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id WHERE demographic.discharge_location = "DISCH-TRAN TO PSYCH HOSP" AND diagnoses.long_title = "Poisoning by other opiates and related narcotics"
mimicsql_data
CREATE TABLE inputevents_cv ( row_id number, subject_id number, hadm_id number, icustay_id number, charttime time, itemid number, amount number ) CREATE TABLE procedures_icd ( row_id number, subject_id number, hadm_id number, icd9_code text, charttime time ) CREATE TABL...
since 1 year ago, what were the top five most common intakes?
SELECT d_items.label FROM d_items WHERE d_items.itemid IN (SELECT t1.itemid FROM (SELECT inputevents_cv.itemid, DENSE_RANK() OVER (ORDER BY COUNT(*) DESC) AS c1 FROM inputevents_cv WHERE DATETIME(inputevents_cv.charttime) >= DATETIME(CURRENT_TIME(), '-1 year') GROUP BY inputevents_cv.itemid) AS t1 WHERE t1.c1 <= 5)
mimic_iii
CREATE TABLE gsi ( course_offering_id int, student_id int ) CREATE TABLE program_requirement ( program_id int, category varchar, min_credit int, additional_req varchar ) CREATE TABLE ta ( campus_job_id int, student_id int, location varchar ) CREATE TABLE offering_instructor ( ...
Are there MDE or PreMajor course offered in the Spring ?
SELECT DISTINCT course.department, course.name, course.number, program_course.category FROM course, course_offering, program_course, semester WHERE course.course_id = course_offering.course_id AND program_course.category IN ('MDE', 'PreMajor') AND program_course.course_id = course.course_id AND semester.semester = 'Spr...
advising
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 ) C...
how many patients born before 2101 had other unilateral salpingo-oophorectomy?
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2101" AND procedures.short_title = "Oth uni salpingo-oophor"
mimicsql_data
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 te...
what is drug name and drug route of drug code hydm4?
SELECT prescriptions.drug, prescriptions.route FROM prescriptions WHERE prescriptions.formulary_drug_cd = "HYDM4"
mimicsql_data
CREATE TABLE ReviewRejectionReasons ( Id number, Name text, Description text, PostTypeId number ) CREATE TABLE VoteTypes ( Id number, Name text ) CREATE TABLE PostTypes ( Id number, Name text ) CREATE TABLE TagSynonyms ( Id number, SourceTagName text, TargetTagName text, ...
Questions answered by more than 3 'Top N' users. Thanks to https://codereview.stackexchange.com/a/244191/103675 for the improvements!
SELECT Q.Id AS "post_link", Q.AnswerCount FROM Posts AS Q WHERE Q.AnswerCount >= 3 AND (SELECT COUNT(DISTINCT A.OwnerUserId) FROM Posts AS A WHERE A.ParentId = Q.Id AND A.OwnerUserId IN (SELECT TOP(100) AS Id FROM Users ORDER BY Reputation DESC)) = 3
sede
CREATE TABLE table_37445 ( "School Year" text, "Class A" text, "Class AA" text, "Class AAA" text, "Class AAAA" text, "Class AAAAA" text )
Name the clas AAAA of school year 2000-01
SELECT "Class AAAA" FROM table_37445 WHERE "School Year" = '2000-01'
wikisql
CREATE TABLE table_27533947_1 ( games_won VARCHAR, best_winning_average VARCHAR )
How many players had a best winning average of 20?
SELECT COUNT(games_won) FROM table_27533947_1 WHERE best_winning_average = "20"
sql_create_context
CREATE TABLE museums ( museum_id number, museum_details text ) CREATE TABLE royal_family ( royal_family_id number, royal_family_details text ) CREATE TABLE ref_hotel_star_ratings ( star_rating_code text, star_rating_description text ) CREATE TABLE photos ( photo_id number, tourist_att...
Show the details of the top 3 most expensive hotels.
SELECT other_hotel_details FROM hotels ORDER BY price_range DESC LIMIT 3
spider
CREATE TABLE table_name_94 ( round INTEGER, college VARCHAR, pick VARCHAR )
what is the round when the college is syracuse and the pick is less than 3?
SELECT AVG(round) FROM table_name_94 WHERE college = "syracuse" AND pick < 3
sql_create_context
CREATE TABLE table_name_68 ( record VARCHAR, high_rebounds VARCHAR )
What is Record, when High Rebounds is 'Tyson Chandler (6)'?
SELECT record FROM table_name_68 WHERE high_rebounds = "tyson chandler (6)"
sql_create_context
CREATE TABLE admissions ( row_id number, subject_id number, hadm_id number, admittime time, dischtime time, admission_type text, admission_location text, discharge_location text, insurance text, language text, marital_status text, ethnicity text, age number ) CREATE ...
what is the maximum hospital cost that involves a procedure known as a cl reduct mandible fx until 2104?
SELECT MAX(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.hadm_id IN (SELECT procedures_icd.hadm_id FROM procedures_icd WHERE procedures_icd.icd9_code = (SELECT d_icd_procedures.icd9_code FROM d_icd_procedures WHERE d_icd_procedures.short_title = 'cl reduct mandible fx')) AND STRFTIME('%y', cost.chargeti...
mimic_iii
CREATE TABLE lab ( labid number, patientunitstayid number, labname text, labresult number, labresulttime time ) CREATE TABLE cost ( costid number, uniquepid text, patienthealthsystemstayid number, eventtype text, eventid number, chargetime time, cost number ) CREATE TAB...
what is the monthly minimum amount of urine in patient 010-29887 until 14 months ago?
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 = '010-29887')) AND intakeoutput.celllabel = 'urine...
eicu
CREATE TABLE table_name_42 ( score VARCHAR, team VARCHAR )
What was the score of the game against Charlotte?
SELECT score FROM table_name_42 WHERE team = "charlotte"
sql_create_context
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 t...
give the number of patients whose diagnosis long title is observation for suspected infectious condition and lab test abnormal status is abnormal.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.long_title = "Observation for suspected infectious condition" AND lab.flag = "abnormal"
mimicsql_data
CREATE TABLE t_kc22 ( AMOUNT number, CHA_ITEM_LEV number, DATA_ID text, DIRE_TYPE number, DOSE_FORM text, DOSE_UNIT text, EACH_DOSAGE text, EXP_OCC_DATE time, FLX_MED_ORG_ID text, FXBZ number, HOSP_DOC_CD text, HOSP_DOC_NM text, MED_CLINIC_ID text, MED_DIRE_CD tex...
编号58061433的参保人从0九年八月二十七日到二一年二月九日,门诊开出的西药总共有多少金额
SELECT SUM(t_kc22.AMOUNT) FROM t_kc22 JOIN mzb ON mzb.MED_ORG_DEPT_CD = t_kc22.MED_CLINIC_ID WHERE mzb.PERSON_NM = '58061433' AND t_kc22.STA_DATE BETWEEN '2009-08-27' AND '2021-02-09' AND t_kc22.MED_INV_ITEM_TYPE = '西药费'
css
CREATE TABLE Apartment_Facilities ( apt_id INTEGER, facility_code CHAR(15) ) CREATE TABLE Apartment_Buildings ( building_id INTEGER, building_short_name CHAR(15), building_full_name VARCHAR(80), building_description VARCHAR(255), building_address VARCHAR(255), building_manager VARCHAR(5...
What are dates of birth of all the guests whose gender is 'Male', and count them by a line chart, list date_of_birth in asc order.
SELECT date_of_birth, COUNT(date_of_birth) FROM Guests WHERE gender_code = "Male" ORDER BY date_of_birth
nvbench
CREATE TABLE table_name_6 ( average VARCHAR, caps VARCHAR, scotland_career VARCHAR )
What is the average cap number in scotland in 1986 1998 leass than 69?
SELECT COUNT(average) FROM table_name_6 WHERE caps < 69 AND scotland_career = "1986–1998"
sql_create_context
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, ...
get the number of patients born before 2103 who had skin closure nec.
SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN procedures ON demographic.hadm_id = procedures.hadm_id WHERE demographic.dob_year < "2103" AND procedures.short_title = "Skin closure NEC"
mimicsql_data
CREATE TABLE table_33683 ( "Home team" text, "Home team score" text, "Away team" text, "Away team score" text, "Venue" text, "Crowd" real, "Date" text )
What is the average crowd for Carlton?
SELECT AVG("Crowd") FROM table_33683 WHERE "Away team" = 'carlton'
wikisql
CREATE TABLE table_name_25 ( north_american_release_date VARCHAR, european_release_date VARCHAR )
What is the North American release date of the remake with a European release date on 2013-03-20?
SELECT north_american_release_date FROM table_name_25 WHERE european_release_date = "2013-03-20"
sql_create_context
CREATE TABLE table_6729 ( "Season" real, "Team" text, "Wins" real, "Losses" real, "Draws" real )
What is the sum of Wins when draws shows 0 in 1964?
SELECT SUM("Wins") FROM table_6729 WHERE "Draws" = '0' AND "Season" = '1964'
wikisql
CREATE TABLE table_name_53 ( engine_capacity INTEGER, mpg_us_urban VARCHAR, mpg_uk_urban__cold_ VARCHAR, mpg_uk_extra_urban VARCHAR )
What's the engine capacity when the mpg-UK urban is less than 12.2, the mpg-UK extra urban is less than 18.8 and the mpg-US turban is less than 7.2?
SELECT SUM(engine_capacity) FROM table_name_53 WHERE mpg_uk_urban__cold_ < 12.2 AND mpg_uk_extra_urban < 18.8 AND mpg_us_urban < 7.2
sql_create_context
CREATE TABLE table_name_64 ( edition INTEGER, runner_up VARCHAR, year VARCHAR, third VARCHAR )
What was the edition after 2003 when the Third was Tikve and Sileks was the runner-up?
SELECT MIN(edition) FROM table_name_64 WHERE year > 2003 AND third = "tikveš" AND runner_up = "sileks"
sql_create_context
CREATE TABLE engineer_skills ( engineer_id number, skill_id number ) CREATE TABLE engineer_visits ( engineer_visit_id number, contact_staff_id number, engineer_id number, fault_log_entry_id number, fault_status text, visit_start_datetime time, visit_end_datetime time, other_visi...
How many engineers did each staff contact? List both the contact staff name and number of engineers contacted.
SELECT T1.staff_name, COUNT(*) FROM staff AS T1 JOIN engineer_visits AS T2 ON T1.staff_id = T2.contact_staff_id GROUP BY T1.staff_name
spider
CREATE TABLE university ( School_ID int, School text, Location text, Founded real, Affiliation text, Enrollment real, Nickname text, Primary_conference text ) CREATE TABLE basketball_match ( Team_ID int, School_ID int, Team_Name text, ACC_Regular_Season text, ACC_Per...
What is the relationship between ACC_Percent and All_Games_Percent , and group by attribute ACC_Road?
SELECT ACC_Percent, All_Games_Percent FROM basketball_match GROUP BY ACC_Road
nvbench
CREATE TABLE course_offering ( offering_id int, course_id int, semester int, section_number int, start_time time, end_time time, monday varchar, tuesday varchar, wednesday varchar, thursday varchar, friday varchar, saturday varchar, sunday varchar, has_final_proje...
Are there courses I need to take before taking LING 426 ?
SELECT DISTINCT COURSE_0.department, COURSE_0.name, COURSE_0.number FROM course AS COURSE_0, course AS COURSE_1, course_prerequisite WHERE COURSE_0.course_id = course_prerequisite.pre_course_id AND NOT COURSE_0.course_id IN (SELECT STUDENT_RECORDalias0.course_id FROM student_record AS STUDENT_RECORDalias0 WHERE STUDENT...
advising
CREATE TABLE patient ( uniquepid text, patienthealthsystemstayid number, patientunitstayid number, gender text, age text, ethnicity text, hospitalid number, wardid number, admissionheight number, admissionweight number, dischargeweight number, hospitaladmittime time, ...
what is the minimum total cost of a hospital with pressure support since 2104?
SELECT MIN(t1.c1) FROM (SELECT SUM(cost.cost) AS c1 FROM cost WHERE cost.patienthealthsystemstayid IN (SELECT patient.patienthealthsystemstayid FROM patient WHERE patient.patientunitstayid IN (SELECT lab.patientunitstayid FROM lab WHERE lab.labname = 'pressure support')) AND STRFTIME('%y', cost.chargetime) >= '2104' GR...
eicu
CREATE TABLE table_203_775 ( id number, "week" number, "date" text, "opponent" text, "result" text, "game site" text, "attendance" number )
what was the largest difference of points in a single game ?
SELECT MAX(ABS("result" - "result")) FROM table_203_775
squall
CREATE TABLE jybgb ( BBCJBW text, BBDM text, BBMC text, BBZT number, BGDH text, BGJGDM text, BGJGMC text, BGRGH text, BGRQ time, BGRXM text, BGSJ time, CJRQ time, JSBBRQSJ time, JSBBSJ time, JYBBH text, JYJGMC text, JYJSGH text, JYJSQM text, JY...
在08年1月10日到2014年4月16日内病号韦红艳的所有检验结果指标记录的检测人为82839333的检查指标流水号是多少?
SELECT jyjgzbb.JYZBLSH FROM person_info JOIN hz_info JOIN txmzjzjlb JOIN jybgb JOIN jyjgzbb ON person_info.RYBH = hz_info.RYBH AND hz_info.YLJGDM = txmzjzjlb.YLJGDM AND hz_info.KH = txmzjzjlb.KH AND hz_info.KLX = txmzjzjlb.KLX AND txmzjzjlb.YLJGDM = jybgb.YLJGDM_MZJZJLB AND txmzjzjlb.JZLSH = jybgb.JZLSH_MZJZJLB AND jyb...
css
CREATE TABLE table_11406866_2 ( a_ VARCHAR, kickoff_ VARCHAR )
what is the total number of kickoff [a ] where week is week
SELECT COUNT(kickoff_) AS "a_" FROM table_11406866_2 WHERE "week" = "week"
sql_create_context
CREATE TABLE table_22044 ( "Home (1st leg)" text, "Home (2nd leg)" text, "1st Leg" text, "2nd leg" text, "Aggregate" text )
If the second leg is 3-2, what is the first leg?
SELECT "Home (1st leg)" FROM table_22044 WHERE "2nd leg" = '3-2'
wikisql