db_id
stringclasses
66 values
question
stringlengths
24
325
evidence
stringlengths
1
673
gold_query
stringlengths
23
804
db_schema
stringclasses
66 values
hockey
How long has the NHL player been playing during the year when he recorded the least number of times being on the ice when a goal is scored for the team versus against the team? Indicate his full name.
NHL refers to lgID = 'NHL'; least number of times being on the ice when a goal is scored for the team versus against the team refers to min(+/-); duration the player's been playing = subtract(year(playerID(min(+/-))), firstNHL(playerID(min(+/-)))); full name = nameGiven + lastName
SELECT DISTINCT T3.firstNHL - T1.year, T3.nameGiven , T3.firstName, T3.lastName FROM Scoring AS T1 INNER JOIN Teams AS T2 ON T2.tmID = T1.tmID INNER JOIN Master AS T3 ON T1.playerID = T3.playerID GROUP BY T3.firstName, T3.lastName, T3.nameGiven, T3.firstNHL - T1.year, T3.firstName, T3.lastName ORDER BY SUM(T1.`+/-`) ASC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value Statics: Total count 45967 - Distinct count 5 - Null count 0 PostG TEXT, -- PostSHG TEXT, -- Example Values: `0`, `1`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 4 - Null count 31475 "+/-" TEXT, -- "Post+/-" TEXT, -- PostSHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 8855 - Distinct count 5 - Null count 37112 PPA TEXT, -- SOG TEXT, -- PostSOG TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, pos TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostPPG TEXT, -- Example Values: `0`, `1`, `5`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 10 - Null count 31475 SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 23214 - Distinct count 11 - Null count 22753 SHG TEXT, -- Example Values: `0`, `2`, `1`, `5`, `7` | Value Statics: Total count 37744 - Distinct count 14 - Null count 8223 Pts INTEGER, -- A INTEGER, -- PostPIM TEXT, -- G INTEGER, -- PostGWG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 15657 - Distinct count 8 - Null count 30310 PostPts TEXT, -- playerID TEXT, -- stint INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 45967 - Distinct count 4 - Null count 0 GWG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 36567 - Distinct count 16 - Null count 9400 PPG TEXT, -- PostPPA TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 8854 - Distinct count 17 - Null count 37113 year INTEGER, -- ); CREATE TABLE AwardsCoaches ( coachID TEXT, -- foreign key (coachID) references Coaches (coachID), year INTEGER, -- note TEXT, -- award TEXT, -- Example Values: `First Team All-Star`, `Second Team All-Star`, `Jack Adams`, `Baldwin`, `Schmertz` | Value Statics: Total count 77 - Distinct count 5 - Null count 0 lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 77 - Distinct count 2 - Null count 0 ); CREATE TABLE HOF ( category TEXT, -- Example Values: `Player`, `Builder`, `Referee/Linesman` | Value Statics: Total count 365 - Distinct count 3 - Null count 0 hofID TEXT not null primary key, year INTEGER, -- name TEXT, -- ); CREATE TABLE SeriesPost ( GoalsLoser INTEGER, -- note TEXT, -- Example Values: `EX`, `TG`, `ND`, `DEF` | Value Statics: Total count 59 - Distinct count 4 - Null count 773 lgIDLoser TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDWinner TEXT, -- series TEXT, -- Example Values: `A`, `B`, `C`, `D`, `E` | Value Statics: Total count 739 - Distinct count 15 - Null count 93 L INTEGER, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDLoser TEXT, -- foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade, year INTEGER, -- foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, T INTEGER, -- Example Values: `0`, `1`, `2` | Value Statics: Total count 832 - Distinct count 3 - Null count 0 lgIDWinner TEXT, -- Example Values: `PCHA`, `NHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 round TEXT, -- Example Values: `SCF`, `F`, `SF`, `SCSF`, `WP` | Value Statics: Total count 832 - Distinct count 13 - Null count 0 GoalsWinner INTEGER, -- W INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `0` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 ); CREATE TABLE abbrev ( Fullname TEXT, -- Code TEXT not null, -- primary key (Type, Code), Type TEXT not null, -- Example Values: `Conference`, `Division`, `Playoffs`, `Round` | Value Statics: Total count 58 - Distinct count 4 - Null count 0 ); CREATE TABLE AwardsMisc ( year INTEGER, -- lgID TEXT, -- Example Values: `NHL` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 note TEXT, -- Example Values: `posthumous` | Value Statics: Total count 15 - Distinct count 1 - Null count 109 name TEXT not null primary key, ID TEXT, -- award TEXT, -- Example Values: `Patrick` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 ); CREATE TABLE ScoringShootout ( year INTEGER, -- Example Values: `2006`, `2005`, `2007`, `2009`, `2008` | Value Statics: Total count 2072 - Distinct count 7 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, stint INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 2072 - Distinct count 3 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, G INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 2072 - Distinct count 16 - Null count 0 tmID TEXT, -- GDG INTEGER, -- Example Values: `0`, `1`, `2`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 8 - Null count 0 S INTEGER, -- Example Values: `1`, `2`, `5`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 19 - Null count 0 playerID TEXT, -- ); CREATE TABLE TeamSplits ( OctOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `5` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovL TEXT, -- Example Values: `1`, `4`, `3`, `2`, `0` | Value Statics: Total count 1358 - Distinct count 14 - Null count 161 FebOL TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovW TEXT, -- Example Values: `5`, `1`, `2`, `0`, `4` | Value Statics: Total count 1358 - Distinct count 13 - Null count 161 primary key (year, tmID), JanT INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 1305 - Distinct count 9 - Null count 214 SepW TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 JanL INTEGER, -- Example Values: `1`, `3`, `2`, `0`, `6` | Value Statics: Total count 1515 - Distinct count 15 - Null count 4 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 OctW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1199 - Distinct count 12 - Null count 320 AprW TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 FebT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1300 - Distinct count 8 - Null count 219 JanW INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 1515 - Distinct count 14 - Null count 4 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, rT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `6` | Value Statics: Total count 1309 - Distinct count 16 - Null count 210 tmID TEXT not null, -- DecW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 year INTEGER not null, -- OctL TEXT, -- Example Values: `1`, `0`, `2`, `4`, `5` | Value Statics: Total count 1199 - Distinct count 13 - Null count 320 SepT TEXT, -- AprOL TEXT, -- Example Values: `1`, `0`, `2`, `3` | Value Statics: Total count 358 - Distinct count 4 - Null count 1161 NovOL TEXT, -- Example Values: `0`, `2`, `1`, `4`, `3` | Value Statics: Total count 358 - Distinct count 5 - Null count 1161 FebW INTEGER, -- Example Values: `2`, `1`, `6`, `5`, `4` | Value Statics: Total count 1510 - Distinct count 14 - Null count 9 MarOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 7 - Null count 1161 hL INTEGER, -- MarL TEXT, -- Example Values: `4`, `0`, `2`, `1`, `3` | Value Statics: Total count 1485 - Distinct count 15 - Null count 34 hT INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1309 - Distinct count 14 - Null count 210 JanOL TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 rOTL TEXT, -- Example Values: `1`, `5`, `3`, `4`, `0` | Value Statics: Total count 358 - Distinct count 11 - Null count 1161 DecL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 MarT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1275 - Distinct count 8 - Null count 244 FebL INTEGER, -- Example Values: `3`, `5`, `0`, `1`, `2` | Value Statics: Total count 1510 - Distinct count 13 - Null count 9 MarW TEXT, -- Example Values: `1`, `3`, `0`, `2`, `5` | Value Statics: Total count 1485 - Distinct count 14 - Null count 34 AprT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 808 - Distinct count 6 - Null count 711 OctT TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 989 - Distinct count 7 - Null count 530 DecOL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 DecT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1263 - Distinct count 8 - Null count 256 NovT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1148 - Distinct count 9 - Null count 371 hW INTEGER, -- AprL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 SepOL TEXT, -- Example Values: `0` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 rW INTEGER, -- rL INTEGER, -- hOTL TEXT, -- Example Values: `2`, `3`, `1`, `0`, `4` | Value Statics: Total count 358 - Distinct count 12 - Null count 1161 SepL TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 ); CREATE TABLE Master ( lastNHL TEXT, -- deathMon TEXT, -- Example Values: `8`, `2`, `12`, `5`, `3` | Value Statics: Total count 1173 - Distinct count 12 - Null count 6588 birthCity TEXT, -- lastName TEXT not null, -- height TEXT, -- pos TEXT, -- Example Values: `C`, `D`, `G`, `L`, `R` | Value Statics: Total count 7447 - Distinct count 18 - Null count 314 nameGiven TEXT, -- playerID TEXT, -- deathDay TEXT, -- deathYear TEXT, -- hofID TEXT, -- deathCountry TEXT, -- Example Values: `USA`, `Canada`, `France`, `Belgium`, `Russia` | Value Statics: Total count 498 - Distinct count 14 - Null count 7263 deathState TEXT, -- firstNHL TEXT, -- birthCountry TEXT, -- birthDay TEXT, -- legendsID TEXT, -- hrefID TEXT, -- coachID TEXT, -- birthState TEXT, -- birthMon TEXT, -- Example Values: `3`, `8`, `2`, `5`, `12` | Value Statics: Total count 7506 - Distinct count 12 - Null count 255 deathCity TEXT, -- firstName TEXT, -- nameNick TEXT, -- firstWHA TEXT, -- Example Values: `1975`, `1976`, `1974`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 lastWHA TEXT, -- Example Values: `1975`, `1977`, `1976`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade, ihdbID TEXT, -- birthYear TEXT, -- weight TEXT, -- nameNote TEXT, -- Example Values: `also known as Bellehumeur`, `also listed as Bourdginon`, `born Bodnarchuk`, `also known as Bowcher`, `also known as Burmeister` | Value Statics: Total count 18 - Distinct count 18 - Null count 7743 shootCatch TEXT, -- Example Values: `L`, `R`, `B` | Value Statics: Total count 7048 - Distinct count 3 - Null count 713 ); CREATE TABLE TeamsPost ( year INTEGER not null, -- G INTEGER, -- PPG TEXT, -- L INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 12 - Null count 0 BenchMinor TEXT, -- Example Values: `0`, `6`, `2`, `4`, `10` | Value Statics: Total count 572 - Distinct count 8 - Null count 355 PKC TEXT, -- SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 604 - Distinct count 9 - Null count 323 tmID TEXT not null, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL`, `WHA` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 PPC TEXT, -- PIM TEXT, -- GA INTEGER, -- GF INTEGER, -- SHF TEXT, -- Example Values: `0`, `1`, `3`, `5`, `2` | Value Statics: Total count 636 - Distinct count 11 - Null count 291 T INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 17 - Null count 0 primary key (year, tmID), PKG TEXT, -- ); CREATE TABLE AwardsPlayers ( primary key (playerID, award, year), playerID TEXT not null, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, award TEXT not null, -- year INTEGER not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 2091 - Distinct count 2 - Null count 0 note TEXT, -- Example Values: `tie`, `shared`, `Most Gentlemanly`, `Rookie`, `Best Goaltender` | Value Statics: Total count 127 - Distinct count 8 - Null count 1964 pos TEXT, -- Example Values: `C`, `LW`, `F`, `RW`, `D` | Value Statics: Total count 1231 - Distinct count 7 - Null count 860 ); CREATE TABLE GoaliesShootout ( year INTEGER, -- Example Values: `2005`, `2006`, `2008`, `2009`, `2010` | Value Statics: Total count 480 - Distinct count 7 - Null count 0 stint INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 480 - Distinct count 2 - Null count 0 tmID TEXT, -- W INTEGER, -- Example Values: `2`, `0`, `1`, `7`, `6` | Value Statics: Total count 480 - Distinct count 11 - Null count 0 L INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `4` | Value Statics: Total count 480 - Distinct count 10 - Null count 0 playerID TEXT, -- GA INTEGER, -- SA INTEGER, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE Teams ( L INTEGER, -- name TEXT, -- W INTEGER, -- confID TEXT, -- Example Values: `CC`, `WA`, `WC`, `EC` | Value Statics: Total count 902 - Distinct count 4 - Null count 617 GA INTEGER, -- SoL TEXT, -- Example Values: `7`, `5`, `8`, `2`, `3` | Value Statics: Total count 210 - Distinct count 12 - Null count 1309 BenchMinor TEXT, -- playoff TEXT, -- lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 G INTEGER, -- GF INTEGER, -- OTL TEXT, -- Example Values: `3`, `4`, `6`, `5`, `0` | Value Statics: Total count 358 - Distinct count 18 - Null count 1161 tmID TEXT not null, -- franchID TEXT, -- primary key (year, tmID), PPC TEXT, -- SHF TEXT, -- T INTEGER, -- SoW TEXT, -- Example Values: `3`, `5`, `2`, `8`, `12` | Value Statics: Total count 210 - Distinct count 15 - Null count 1309 Pts INTEGER, -- PKG TEXT, -- PPG TEXT, -- PKC TEXT, -- divID TEXT, -- Example Values: `AM`, `CA`, `ED`, `WD`, `WW` | Value Statics: Total count 1171 - Distinct count 17 - Null count 348 PIM TEXT, -- rank INTEGER, -- Example Values: `4`, `5`, `7`, `6`, `1` | Value Statics: Total count 1519 - Distinct count 10 - Null count 0 SHA TEXT, -- year INTEGER not null, -- ); CREATE TABLE TeamVsTeam ( oppID TEXT not null, -- T INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 19962 - Distinct count 9 - Null count 5640 foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade, OTL TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 9874 - Distinct count 5 - Null count 15728 tmID TEXT not null, -- primary key (year, tmID, oppID), lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 25602 - Distinct count 5 - Null count 0 year INTEGER not null, -- L INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `0`, `3`, `4` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE ScoringSC ( foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `VML`, `CAT`, `VIC`, `TRS`, `MOC` | Value Statics: Total count 284 - Distinct count 17 - Null count 0 year INTEGER, -- Example Values: `1920`, `1921`, `1923`, `1924`, `1925` | Value Statics: Total count 284 - Distinct count 14 - Null count 0 playerID TEXT, -- G INTEGER, -- Example Values: `0`, `2`, `6`, `1`, `3` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, GP INTEGER, -- Example Values: `4`, `5`, `2`, `1`, `3` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 A INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 PIM INTEGER, -- pos TEXT, -- Example Values: `R`, `C`, `L`, `F`, `G` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `PCHA`, `WCHL`, `NHL`, `NHA` | Value Statics: Total count 284 - Distinct count 4 - Null count 0 Pts INTEGER, -- Example Values: `0`, `3`, `7`, `1`, `2` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 ); CREATE TABLE CombinedShutouts ( foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, month INTEGER, -- Example Values: `3`, `2`, `11`, `1`, `12` | Value Statics: Total count 54 - Distinct count 8 - Null count 0 oppID TEXT, -- foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade, "R/P" TEXT, -- Example Values: `R`, `P` | Value Statics: Total count 54 - Distinct count 2 - Null count 0 date INTEGER, -- tmID TEXT, -- IDgoalie1 TEXT, -- year INTEGER, -- IDgoalie2 TEXT, -- ); CREATE TABLE GoaliesSC ( GP INTEGER, -- Example Values: `3`, `5`, `6`, `4`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `OT1`, `OTS`, `MTM`, `TBS`, `SEA` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 playerID TEXT not null, -- Example Values: `benedcl01`, `clancki01`, `holmeha01`, `lehmahu01`, `lindsbe01` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, Min INTEGER, -- Example Values: `180`, `300`, `361`, `240`, `2` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 SHO INTEGER, -- Example Values: `0`, `1`, `3`, `2` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 W INTEGER, -- Example Values: `0`, `3`, `5`, `2`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 GA INTEGER, -- Example Values: `26`, `11`, `12`, `8`, `3` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 31 - Distinct count 2 - Null count 0 year INTEGER not null, -- Example Values: `1914`, `1919`, `1920`, `1922`, `1925` | Value Statics: Total count 31 - Distinct count 14 - Null count 0 primary key (playerID, year), L INTEGER, -- Example Values: `3`, `2`, `1`, `0` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 ); CREATE TABLE Goalies ( PostT TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 106 - Distinct count 5 - Null count 4172 SHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 4257 - Distinct count 17 - Null count 21 L TEXT, -- PostMin TEXT, -- PostW TEXT, -- Example Values: `0`, `6`, `1`, `2`, `3` | Value Statics: Total count 1439 - Distinct count 17 - Null count 2839 Min TEXT, -- PostGA TEXT, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 4278 - Distinct count 5 - Null count 0 ENG TEXT, -- Example Values: `0`, `1`, `3`, `4`, `5` | Value Statics: Total count 3533 - Distinct count 13 - Null count 745 GA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostSA TEXT, -- primary key (playerID, year, stint), playerID TEXT not null, -- "T/OL" TEXT, -- W TEXT, -- PostENG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 1187 - Distinct count 6 - Null count 3091 GP TEXT, -- PostSHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 8 - Null count 2839 SA TEXT, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 4278 - Distinct count 3 - Null count 0 PostGP TEXT, -- tmID TEXT, -- year INTEGER not null, -- PostL TEXT, -- Example Values: `0`, `1`, `5`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 12 - Null count 2839 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE TeamsHalf ( GA INTEGER, -- year INTEGER not null, -- Example Values: `1916`, `1917`, `1918`, `1919`, `1920` | Value Statics: Total count 41 - Distinct count 5 - Null count 0 primary key (year, tmID, half), tmID TEXT not null, -- Example Values: `MOC`, `MOW`, `OT1`, `QU1`, `TBS` | Value Statics: Total count 41 - Distinct count 13 - Null count 0 rank INTEGER, -- Example Values: `1`, `3`, `5`, `4`, `2` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 L INTEGER, -- Example Values: `3`, `7`, `8`, `2`, `5` | Value Statics: Total count 41 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 half INTEGER not null, -- Example Values: `1`, `2` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 GF INTEGER, -- T INTEGER, -- Example Values: `0` | Value Statics: Total count 41 - Distinct count 1 - Null count 0 foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade, G INTEGER, -- Example Values: `10`, `4`, `14`, `8`, `6` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 W INTEGER, -- Example Values: `7`, `3`, `2`, `8`, `5` | Value Statics: Total count 41 - Distinct count 10 - Null count 0 ); CREATE TABLE ScoringSup ( SHA TEXT, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 41 - Distinct count 4 - Null count 96 year INTEGER, -- Example Values: `1988`, `1989`, `1987`, `1990` | Value Statics: Total count 137 - Distinct count 4 - Null count 0 playerID TEXT, -- PPA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, ); CREATE TABLE Coaches ( coachID TEXT not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 1812 - Distinct count 5 - Null count 0 t INTEGER, -- l INTEGER, -- tmID TEXT not null, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 1812 - Distinct count 3 - Null count 0 postw TEXT, -- Example Values: `3`, `0`, `2`, `6`, `5` | Value Statics: Total count 927 - Distinct count 17 - Null count 885 w INTEGER, -- year INTEGER not null, -- notes TEXT, -- Example Values: `interim`, `co-coach with Barry Smith`, `co-coach with Dave Lewis` | Value Statics: Total count 11 - Distinct count 3 - Null count 1801 postg TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, g INTEGER, -- postl TEXT, -- Example Values: `4`, `5`, `6`, `7`, `2` | Value Statics: Total count 927 - Distinct count 12 - Null count 885 postt TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 927 - Distinct count 5 - Null count 885 primary key (coachID, year, tmID, stint), ); CREATE TABLE TeamsSC ( GF INTEGER, -- Example Values: `12`, `16`, `13`, `8`, `26` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 GA INTEGER, -- Example Values: `16`, `12`, `8`, `13`, `26` | Value Statics: Total count 30 - Distinct count 16 - Null count 0 G INTEGER, -- Example Values: `3`, `5`, `4`, `2`, `6` | Value Statics: Total count 30 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `5` | Value Statics: Total count 30 - Distinct count 6 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 30 - Distinct count 2 - Null count 0 L INTEGER, -- Example Values: `2`, `1`, `0`, `3` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT not null, -- Example Values: `QU1`, `VA1`, `TBS`, `OT1`, `VML` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 PIM TEXT, -- Example Values: `24`, `20`, `75`, `53`, `50` | Value Statics: Total count 8 - Distinct count 7 - Null count 22 year INTEGER not null, -- Example Values: `1912`, `1913`, `1914`, `1915`, `1916` | Value Statics: Total count 30 - Distinct count 14 - Null count 0 primary key (year, tmID), );
superstore
How many orders in the south superstore with the fastest delivery are items of furniture?
fastest delivery refers to Ship Mode = 'First Class'; furniture refers to Category = 'Furniture'
SELECT COUNT(T1.`Order ID`) FROM south_superstore AS T1 INNER JOIN product AS T2 ON T1.`Product ID` = T2.`Product ID` WHERE T1.`Ship Mode` = 'First Class' AND T2.Category = 'Furniture'
CREATE TABLE west_superstore ( Profit REAL, -- Region TEXT, -- Example Values: `West` | Value Statics: Total count 6406 - Distinct count 1 - Null count 0 "Product ID" TEXT, -- foreign key ("Product ID", Region) references product("Product ID",Region), "Order Date" DATE, -- foreign key ("Customer ID", Region) references people("Customer ID",Region), "Ship Mode" TEXT, -- Example Values: `Second Class`, `Standard Class`, `First Class`, `Same Day` | Value Statics: Total count 6406 - Distinct count 4 - Null count 0 "Customer ID" TEXT, -- "Order ID" TEXT, -- "Row ID" INTEGER primary key, Sales REAL, -- Quantity INTEGER, -- Example Values: `3`, `5`, `4`, `10`, `2` | Value Statics: Total count 6406 - Distinct count 14 - Null count 0 Discount REAL, -- Example Values: `0.0`, `0.15`, `0.2`, `0.7`, `0.5` | Value Statics: Total count 6406 - Distinct count 5 - Null count 0 "Ship Date" DATE, -- ); CREATE TABLE people ( Region TEXT, -- Example Values: `Central`, `East`, `West`, `South` | Value Statics: Total count 2501 - Distinct count 4 - Null count 0 Country TEXT, -- Example Values: `United States` | Value Statics: Total count 2501 - Distinct count 1 - Null count 0 State TEXT, -- primary key ("Customer ID", Region), City TEXT, -- Segment TEXT, -- Example Values: `Consumer`, `Home Office`, `Corporate` | Value Statics: Total count 2501 - Distinct count 3 - Null count 0 "Customer ID" TEXT, -- "Postal Code" INTEGER, -- "Customer Name" TEXT, -- ); CREATE TABLE product ( "Product ID" TEXT, -- Region TEXT, -- Example Values: `Central`, `South`, `West`, `East` | Value Statics: Total count 5298 - Distinct count 4 - Null count 0 "Sub-Category" TEXT, -- Example Values: `Bookcases`, `Chairs`, `Furnishings`, `Tables`, `Appliances` | Value Statics: Total count 5298 - Distinct count 17 - Null count 0 Category TEXT, -- Example Values: `Furniture`, `Office Supplies`, `Technology` | Value Statics: Total count 5298 - Distinct count 3 - Null count 0 "Product Name" TEXT, -- primary key ("Product ID", Region), ); CREATE TABLE central_superstore ( "Ship Mode" TEXT, -- Example Values: `Standard Class`, `First Class`, `Second Class`, `Same Day` | Value Statics: Total count 4646 - Distinct count 4 - Null count 0 Quantity INTEGER, -- Example Values: `2`, `3`, `7`, `1`, `5` | Value Statics: Total count 4646 - Distinct count 14 - Null count 0 "Ship Date" DATE, -- "Order Date" DATE, -- "Order ID" TEXT, -- "Row ID" INTEGER primary key, "Product ID" TEXT, -- foreign key ("Customer ID", Region) references people("Customer ID",Region), Sales REAL, -- foreign key ("Product ID", Region) references product("Product ID",Region), Profit REAL, -- "Customer ID" TEXT, -- Discount REAL, -- Example Values: `0.2`, `0.8`, `0.6`, `0.0`, `0.1` | Value Statics: Total count 4646 - Distinct count 9 - Null count 0 Region TEXT, -- Example Values: `Central` | Value Statics: Total count 4646 - Distinct count 1 - Null count 0 ); CREATE TABLE east_superstore ( "Row ID" INTEGER primary key, Region TEXT, -- Example Values: `East` | Value Statics: Total count 5696 - Distinct count 1 - Null count 0 "Order ID" TEXT, -- "Product ID" TEXT, -- Sales REAL, -- foreign key ("Product ID", Region) references product("Product ID",Region), Discount REAL, -- Example Values: `0.2`, `0.0`, `0.7`, `0.5`, `0.4` | Value Statics: Total count 5696 - Distinct count 7 - Null count 0 Quantity INTEGER, -- Example Values: `3`, `2`, `7`, `4`, `6` | Value Statics: Total count 5696 - Distinct count 14 - Null count 0 Profit REAL, -- foreign key ("Customer ID", Region) references people("Customer ID",Region), "Ship Mode" TEXT, -- Example Values: `Standard Class`, `First Class`, `Second Class`, `Same Day` | Value Statics: Total count 5696 - Distinct count 4 - Null count 0 "Customer ID" TEXT, -- "Order Date" DATE, -- "Ship Date" DATE, -- ); CREATE TABLE south_superstore ( "Product ID" TEXT, -- Profit REAL, -- Sales REAL, -- "Order Date" DATE, -- "Customer ID" TEXT, -- Discount REAL, -- Example Values: `0.0`, `0.7`, `0.2`, `0.5`, `0.45` | Value Statics: Total count 3240 - Distinct count 6 - Null count 0 Region TEXT, -- Example Values: `South` | Value Statics: Total count 3240 - Distinct count 1 - Null count 0 "Ship Date" DATE, -- foreign key ("Product ID", Region) references product("Product ID",Region), foreign key ("Customer ID", Region) references people("Customer ID",Region), Quantity INTEGER, -- Example Values: `3`, `9`, `2`, `4`, `1` | Value Statics: Total count 3240 - Distinct count 14 - Null count 0 "Order ID" TEXT, -- "Row ID" INTEGER primary key, "Ship Mode" TEXT, -- Example Values: `First Class`, `Standard Class`, `Second Class`, `Same Day` | Value Statics: Total count 3240 - Distinct count 4 - Null count 0 );
craftbeer
Where in New York can you locate the brewery that makes the bitterest beer? List both the brewery's name and the name of the city.
The more IBU, the more bitter the beer is, bitterest means highest IBU.
SELECT T2.name, T2.city FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T2.state = 'NY' ORDER BY T1.ibu DESC LIMIT 1
CREATE TABLE beers ( brewery_id INTEGER not null constraint beers_ibfk_1 references breweries, -- id INTEGER not null primary key, abv REAL, -- style TEXT, -- ibu REAL, -- name TEXT not null, -- ounces REAL not null, -- Example Values: `12.0`, `16.0`, `24.0`, `19.2`, `8.4` | Value Statics: Total count 2410 - Distinct count 7 - Null count 0 ); CREATE TABLE breweries ( id INTEGER not null primary key, city TEXT null, -- state TEXT null, -- name TEXT null, -- );
hockey
What is the name of the losing team during an exhibition game in 1912?
exhibition game refers to note = 'EX'; team of losing team refers to tmIDLoser
SELECT T2.name FROM SeriesPost AS T1 INNER JOIN Teams AS T2 ON T1.year = T2.year AND tmIDLoser = tmID WHERE T1.note = 'EX' AND T2.year = '1912'
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value Statics: Total count 45967 - Distinct count 5 - Null count 0 PostG TEXT, -- PostSHG TEXT, -- Example Values: `0`, `1`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 4 - Null count 31475 "+/-" TEXT, -- "Post+/-" TEXT, -- PostSHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 8855 - Distinct count 5 - Null count 37112 PPA TEXT, -- SOG TEXT, -- PostSOG TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, pos TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostPPG TEXT, -- Example Values: `0`, `1`, `5`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 10 - Null count 31475 SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 23214 - Distinct count 11 - Null count 22753 SHG TEXT, -- Example Values: `0`, `2`, `1`, `5`, `7` | Value Statics: Total count 37744 - Distinct count 14 - Null count 8223 Pts INTEGER, -- A INTEGER, -- PostPIM TEXT, -- G INTEGER, -- PostGWG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 15657 - Distinct count 8 - Null count 30310 PostPts TEXT, -- playerID TEXT, -- stint INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 45967 - Distinct count 4 - Null count 0 GWG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 36567 - Distinct count 16 - Null count 9400 PPG TEXT, -- PostPPA TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 8854 - Distinct count 17 - Null count 37113 year INTEGER, -- ); CREATE TABLE AwardsCoaches ( coachID TEXT, -- foreign key (coachID) references Coaches (coachID), year INTEGER, -- note TEXT, -- award TEXT, -- Example Values: `First Team All-Star`, `Second Team All-Star`, `Jack Adams`, `Baldwin`, `Schmertz` | Value Statics: Total count 77 - Distinct count 5 - Null count 0 lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 77 - Distinct count 2 - Null count 0 ); CREATE TABLE HOF ( category TEXT, -- Example Values: `Player`, `Builder`, `Referee/Linesman` | Value Statics: Total count 365 - Distinct count 3 - Null count 0 hofID TEXT not null primary key, year INTEGER, -- name TEXT, -- ); CREATE TABLE SeriesPost ( GoalsLoser INTEGER, -- note TEXT, -- Example Values: `EX`, `TG`, `ND`, `DEF` | Value Statics: Total count 59 - Distinct count 4 - Null count 773 lgIDLoser TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDWinner TEXT, -- series TEXT, -- Example Values: `A`, `B`, `C`, `D`, `E` | Value Statics: Total count 739 - Distinct count 15 - Null count 93 L INTEGER, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDLoser TEXT, -- foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade, year INTEGER, -- foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, T INTEGER, -- Example Values: `0`, `1`, `2` | Value Statics: Total count 832 - Distinct count 3 - Null count 0 lgIDWinner TEXT, -- Example Values: `PCHA`, `NHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 round TEXT, -- Example Values: `SCF`, `F`, `SF`, `SCSF`, `WP` | Value Statics: Total count 832 - Distinct count 13 - Null count 0 GoalsWinner INTEGER, -- W INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `0` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 ); CREATE TABLE abbrev ( Fullname TEXT, -- Code TEXT not null, -- primary key (Type, Code), Type TEXT not null, -- Example Values: `Conference`, `Division`, `Playoffs`, `Round` | Value Statics: Total count 58 - Distinct count 4 - Null count 0 ); CREATE TABLE AwardsMisc ( year INTEGER, -- lgID TEXT, -- Example Values: `NHL` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 note TEXT, -- Example Values: `posthumous` | Value Statics: Total count 15 - Distinct count 1 - Null count 109 name TEXT not null primary key, ID TEXT, -- award TEXT, -- Example Values: `Patrick` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 ); CREATE TABLE ScoringShootout ( year INTEGER, -- Example Values: `2006`, `2005`, `2007`, `2009`, `2008` | Value Statics: Total count 2072 - Distinct count 7 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, stint INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 2072 - Distinct count 3 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, G INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 2072 - Distinct count 16 - Null count 0 tmID TEXT, -- GDG INTEGER, -- Example Values: `0`, `1`, `2`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 8 - Null count 0 S INTEGER, -- Example Values: `1`, `2`, `5`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 19 - Null count 0 playerID TEXT, -- ); CREATE TABLE TeamSplits ( OctOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `5` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovL TEXT, -- Example Values: `1`, `4`, `3`, `2`, `0` | Value Statics: Total count 1358 - Distinct count 14 - Null count 161 FebOL TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovW TEXT, -- Example Values: `5`, `1`, `2`, `0`, `4` | Value Statics: Total count 1358 - Distinct count 13 - Null count 161 primary key (year, tmID), JanT INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 1305 - Distinct count 9 - Null count 214 SepW TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 JanL INTEGER, -- Example Values: `1`, `3`, `2`, `0`, `6` | Value Statics: Total count 1515 - Distinct count 15 - Null count 4 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 OctW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1199 - Distinct count 12 - Null count 320 AprW TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 FebT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1300 - Distinct count 8 - Null count 219 JanW INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 1515 - Distinct count 14 - Null count 4 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, rT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `6` | Value Statics: Total count 1309 - Distinct count 16 - Null count 210 tmID TEXT not null, -- DecW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 year INTEGER not null, -- OctL TEXT, -- Example Values: `1`, `0`, `2`, `4`, `5` | Value Statics: Total count 1199 - Distinct count 13 - Null count 320 SepT TEXT, -- AprOL TEXT, -- Example Values: `1`, `0`, `2`, `3` | Value Statics: Total count 358 - Distinct count 4 - Null count 1161 NovOL TEXT, -- Example Values: `0`, `2`, `1`, `4`, `3` | Value Statics: Total count 358 - Distinct count 5 - Null count 1161 FebW INTEGER, -- Example Values: `2`, `1`, `6`, `5`, `4` | Value Statics: Total count 1510 - Distinct count 14 - Null count 9 MarOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 7 - Null count 1161 hL INTEGER, -- MarL TEXT, -- Example Values: `4`, `0`, `2`, `1`, `3` | Value Statics: Total count 1485 - Distinct count 15 - Null count 34 hT INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1309 - Distinct count 14 - Null count 210 JanOL TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 rOTL TEXT, -- Example Values: `1`, `5`, `3`, `4`, `0` | Value Statics: Total count 358 - Distinct count 11 - Null count 1161 DecL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 MarT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1275 - Distinct count 8 - Null count 244 FebL INTEGER, -- Example Values: `3`, `5`, `0`, `1`, `2` | Value Statics: Total count 1510 - Distinct count 13 - Null count 9 MarW TEXT, -- Example Values: `1`, `3`, `0`, `2`, `5` | Value Statics: Total count 1485 - Distinct count 14 - Null count 34 AprT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 808 - Distinct count 6 - Null count 711 OctT TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 989 - Distinct count 7 - Null count 530 DecOL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 DecT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1263 - Distinct count 8 - Null count 256 NovT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1148 - Distinct count 9 - Null count 371 hW INTEGER, -- AprL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 SepOL TEXT, -- Example Values: `0` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 rW INTEGER, -- rL INTEGER, -- hOTL TEXT, -- Example Values: `2`, `3`, `1`, `0`, `4` | Value Statics: Total count 358 - Distinct count 12 - Null count 1161 SepL TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 ); CREATE TABLE Master ( lastNHL TEXT, -- deathMon TEXT, -- Example Values: `8`, `2`, `12`, `5`, `3` | Value Statics: Total count 1173 - Distinct count 12 - Null count 6588 birthCity TEXT, -- lastName TEXT not null, -- height TEXT, -- pos TEXT, -- Example Values: `C`, `D`, `G`, `L`, `R` | Value Statics: Total count 7447 - Distinct count 18 - Null count 314 nameGiven TEXT, -- playerID TEXT, -- deathDay TEXT, -- deathYear TEXT, -- hofID TEXT, -- deathCountry TEXT, -- Example Values: `USA`, `Canada`, `France`, `Belgium`, `Russia` | Value Statics: Total count 498 - Distinct count 14 - Null count 7263 deathState TEXT, -- firstNHL TEXT, -- birthCountry TEXT, -- birthDay TEXT, -- legendsID TEXT, -- hrefID TEXT, -- coachID TEXT, -- birthState TEXT, -- birthMon TEXT, -- Example Values: `3`, `8`, `2`, `5`, `12` | Value Statics: Total count 7506 - Distinct count 12 - Null count 255 deathCity TEXT, -- firstName TEXT, -- nameNick TEXT, -- firstWHA TEXT, -- Example Values: `1975`, `1976`, `1974`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 lastWHA TEXT, -- Example Values: `1975`, `1977`, `1976`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade, ihdbID TEXT, -- birthYear TEXT, -- weight TEXT, -- nameNote TEXT, -- Example Values: `also known as Bellehumeur`, `also listed as Bourdginon`, `born Bodnarchuk`, `also known as Bowcher`, `also known as Burmeister` | Value Statics: Total count 18 - Distinct count 18 - Null count 7743 shootCatch TEXT, -- Example Values: `L`, `R`, `B` | Value Statics: Total count 7048 - Distinct count 3 - Null count 713 ); CREATE TABLE TeamsPost ( year INTEGER not null, -- G INTEGER, -- PPG TEXT, -- L INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 12 - Null count 0 BenchMinor TEXT, -- Example Values: `0`, `6`, `2`, `4`, `10` | Value Statics: Total count 572 - Distinct count 8 - Null count 355 PKC TEXT, -- SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 604 - Distinct count 9 - Null count 323 tmID TEXT not null, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL`, `WHA` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 PPC TEXT, -- PIM TEXT, -- GA INTEGER, -- GF INTEGER, -- SHF TEXT, -- Example Values: `0`, `1`, `3`, `5`, `2` | Value Statics: Total count 636 - Distinct count 11 - Null count 291 T INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 17 - Null count 0 primary key (year, tmID), PKG TEXT, -- ); CREATE TABLE AwardsPlayers ( primary key (playerID, award, year), playerID TEXT not null, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, award TEXT not null, -- year INTEGER not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 2091 - Distinct count 2 - Null count 0 note TEXT, -- Example Values: `tie`, `shared`, `Most Gentlemanly`, `Rookie`, `Best Goaltender` | Value Statics: Total count 127 - Distinct count 8 - Null count 1964 pos TEXT, -- Example Values: `C`, `LW`, `F`, `RW`, `D` | Value Statics: Total count 1231 - Distinct count 7 - Null count 860 ); CREATE TABLE GoaliesShootout ( year INTEGER, -- Example Values: `2005`, `2006`, `2008`, `2009`, `2010` | Value Statics: Total count 480 - Distinct count 7 - Null count 0 stint INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 480 - Distinct count 2 - Null count 0 tmID TEXT, -- W INTEGER, -- Example Values: `2`, `0`, `1`, `7`, `6` | Value Statics: Total count 480 - Distinct count 11 - Null count 0 L INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `4` | Value Statics: Total count 480 - Distinct count 10 - Null count 0 playerID TEXT, -- GA INTEGER, -- SA INTEGER, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE Teams ( L INTEGER, -- name TEXT, -- W INTEGER, -- confID TEXT, -- Example Values: `CC`, `WA`, `WC`, `EC` | Value Statics: Total count 902 - Distinct count 4 - Null count 617 GA INTEGER, -- SoL TEXT, -- Example Values: `7`, `5`, `8`, `2`, `3` | Value Statics: Total count 210 - Distinct count 12 - Null count 1309 BenchMinor TEXT, -- playoff TEXT, -- lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 G INTEGER, -- GF INTEGER, -- OTL TEXT, -- Example Values: `3`, `4`, `6`, `5`, `0` | Value Statics: Total count 358 - Distinct count 18 - Null count 1161 tmID TEXT not null, -- franchID TEXT, -- primary key (year, tmID), PPC TEXT, -- SHF TEXT, -- T INTEGER, -- SoW TEXT, -- Example Values: `3`, `5`, `2`, `8`, `12` | Value Statics: Total count 210 - Distinct count 15 - Null count 1309 Pts INTEGER, -- PKG TEXT, -- PPG TEXT, -- PKC TEXT, -- divID TEXT, -- Example Values: `AM`, `CA`, `ED`, `WD`, `WW` | Value Statics: Total count 1171 - Distinct count 17 - Null count 348 PIM TEXT, -- rank INTEGER, -- Example Values: `4`, `5`, `7`, `6`, `1` | Value Statics: Total count 1519 - Distinct count 10 - Null count 0 SHA TEXT, -- year INTEGER not null, -- ); CREATE TABLE TeamVsTeam ( oppID TEXT not null, -- T INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 19962 - Distinct count 9 - Null count 5640 foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade, OTL TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 9874 - Distinct count 5 - Null count 15728 tmID TEXT not null, -- primary key (year, tmID, oppID), lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 25602 - Distinct count 5 - Null count 0 year INTEGER not null, -- L INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `0`, `3`, `4` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE ScoringSC ( foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `VML`, `CAT`, `VIC`, `TRS`, `MOC` | Value Statics: Total count 284 - Distinct count 17 - Null count 0 year INTEGER, -- Example Values: `1920`, `1921`, `1923`, `1924`, `1925` | Value Statics: Total count 284 - Distinct count 14 - Null count 0 playerID TEXT, -- G INTEGER, -- Example Values: `0`, `2`, `6`, `1`, `3` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, GP INTEGER, -- Example Values: `4`, `5`, `2`, `1`, `3` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 A INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 PIM INTEGER, -- pos TEXT, -- Example Values: `R`, `C`, `L`, `F`, `G` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `PCHA`, `WCHL`, `NHL`, `NHA` | Value Statics: Total count 284 - Distinct count 4 - Null count 0 Pts INTEGER, -- Example Values: `0`, `3`, `7`, `1`, `2` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 ); CREATE TABLE CombinedShutouts ( foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, month INTEGER, -- Example Values: `3`, `2`, `11`, `1`, `12` | Value Statics: Total count 54 - Distinct count 8 - Null count 0 oppID TEXT, -- foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade, "R/P" TEXT, -- Example Values: `R`, `P` | Value Statics: Total count 54 - Distinct count 2 - Null count 0 date INTEGER, -- tmID TEXT, -- IDgoalie1 TEXT, -- year INTEGER, -- IDgoalie2 TEXT, -- ); CREATE TABLE GoaliesSC ( GP INTEGER, -- Example Values: `3`, `5`, `6`, `4`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `OT1`, `OTS`, `MTM`, `TBS`, `SEA` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 playerID TEXT not null, -- Example Values: `benedcl01`, `clancki01`, `holmeha01`, `lehmahu01`, `lindsbe01` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, Min INTEGER, -- Example Values: `180`, `300`, `361`, `240`, `2` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 SHO INTEGER, -- Example Values: `0`, `1`, `3`, `2` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 W INTEGER, -- Example Values: `0`, `3`, `5`, `2`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 GA INTEGER, -- Example Values: `26`, `11`, `12`, `8`, `3` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 31 - Distinct count 2 - Null count 0 year INTEGER not null, -- Example Values: `1914`, `1919`, `1920`, `1922`, `1925` | Value Statics: Total count 31 - Distinct count 14 - Null count 0 primary key (playerID, year), L INTEGER, -- Example Values: `3`, `2`, `1`, `0` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 ); CREATE TABLE Goalies ( PostT TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 106 - Distinct count 5 - Null count 4172 SHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 4257 - Distinct count 17 - Null count 21 L TEXT, -- PostMin TEXT, -- PostW TEXT, -- Example Values: `0`, `6`, `1`, `2`, `3` | Value Statics: Total count 1439 - Distinct count 17 - Null count 2839 Min TEXT, -- PostGA TEXT, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 4278 - Distinct count 5 - Null count 0 ENG TEXT, -- Example Values: `0`, `1`, `3`, `4`, `5` | Value Statics: Total count 3533 - Distinct count 13 - Null count 745 GA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostSA TEXT, -- primary key (playerID, year, stint), playerID TEXT not null, -- "T/OL" TEXT, -- W TEXT, -- PostENG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 1187 - Distinct count 6 - Null count 3091 GP TEXT, -- PostSHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 8 - Null count 2839 SA TEXT, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 4278 - Distinct count 3 - Null count 0 PostGP TEXT, -- tmID TEXT, -- year INTEGER not null, -- PostL TEXT, -- Example Values: `0`, `1`, `5`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 12 - Null count 2839 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE TeamsHalf ( GA INTEGER, -- year INTEGER not null, -- Example Values: `1916`, `1917`, `1918`, `1919`, `1920` | Value Statics: Total count 41 - Distinct count 5 - Null count 0 primary key (year, tmID, half), tmID TEXT not null, -- Example Values: `MOC`, `MOW`, `OT1`, `QU1`, `TBS` | Value Statics: Total count 41 - Distinct count 13 - Null count 0 rank INTEGER, -- Example Values: `1`, `3`, `5`, `4`, `2` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 L INTEGER, -- Example Values: `3`, `7`, `8`, `2`, `5` | Value Statics: Total count 41 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 half INTEGER not null, -- Example Values: `1`, `2` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 GF INTEGER, -- T INTEGER, -- Example Values: `0` | Value Statics: Total count 41 - Distinct count 1 - Null count 0 foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade, G INTEGER, -- Example Values: `10`, `4`, `14`, `8`, `6` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 W INTEGER, -- Example Values: `7`, `3`, `2`, `8`, `5` | Value Statics: Total count 41 - Distinct count 10 - Null count 0 ); CREATE TABLE ScoringSup ( SHA TEXT, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 41 - Distinct count 4 - Null count 96 year INTEGER, -- Example Values: `1988`, `1989`, `1987`, `1990` | Value Statics: Total count 137 - Distinct count 4 - Null count 0 playerID TEXT, -- PPA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, ); CREATE TABLE Coaches ( coachID TEXT not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 1812 - Distinct count 5 - Null count 0 t INTEGER, -- l INTEGER, -- tmID TEXT not null, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 1812 - Distinct count 3 - Null count 0 postw TEXT, -- Example Values: `3`, `0`, `2`, `6`, `5` | Value Statics: Total count 927 - Distinct count 17 - Null count 885 w INTEGER, -- year INTEGER not null, -- notes TEXT, -- Example Values: `interim`, `co-coach with Barry Smith`, `co-coach with Dave Lewis` | Value Statics: Total count 11 - Distinct count 3 - Null count 1801 postg TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, g INTEGER, -- postl TEXT, -- Example Values: `4`, `5`, `6`, `7`, `2` | Value Statics: Total count 927 - Distinct count 12 - Null count 885 postt TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 927 - Distinct count 5 - Null count 885 primary key (coachID, year, tmID, stint), ); CREATE TABLE TeamsSC ( GF INTEGER, -- Example Values: `12`, `16`, `13`, `8`, `26` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 GA INTEGER, -- Example Values: `16`, `12`, `8`, `13`, `26` | Value Statics: Total count 30 - Distinct count 16 - Null count 0 G INTEGER, -- Example Values: `3`, `5`, `4`, `2`, `6` | Value Statics: Total count 30 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `5` | Value Statics: Total count 30 - Distinct count 6 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 30 - Distinct count 2 - Null count 0 L INTEGER, -- Example Values: `2`, `1`, `0`, `3` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT not null, -- Example Values: `QU1`, `VA1`, `TBS`, `OT1`, `VML` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 PIM TEXT, -- Example Values: `24`, `20`, `75`, `53`, `50` | Value Statics: Total count 8 - Distinct count 7 - Null count 22 year INTEGER not null, -- Example Values: `1912`, `1913`, `1914`, `1915`, `1916` | Value Statics: Total count 30 - Distinct count 14 - Null count 0 primary key (year, tmID), );
shooting
Of all male officers, what percentage are black officers?
male refers to gender = 'M'; black refers to race = 'B'; percentage = divide(count(officers where race = 'B'), count(officers)) where gender = 'M' * 100%
SELECT CAST(SUM(race = 'B') AS REAL) * 100 / COUNT(case_number) FROM officers WHERE gender = 'M'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
craftbeer
Which distinct state makes beer that has the least amount of bitterness?
null
SELECT DISTINCT T2.state, T1.ibu FROM beers AS T1 INNER JOIN breweries AS T2 ON T1.brewery_id = T2.id WHERE T1.ibu IS NOT NULL AND T1.ibu = ( SELECT MIN(ibu) FROM beers )
CREATE TABLE beers ( brewery_id INTEGER not null constraint beers_ibfk_1 references breweries, -- id INTEGER not null primary key, abv REAL, -- style TEXT, -- ibu REAL, -- name TEXT not null, -- ounces REAL not null, -- Example Values: `12.0`, `16.0`, `24.0`, `19.2`, `8.4` | Value Statics: Total count 2410 - Distinct count 7 - Null count 0 ); CREATE TABLE breweries ( id INTEGER not null primary key, city TEXT null, -- state TEXT null, -- name TEXT null, -- );
hockey
What are the awards won by the coach who coached the team with the most number of victories of all time? Indicate the choach ID.
victories' and 'wins' are synonyms; most number of victories refers to max(w)
SELECT DISTINCT T2.coachID, T1.award FROM AwardsCoaches AS T1 INNER JOIN Coaches AS T2 ON T1.coachID = T2.coachID GROUP BY T2.coachID, T1.award ORDER BY SUM(T2.w) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value Statics: Total count 45967 - Distinct count 5 - Null count 0 PostG TEXT, -- PostSHG TEXT, -- Example Values: `0`, `1`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 4 - Null count 31475 "+/-" TEXT, -- "Post+/-" TEXT, -- PostSHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 8855 - Distinct count 5 - Null count 37112 PPA TEXT, -- SOG TEXT, -- PostSOG TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, pos TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostPPG TEXT, -- Example Values: `0`, `1`, `5`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 10 - Null count 31475 SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 23214 - Distinct count 11 - Null count 22753 SHG TEXT, -- Example Values: `0`, `2`, `1`, `5`, `7` | Value Statics: Total count 37744 - Distinct count 14 - Null count 8223 Pts INTEGER, -- A INTEGER, -- PostPIM TEXT, -- G INTEGER, -- PostGWG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 15657 - Distinct count 8 - Null count 30310 PostPts TEXT, -- playerID TEXT, -- stint INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 45967 - Distinct count 4 - Null count 0 GWG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 36567 - Distinct count 16 - Null count 9400 PPG TEXT, -- PostPPA TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 8854 - Distinct count 17 - Null count 37113 year INTEGER, -- ); CREATE TABLE AwardsCoaches ( coachID TEXT, -- foreign key (coachID) references Coaches (coachID), year INTEGER, -- note TEXT, -- award TEXT, -- Example Values: `First Team All-Star`, `Second Team All-Star`, `Jack Adams`, `Baldwin`, `Schmertz` | Value Statics: Total count 77 - Distinct count 5 - Null count 0 lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 77 - Distinct count 2 - Null count 0 ); CREATE TABLE HOF ( category TEXT, -- Example Values: `Player`, `Builder`, `Referee/Linesman` | Value Statics: Total count 365 - Distinct count 3 - Null count 0 hofID TEXT not null primary key, year INTEGER, -- name TEXT, -- ); CREATE TABLE SeriesPost ( GoalsLoser INTEGER, -- note TEXT, -- Example Values: `EX`, `TG`, `ND`, `DEF` | Value Statics: Total count 59 - Distinct count 4 - Null count 773 lgIDLoser TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDWinner TEXT, -- series TEXT, -- Example Values: `A`, `B`, `C`, `D`, `E` | Value Statics: Total count 739 - Distinct count 15 - Null count 93 L INTEGER, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDLoser TEXT, -- foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade, year INTEGER, -- foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, T INTEGER, -- Example Values: `0`, `1`, `2` | Value Statics: Total count 832 - Distinct count 3 - Null count 0 lgIDWinner TEXT, -- Example Values: `PCHA`, `NHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 round TEXT, -- Example Values: `SCF`, `F`, `SF`, `SCSF`, `WP` | Value Statics: Total count 832 - Distinct count 13 - Null count 0 GoalsWinner INTEGER, -- W INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `0` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 ); CREATE TABLE abbrev ( Fullname TEXT, -- Code TEXT not null, -- primary key (Type, Code), Type TEXT not null, -- Example Values: `Conference`, `Division`, `Playoffs`, `Round` | Value Statics: Total count 58 - Distinct count 4 - Null count 0 ); CREATE TABLE AwardsMisc ( year INTEGER, -- lgID TEXT, -- Example Values: `NHL` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 note TEXT, -- Example Values: `posthumous` | Value Statics: Total count 15 - Distinct count 1 - Null count 109 name TEXT not null primary key, ID TEXT, -- award TEXT, -- Example Values: `Patrick` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 ); CREATE TABLE ScoringShootout ( year INTEGER, -- Example Values: `2006`, `2005`, `2007`, `2009`, `2008` | Value Statics: Total count 2072 - Distinct count 7 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, stint INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 2072 - Distinct count 3 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, G INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 2072 - Distinct count 16 - Null count 0 tmID TEXT, -- GDG INTEGER, -- Example Values: `0`, `1`, `2`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 8 - Null count 0 S INTEGER, -- Example Values: `1`, `2`, `5`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 19 - Null count 0 playerID TEXT, -- ); CREATE TABLE TeamSplits ( OctOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `5` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovL TEXT, -- Example Values: `1`, `4`, `3`, `2`, `0` | Value Statics: Total count 1358 - Distinct count 14 - Null count 161 FebOL TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovW TEXT, -- Example Values: `5`, `1`, `2`, `0`, `4` | Value Statics: Total count 1358 - Distinct count 13 - Null count 161 primary key (year, tmID), JanT INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 1305 - Distinct count 9 - Null count 214 SepW TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 JanL INTEGER, -- Example Values: `1`, `3`, `2`, `0`, `6` | Value Statics: Total count 1515 - Distinct count 15 - Null count 4 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 OctW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1199 - Distinct count 12 - Null count 320 AprW TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 FebT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1300 - Distinct count 8 - Null count 219 JanW INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 1515 - Distinct count 14 - Null count 4 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, rT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `6` | Value Statics: Total count 1309 - Distinct count 16 - Null count 210 tmID TEXT not null, -- DecW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 year INTEGER not null, -- OctL TEXT, -- Example Values: `1`, `0`, `2`, `4`, `5` | Value Statics: Total count 1199 - Distinct count 13 - Null count 320 SepT TEXT, -- AprOL TEXT, -- Example Values: `1`, `0`, `2`, `3` | Value Statics: Total count 358 - Distinct count 4 - Null count 1161 NovOL TEXT, -- Example Values: `0`, `2`, `1`, `4`, `3` | Value Statics: Total count 358 - Distinct count 5 - Null count 1161 FebW INTEGER, -- Example Values: `2`, `1`, `6`, `5`, `4` | Value Statics: Total count 1510 - Distinct count 14 - Null count 9 MarOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 7 - Null count 1161 hL INTEGER, -- MarL TEXT, -- Example Values: `4`, `0`, `2`, `1`, `3` | Value Statics: Total count 1485 - Distinct count 15 - Null count 34 hT INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1309 - Distinct count 14 - Null count 210 JanOL TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 rOTL TEXT, -- Example Values: `1`, `5`, `3`, `4`, `0` | Value Statics: Total count 358 - Distinct count 11 - Null count 1161 DecL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 MarT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1275 - Distinct count 8 - Null count 244 FebL INTEGER, -- Example Values: `3`, `5`, `0`, `1`, `2` | Value Statics: Total count 1510 - Distinct count 13 - Null count 9 MarW TEXT, -- Example Values: `1`, `3`, `0`, `2`, `5` | Value Statics: Total count 1485 - Distinct count 14 - Null count 34 AprT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 808 - Distinct count 6 - Null count 711 OctT TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 989 - Distinct count 7 - Null count 530 DecOL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 DecT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1263 - Distinct count 8 - Null count 256 NovT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1148 - Distinct count 9 - Null count 371 hW INTEGER, -- AprL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 SepOL TEXT, -- Example Values: `0` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 rW INTEGER, -- rL INTEGER, -- hOTL TEXT, -- Example Values: `2`, `3`, `1`, `0`, `4` | Value Statics: Total count 358 - Distinct count 12 - Null count 1161 SepL TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 ); CREATE TABLE Master ( lastNHL TEXT, -- deathMon TEXT, -- Example Values: `8`, `2`, `12`, `5`, `3` | Value Statics: Total count 1173 - Distinct count 12 - Null count 6588 birthCity TEXT, -- lastName TEXT not null, -- height TEXT, -- pos TEXT, -- Example Values: `C`, `D`, `G`, `L`, `R` | Value Statics: Total count 7447 - Distinct count 18 - Null count 314 nameGiven TEXT, -- playerID TEXT, -- deathDay TEXT, -- deathYear TEXT, -- hofID TEXT, -- deathCountry TEXT, -- Example Values: `USA`, `Canada`, `France`, `Belgium`, `Russia` | Value Statics: Total count 498 - Distinct count 14 - Null count 7263 deathState TEXT, -- firstNHL TEXT, -- birthCountry TEXT, -- birthDay TEXT, -- legendsID TEXT, -- hrefID TEXT, -- coachID TEXT, -- birthState TEXT, -- birthMon TEXT, -- Example Values: `3`, `8`, `2`, `5`, `12` | Value Statics: Total count 7506 - Distinct count 12 - Null count 255 deathCity TEXT, -- firstName TEXT, -- nameNick TEXT, -- firstWHA TEXT, -- Example Values: `1975`, `1976`, `1974`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 lastWHA TEXT, -- Example Values: `1975`, `1977`, `1976`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade, ihdbID TEXT, -- birthYear TEXT, -- weight TEXT, -- nameNote TEXT, -- Example Values: `also known as Bellehumeur`, `also listed as Bourdginon`, `born Bodnarchuk`, `also known as Bowcher`, `also known as Burmeister` | Value Statics: Total count 18 - Distinct count 18 - Null count 7743 shootCatch TEXT, -- Example Values: `L`, `R`, `B` | Value Statics: Total count 7048 - Distinct count 3 - Null count 713 ); CREATE TABLE TeamsPost ( year INTEGER not null, -- G INTEGER, -- PPG TEXT, -- L INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 12 - Null count 0 BenchMinor TEXT, -- Example Values: `0`, `6`, `2`, `4`, `10` | Value Statics: Total count 572 - Distinct count 8 - Null count 355 PKC TEXT, -- SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 604 - Distinct count 9 - Null count 323 tmID TEXT not null, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL`, `WHA` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 PPC TEXT, -- PIM TEXT, -- GA INTEGER, -- GF INTEGER, -- SHF TEXT, -- Example Values: `0`, `1`, `3`, `5`, `2` | Value Statics: Total count 636 - Distinct count 11 - Null count 291 T INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 17 - Null count 0 primary key (year, tmID), PKG TEXT, -- ); CREATE TABLE AwardsPlayers ( primary key (playerID, award, year), playerID TEXT not null, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, award TEXT not null, -- year INTEGER not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 2091 - Distinct count 2 - Null count 0 note TEXT, -- Example Values: `tie`, `shared`, `Most Gentlemanly`, `Rookie`, `Best Goaltender` | Value Statics: Total count 127 - Distinct count 8 - Null count 1964 pos TEXT, -- Example Values: `C`, `LW`, `F`, `RW`, `D` | Value Statics: Total count 1231 - Distinct count 7 - Null count 860 ); CREATE TABLE GoaliesShootout ( year INTEGER, -- Example Values: `2005`, `2006`, `2008`, `2009`, `2010` | Value Statics: Total count 480 - Distinct count 7 - Null count 0 stint INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 480 - Distinct count 2 - Null count 0 tmID TEXT, -- W INTEGER, -- Example Values: `2`, `0`, `1`, `7`, `6` | Value Statics: Total count 480 - Distinct count 11 - Null count 0 L INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `4` | Value Statics: Total count 480 - Distinct count 10 - Null count 0 playerID TEXT, -- GA INTEGER, -- SA INTEGER, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE Teams ( L INTEGER, -- name TEXT, -- W INTEGER, -- confID TEXT, -- Example Values: `CC`, `WA`, `WC`, `EC` | Value Statics: Total count 902 - Distinct count 4 - Null count 617 GA INTEGER, -- SoL TEXT, -- Example Values: `7`, `5`, `8`, `2`, `3` | Value Statics: Total count 210 - Distinct count 12 - Null count 1309 BenchMinor TEXT, -- playoff TEXT, -- lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 G INTEGER, -- GF INTEGER, -- OTL TEXT, -- Example Values: `3`, `4`, `6`, `5`, `0` | Value Statics: Total count 358 - Distinct count 18 - Null count 1161 tmID TEXT not null, -- franchID TEXT, -- primary key (year, tmID), PPC TEXT, -- SHF TEXT, -- T INTEGER, -- SoW TEXT, -- Example Values: `3`, `5`, `2`, `8`, `12` | Value Statics: Total count 210 - Distinct count 15 - Null count 1309 Pts INTEGER, -- PKG TEXT, -- PPG TEXT, -- PKC TEXT, -- divID TEXT, -- Example Values: `AM`, `CA`, `ED`, `WD`, `WW` | Value Statics: Total count 1171 - Distinct count 17 - Null count 348 PIM TEXT, -- rank INTEGER, -- Example Values: `4`, `5`, `7`, `6`, `1` | Value Statics: Total count 1519 - Distinct count 10 - Null count 0 SHA TEXT, -- year INTEGER not null, -- ); CREATE TABLE TeamVsTeam ( oppID TEXT not null, -- T INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 19962 - Distinct count 9 - Null count 5640 foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade, OTL TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 9874 - Distinct count 5 - Null count 15728 tmID TEXT not null, -- primary key (year, tmID, oppID), lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 25602 - Distinct count 5 - Null count 0 year INTEGER not null, -- L INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `0`, `3`, `4` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE ScoringSC ( foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `VML`, `CAT`, `VIC`, `TRS`, `MOC` | Value Statics: Total count 284 - Distinct count 17 - Null count 0 year INTEGER, -- Example Values: `1920`, `1921`, `1923`, `1924`, `1925` | Value Statics: Total count 284 - Distinct count 14 - Null count 0 playerID TEXT, -- G INTEGER, -- Example Values: `0`, `2`, `6`, `1`, `3` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, GP INTEGER, -- Example Values: `4`, `5`, `2`, `1`, `3` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 A INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 PIM INTEGER, -- pos TEXT, -- Example Values: `R`, `C`, `L`, `F`, `G` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `PCHA`, `WCHL`, `NHL`, `NHA` | Value Statics: Total count 284 - Distinct count 4 - Null count 0 Pts INTEGER, -- Example Values: `0`, `3`, `7`, `1`, `2` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 ); CREATE TABLE CombinedShutouts ( foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, month INTEGER, -- Example Values: `3`, `2`, `11`, `1`, `12` | Value Statics: Total count 54 - Distinct count 8 - Null count 0 oppID TEXT, -- foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade, "R/P" TEXT, -- Example Values: `R`, `P` | Value Statics: Total count 54 - Distinct count 2 - Null count 0 date INTEGER, -- tmID TEXT, -- IDgoalie1 TEXT, -- year INTEGER, -- IDgoalie2 TEXT, -- ); CREATE TABLE GoaliesSC ( GP INTEGER, -- Example Values: `3`, `5`, `6`, `4`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `OT1`, `OTS`, `MTM`, `TBS`, `SEA` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 playerID TEXT not null, -- Example Values: `benedcl01`, `clancki01`, `holmeha01`, `lehmahu01`, `lindsbe01` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, Min INTEGER, -- Example Values: `180`, `300`, `361`, `240`, `2` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 SHO INTEGER, -- Example Values: `0`, `1`, `3`, `2` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 W INTEGER, -- Example Values: `0`, `3`, `5`, `2`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 GA INTEGER, -- Example Values: `26`, `11`, `12`, `8`, `3` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 31 - Distinct count 2 - Null count 0 year INTEGER not null, -- Example Values: `1914`, `1919`, `1920`, `1922`, `1925` | Value Statics: Total count 31 - Distinct count 14 - Null count 0 primary key (playerID, year), L INTEGER, -- Example Values: `3`, `2`, `1`, `0` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 ); CREATE TABLE Goalies ( PostT TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 106 - Distinct count 5 - Null count 4172 SHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 4257 - Distinct count 17 - Null count 21 L TEXT, -- PostMin TEXT, -- PostW TEXT, -- Example Values: `0`, `6`, `1`, `2`, `3` | Value Statics: Total count 1439 - Distinct count 17 - Null count 2839 Min TEXT, -- PostGA TEXT, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 4278 - Distinct count 5 - Null count 0 ENG TEXT, -- Example Values: `0`, `1`, `3`, `4`, `5` | Value Statics: Total count 3533 - Distinct count 13 - Null count 745 GA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostSA TEXT, -- primary key (playerID, year, stint), playerID TEXT not null, -- "T/OL" TEXT, -- W TEXT, -- PostENG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 1187 - Distinct count 6 - Null count 3091 GP TEXT, -- PostSHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 8 - Null count 2839 SA TEXT, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 4278 - Distinct count 3 - Null count 0 PostGP TEXT, -- tmID TEXT, -- year INTEGER not null, -- PostL TEXT, -- Example Values: `0`, `1`, `5`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 12 - Null count 2839 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE TeamsHalf ( GA INTEGER, -- year INTEGER not null, -- Example Values: `1916`, `1917`, `1918`, `1919`, `1920` | Value Statics: Total count 41 - Distinct count 5 - Null count 0 primary key (year, tmID, half), tmID TEXT not null, -- Example Values: `MOC`, `MOW`, `OT1`, `QU1`, `TBS` | Value Statics: Total count 41 - Distinct count 13 - Null count 0 rank INTEGER, -- Example Values: `1`, `3`, `5`, `4`, `2` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 L INTEGER, -- Example Values: `3`, `7`, `8`, `2`, `5` | Value Statics: Total count 41 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 half INTEGER not null, -- Example Values: `1`, `2` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 GF INTEGER, -- T INTEGER, -- Example Values: `0` | Value Statics: Total count 41 - Distinct count 1 - Null count 0 foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade, G INTEGER, -- Example Values: `10`, `4`, `14`, `8`, `6` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 W INTEGER, -- Example Values: `7`, `3`, `2`, `8`, `5` | Value Statics: Total count 41 - Distinct count 10 - Null count 0 ); CREATE TABLE ScoringSup ( SHA TEXT, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 41 - Distinct count 4 - Null count 96 year INTEGER, -- Example Values: `1988`, `1989`, `1987`, `1990` | Value Statics: Total count 137 - Distinct count 4 - Null count 0 playerID TEXT, -- PPA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, ); CREATE TABLE Coaches ( coachID TEXT not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 1812 - Distinct count 5 - Null count 0 t INTEGER, -- l INTEGER, -- tmID TEXT not null, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 1812 - Distinct count 3 - Null count 0 postw TEXT, -- Example Values: `3`, `0`, `2`, `6`, `5` | Value Statics: Total count 927 - Distinct count 17 - Null count 885 w INTEGER, -- year INTEGER not null, -- notes TEXT, -- Example Values: `interim`, `co-coach with Barry Smith`, `co-coach with Dave Lewis` | Value Statics: Total count 11 - Distinct count 3 - Null count 1801 postg TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, g INTEGER, -- postl TEXT, -- Example Values: `4`, `5`, `6`, `7`, `2` | Value Statics: Total count 927 - Distinct count 12 - Null count 885 postt TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 927 - Distinct count 5 - Null count 885 primary key (coachID, year, tmID, stint), ); CREATE TABLE TeamsSC ( GF INTEGER, -- Example Values: `12`, `16`, `13`, `8`, `26` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 GA INTEGER, -- Example Values: `16`, `12`, `8`, `13`, `26` | Value Statics: Total count 30 - Distinct count 16 - Null count 0 G INTEGER, -- Example Values: `3`, `5`, `4`, `2`, `6` | Value Statics: Total count 30 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `5` | Value Statics: Total count 30 - Distinct count 6 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 30 - Distinct count 2 - Null count 0 L INTEGER, -- Example Values: `2`, `1`, `0`, `3` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT not null, -- Example Values: `QU1`, `VA1`, `TBS`, `OT1`, `VML` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 PIM TEXT, -- Example Values: `24`, `20`, `75`, `53`, `50` | Value Statics: Total count 8 - Distinct count 7 - Null count 22 year INTEGER not null, -- Example Values: `1912`, `1913`, `1914`, `1915`, `1916` | Value Statics: Total count 30 - Distinct count 14 - Null count 0 primary key (year, tmID), );
student_loan
List the longest duration of absense for a student enlisted in the fire department.
longest duration of absence refers to MAX(month); department refers to organ; organ = 'fire_department';
SELECT T1.month FROM longest_absense_from_school AS T1 INNER JOIN enlist AS T2 ON T1.name = T2.name WHERE T2.organ = 'fire_department' ORDER BY T1.month DESC LIMIT 1
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ); CREATE TABLE bool ( "name" TEXT default '' not null primary key, ); CREATE TABLE enlist ( "name" TEXT not null, -- foreign key ("name") references person ("name") on update cascade on delete cascade, organ TEXT not null, -- Example Values: `fire_department`, `air_force`, `navy`, `marines`, `foreign_legion` | Value Statics: Total count 306 - Distinct count 7 - Null count 0 ); CREATE TABLE unemployed ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE male ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE disabled ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE filed_for_bankrupcy ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE person ( "name" TEXT default '' not null primary key, ); CREATE TABLE no_payment_due ( bool TEXT null, -- Example Values: `neg`, `pos` | Value Statics: Total count 1000 - Distinct count 2 - Null count 0 "name" TEXT default '' not null primary key, foreign key (bool) references bool ("name") on update cascade on delete cascade, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE enrolled ( `name` TEXT NOT NULL, -- PRIMARY KEY (`name`,`school`), `month` INTEGER NOT NULL DEFAULT 0, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 1194 - Distinct count 15 - Null count 0 `school` TEXT NOT NULL, -- Example Values: `occ`, `smc`, `ucb`, `ucla`, `ucsd` | Value Statics: Total count 1194 - Distinct count 6 - Null count 0 FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, );
shooting
What is the percentage of subject who are female used the Vehicle as weapon?
female refers to gender = 'F'; use Vehicle as weapon refers to subject_weapon = 'Vehicle'; percentage = divide(count(case_number where subject_weapon = 'Vehicle'), count(case_number)) where gender = 'F' * 100%
SELECT CAST(SUM(T1.subject_weapon = 'Vehicle') AS REAL) * 100 / COUNT(T1.case_number) FROM incidents T1 INNER JOIN subjects T2 ON T1.case_number = T2.case_number WHERE T2.gender = 'F'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
food_inspection
In businesses with a score lower than 95 and located around the postal code of 94110, what is the percentage of businesses with a risk category of low risk?
DIVIDE(COUNT(business_id where risk_category = 'Low Risk', score < 95 and postal_code = 94110), COUNT(business_id where score < 95 and postal_code = 94110)) as percentage;
SELECT CAST(SUM(CASE WHEN T1.risk_category = 'Low Risk' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(T1.risk_category) FROM violations AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN businesses AS T3 ON T2.business_id = T3.business_id WHERE T2.score < 95 AND T3.postal_code = 94110
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`), `description` TEXT NOT NULL, -- `business_id` INTEGER NOT NULL, -- ); CREATE TABLE businesses ( `phone_number` INTEGER DEFAULT NULL, -- `postal_code` TEXT DEFAULT NULL, -- `owner_city` TEXT DEFAULT NULL, -- `owner_name` TEXT NOT NULL, -- `business_certificate` INTEGER NOT NULL, -- PRIMARY KEY (`business_id`), `owner_zip` TEXT DEFAULT NULL, -- `address` TEXT DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `owner_state` TEXT DEFAULT NULL, -- `tax_code` TEXT DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- `business_id` INTEGER NOT NULL, -- `name` TEXT NOT NULL, -- `city` TEXT DEFAULT NULL, -- `owner_address` TEXT DEFAULT NULL, -- `application_date` DATE DEFAULT NULL, -- ); CREATE TABLE inspections ( `type` TEXT NOT NULL, -- Example Values: `Routine - Unscheduled`, `Reinspection/Followup`, `Complaint Reinspection/Followup`, `Non-inspection site visit`, `Complaint` | Value Statics: Total count 23764 - Distinct count 13 - Null count 0 `score` INTEGER DEFAULT NULL, -- `business_id` INTEGER NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`), `date` DATE NOT NULL, -- );
hockey
What is the power play percentage of the team with the least number of penalty kill chances and to which team were they playing against? Indicate whether the team lost or victorious.
least number of penalty kill chances refers to min(PKC); power play percentage refers to (PP%) = divide(PPG, PPC); team playing refers to tmID; victorious team refers to tmIDWinner; team victorious refers to tmID = tmIDWinner and vice versa
SELECT SUM(T1.A), T2.firstName, T2.lastName FROM Scoring AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.lgID = 'NHL' GROUP BY T2.firstName, T2.lastName ORDER BY SUM(T1.A) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value Statics: Total count 45967 - Distinct count 5 - Null count 0 PostG TEXT, -- PostSHG TEXT, -- Example Values: `0`, `1`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 4 - Null count 31475 "+/-" TEXT, -- "Post+/-" TEXT, -- PostSHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 8855 - Distinct count 5 - Null count 37112 PPA TEXT, -- SOG TEXT, -- PostSOG TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, pos TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostPPG TEXT, -- Example Values: `0`, `1`, `5`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 10 - Null count 31475 SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 23214 - Distinct count 11 - Null count 22753 SHG TEXT, -- Example Values: `0`, `2`, `1`, `5`, `7` | Value Statics: Total count 37744 - Distinct count 14 - Null count 8223 Pts INTEGER, -- A INTEGER, -- PostPIM TEXT, -- G INTEGER, -- PostGWG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 15657 - Distinct count 8 - Null count 30310 PostPts TEXT, -- playerID TEXT, -- stint INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 45967 - Distinct count 4 - Null count 0 GWG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 36567 - Distinct count 16 - Null count 9400 PPG TEXT, -- PostPPA TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 8854 - Distinct count 17 - Null count 37113 year INTEGER, -- ); CREATE TABLE AwardsCoaches ( coachID TEXT, -- foreign key (coachID) references Coaches (coachID), year INTEGER, -- note TEXT, -- award TEXT, -- Example Values: `First Team All-Star`, `Second Team All-Star`, `Jack Adams`, `Baldwin`, `Schmertz` | Value Statics: Total count 77 - Distinct count 5 - Null count 0 lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 77 - Distinct count 2 - Null count 0 ); CREATE TABLE HOF ( category TEXT, -- Example Values: `Player`, `Builder`, `Referee/Linesman` | Value Statics: Total count 365 - Distinct count 3 - Null count 0 hofID TEXT not null primary key, year INTEGER, -- name TEXT, -- ); CREATE TABLE SeriesPost ( GoalsLoser INTEGER, -- note TEXT, -- Example Values: `EX`, `TG`, `ND`, `DEF` | Value Statics: Total count 59 - Distinct count 4 - Null count 773 lgIDLoser TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDWinner TEXT, -- series TEXT, -- Example Values: `A`, `B`, `C`, `D`, `E` | Value Statics: Total count 739 - Distinct count 15 - Null count 93 L INTEGER, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDLoser TEXT, -- foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade, year INTEGER, -- foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, T INTEGER, -- Example Values: `0`, `1`, `2` | Value Statics: Total count 832 - Distinct count 3 - Null count 0 lgIDWinner TEXT, -- Example Values: `PCHA`, `NHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 round TEXT, -- Example Values: `SCF`, `F`, `SF`, `SCSF`, `WP` | Value Statics: Total count 832 - Distinct count 13 - Null count 0 GoalsWinner INTEGER, -- W INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `0` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 ); CREATE TABLE abbrev ( Fullname TEXT, -- Code TEXT not null, -- primary key (Type, Code), Type TEXT not null, -- Example Values: `Conference`, `Division`, `Playoffs`, `Round` | Value Statics: Total count 58 - Distinct count 4 - Null count 0 ); CREATE TABLE AwardsMisc ( year INTEGER, -- lgID TEXT, -- Example Values: `NHL` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 note TEXT, -- Example Values: `posthumous` | Value Statics: Total count 15 - Distinct count 1 - Null count 109 name TEXT not null primary key, ID TEXT, -- award TEXT, -- Example Values: `Patrick` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 ); CREATE TABLE ScoringShootout ( year INTEGER, -- Example Values: `2006`, `2005`, `2007`, `2009`, `2008` | Value Statics: Total count 2072 - Distinct count 7 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, stint INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 2072 - Distinct count 3 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, G INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 2072 - Distinct count 16 - Null count 0 tmID TEXT, -- GDG INTEGER, -- Example Values: `0`, `1`, `2`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 8 - Null count 0 S INTEGER, -- Example Values: `1`, `2`, `5`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 19 - Null count 0 playerID TEXT, -- ); CREATE TABLE TeamSplits ( OctOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `5` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovL TEXT, -- Example Values: `1`, `4`, `3`, `2`, `0` | Value Statics: Total count 1358 - Distinct count 14 - Null count 161 FebOL TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovW TEXT, -- Example Values: `5`, `1`, `2`, `0`, `4` | Value Statics: Total count 1358 - Distinct count 13 - Null count 161 primary key (year, tmID), JanT INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 1305 - Distinct count 9 - Null count 214 SepW TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 JanL INTEGER, -- Example Values: `1`, `3`, `2`, `0`, `6` | Value Statics: Total count 1515 - Distinct count 15 - Null count 4 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 OctW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1199 - Distinct count 12 - Null count 320 AprW TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 FebT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1300 - Distinct count 8 - Null count 219 JanW INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 1515 - Distinct count 14 - Null count 4 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, rT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `6` | Value Statics: Total count 1309 - Distinct count 16 - Null count 210 tmID TEXT not null, -- DecW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 year INTEGER not null, -- OctL TEXT, -- Example Values: `1`, `0`, `2`, `4`, `5` | Value Statics: Total count 1199 - Distinct count 13 - Null count 320 SepT TEXT, -- AprOL TEXT, -- Example Values: `1`, `0`, `2`, `3` | Value Statics: Total count 358 - Distinct count 4 - Null count 1161 NovOL TEXT, -- Example Values: `0`, `2`, `1`, `4`, `3` | Value Statics: Total count 358 - Distinct count 5 - Null count 1161 FebW INTEGER, -- Example Values: `2`, `1`, `6`, `5`, `4` | Value Statics: Total count 1510 - Distinct count 14 - Null count 9 MarOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 7 - Null count 1161 hL INTEGER, -- MarL TEXT, -- Example Values: `4`, `0`, `2`, `1`, `3` | Value Statics: Total count 1485 - Distinct count 15 - Null count 34 hT INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1309 - Distinct count 14 - Null count 210 JanOL TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 rOTL TEXT, -- Example Values: `1`, `5`, `3`, `4`, `0` | Value Statics: Total count 358 - Distinct count 11 - Null count 1161 DecL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 MarT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1275 - Distinct count 8 - Null count 244 FebL INTEGER, -- Example Values: `3`, `5`, `0`, `1`, `2` | Value Statics: Total count 1510 - Distinct count 13 - Null count 9 MarW TEXT, -- Example Values: `1`, `3`, `0`, `2`, `5` | Value Statics: Total count 1485 - Distinct count 14 - Null count 34 AprT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 808 - Distinct count 6 - Null count 711 OctT TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 989 - Distinct count 7 - Null count 530 DecOL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 DecT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1263 - Distinct count 8 - Null count 256 NovT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1148 - Distinct count 9 - Null count 371 hW INTEGER, -- AprL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 SepOL TEXT, -- Example Values: `0` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 rW INTEGER, -- rL INTEGER, -- hOTL TEXT, -- Example Values: `2`, `3`, `1`, `0`, `4` | Value Statics: Total count 358 - Distinct count 12 - Null count 1161 SepL TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 ); CREATE TABLE Master ( lastNHL TEXT, -- deathMon TEXT, -- Example Values: `8`, `2`, `12`, `5`, `3` | Value Statics: Total count 1173 - Distinct count 12 - Null count 6588 birthCity TEXT, -- lastName TEXT not null, -- height TEXT, -- pos TEXT, -- Example Values: `C`, `D`, `G`, `L`, `R` | Value Statics: Total count 7447 - Distinct count 18 - Null count 314 nameGiven TEXT, -- playerID TEXT, -- deathDay TEXT, -- deathYear TEXT, -- hofID TEXT, -- deathCountry TEXT, -- Example Values: `USA`, `Canada`, `France`, `Belgium`, `Russia` | Value Statics: Total count 498 - Distinct count 14 - Null count 7263 deathState TEXT, -- firstNHL TEXT, -- birthCountry TEXT, -- birthDay TEXT, -- legendsID TEXT, -- hrefID TEXT, -- coachID TEXT, -- birthState TEXT, -- birthMon TEXT, -- Example Values: `3`, `8`, `2`, `5`, `12` | Value Statics: Total count 7506 - Distinct count 12 - Null count 255 deathCity TEXT, -- firstName TEXT, -- nameNick TEXT, -- firstWHA TEXT, -- Example Values: `1975`, `1976`, `1974`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 lastWHA TEXT, -- Example Values: `1975`, `1977`, `1976`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade, ihdbID TEXT, -- birthYear TEXT, -- weight TEXT, -- nameNote TEXT, -- Example Values: `also known as Bellehumeur`, `also listed as Bourdginon`, `born Bodnarchuk`, `also known as Bowcher`, `also known as Burmeister` | Value Statics: Total count 18 - Distinct count 18 - Null count 7743 shootCatch TEXT, -- Example Values: `L`, `R`, `B` | Value Statics: Total count 7048 - Distinct count 3 - Null count 713 ); CREATE TABLE TeamsPost ( year INTEGER not null, -- G INTEGER, -- PPG TEXT, -- L INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 12 - Null count 0 BenchMinor TEXT, -- Example Values: `0`, `6`, `2`, `4`, `10` | Value Statics: Total count 572 - Distinct count 8 - Null count 355 PKC TEXT, -- SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 604 - Distinct count 9 - Null count 323 tmID TEXT not null, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL`, `WHA` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 PPC TEXT, -- PIM TEXT, -- GA INTEGER, -- GF INTEGER, -- SHF TEXT, -- Example Values: `0`, `1`, `3`, `5`, `2` | Value Statics: Total count 636 - Distinct count 11 - Null count 291 T INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 17 - Null count 0 primary key (year, tmID), PKG TEXT, -- ); CREATE TABLE AwardsPlayers ( primary key (playerID, award, year), playerID TEXT not null, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, award TEXT not null, -- year INTEGER not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 2091 - Distinct count 2 - Null count 0 note TEXT, -- Example Values: `tie`, `shared`, `Most Gentlemanly`, `Rookie`, `Best Goaltender` | Value Statics: Total count 127 - Distinct count 8 - Null count 1964 pos TEXT, -- Example Values: `C`, `LW`, `F`, `RW`, `D` | Value Statics: Total count 1231 - Distinct count 7 - Null count 860 ); CREATE TABLE GoaliesShootout ( year INTEGER, -- Example Values: `2005`, `2006`, `2008`, `2009`, `2010` | Value Statics: Total count 480 - Distinct count 7 - Null count 0 stint INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 480 - Distinct count 2 - Null count 0 tmID TEXT, -- W INTEGER, -- Example Values: `2`, `0`, `1`, `7`, `6` | Value Statics: Total count 480 - Distinct count 11 - Null count 0 L INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `4` | Value Statics: Total count 480 - Distinct count 10 - Null count 0 playerID TEXT, -- GA INTEGER, -- SA INTEGER, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE Teams ( L INTEGER, -- name TEXT, -- W INTEGER, -- confID TEXT, -- Example Values: `CC`, `WA`, `WC`, `EC` | Value Statics: Total count 902 - Distinct count 4 - Null count 617 GA INTEGER, -- SoL TEXT, -- Example Values: `7`, `5`, `8`, `2`, `3` | Value Statics: Total count 210 - Distinct count 12 - Null count 1309 BenchMinor TEXT, -- playoff TEXT, -- lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 G INTEGER, -- GF INTEGER, -- OTL TEXT, -- Example Values: `3`, `4`, `6`, `5`, `0` | Value Statics: Total count 358 - Distinct count 18 - Null count 1161 tmID TEXT not null, -- franchID TEXT, -- primary key (year, tmID), PPC TEXT, -- SHF TEXT, -- T INTEGER, -- SoW TEXT, -- Example Values: `3`, `5`, `2`, `8`, `12` | Value Statics: Total count 210 - Distinct count 15 - Null count 1309 Pts INTEGER, -- PKG TEXT, -- PPG TEXT, -- PKC TEXT, -- divID TEXT, -- Example Values: `AM`, `CA`, `ED`, `WD`, `WW` | Value Statics: Total count 1171 - Distinct count 17 - Null count 348 PIM TEXT, -- rank INTEGER, -- Example Values: `4`, `5`, `7`, `6`, `1` | Value Statics: Total count 1519 - Distinct count 10 - Null count 0 SHA TEXT, -- year INTEGER not null, -- ); CREATE TABLE TeamVsTeam ( oppID TEXT not null, -- T INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 19962 - Distinct count 9 - Null count 5640 foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade, OTL TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 9874 - Distinct count 5 - Null count 15728 tmID TEXT not null, -- primary key (year, tmID, oppID), lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 25602 - Distinct count 5 - Null count 0 year INTEGER not null, -- L INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `0`, `3`, `4` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE ScoringSC ( foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `VML`, `CAT`, `VIC`, `TRS`, `MOC` | Value Statics: Total count 284 - Distinct count 17 - Null count 0 year INTEGER, -- Example Values: `1920`, `1921`, `1923`, `1924`, `1925` | Value Statics: Total count 284 - Distinct count 14 - Null count 0 playerID TEXT, -- G INTEGER, -- Example Values: `0`, `2`, `6`, `1`, `3` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, GP INTEGER, -- Example Values: `4`, `5`, `2`, `1`, `3` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 A INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 PIM INTEGER, -- pos TEXT, -- Example Values: `R`, `C`, `L`, `F`, `G` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `PCHA`, `WCHL`, `NHL`, `NHA` | Value Statics: Total count 284 - Distinct count 4 - Null count 0 Pts INTEGER, -- Example Values: `0`, `3`, `7`, `1`, `2` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 ); CREATE TABLE CombinedShutouts ( foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, month INTEGER, -- Example Values: `3`, `2`, `11`, `1`, `12` | Value Statics: Total count 54 - Distinct count 8 - Null count 0 oppID TEXT, -- foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade, "R/P" TEXT, -- Example Values: `R`, `P` | Value Statics: Total count 54 - Distinct count 2 - Null count 0 date INTEGER, -- tmID TEXT, -- IDgoalie1 TEXT, -- year INTEGER, -- IDgoalie2 TEXT, -- ); CREATE TABLE GoaliesSC ( GP INTEGER, -- Example Values: `3`, `5`, `6`, `4`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `OT1`, `OTS`, `MTM`, `TBS`, `SEA` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 playerID TEXT not null, -- Example Values: `benedcl01`, `clancki01`, `holmeha01`, `lehmahu01`, `lindsbe01` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, Min INTEGER, -- Example Values: `180`, `300`, `361`, `240`, `2` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 SHO INTEGER, -- Example Values: `0`, `1`, `3`, `2` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 W INTEGER, -- Example Values: `0`, `3`, `5`, `2`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 GA INTEGER, -- Example Values: `26`, `11`, `12`, `8`, `3` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 31 - Distinct count 2 - Null count 0 year INTEGER not null, -- Example Values: `1914`, `1919`, `1920`, `1922`, `1925` | Value Statics: Total count 31 - Distinct count 14 - Null count 0 primary key (playerID, year), L INTEGER, -- Example Values: `3`, `2`, `1`, `0` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 ); CREATE TABLE Goalies ( PostT TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 106 - Distinct count 5 - Null count 4172 SHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 4257 - Distinct count 17 - Null count 21 L TEXT, -- PostMin TEXT, -- PostW TEXT, -- Example Values: `0`, `6`, `1`, `2`, `3` | Value Statics: Total count 1439 - Distinct count 17 - Null count 2839 Min TEXT, -- PostGA TEXT, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 4278 - Distinct count 5 - Null count 0 ENG TEXT, -- Example Values: `0`, `1`, `3`, `4`, `5` | Value Statics: Total count 3533 - Distinct count 13 - Null count 745 GA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostSA TEXT, -- primary key (playerID, year, stint), playerID TEXT not null, -- "T/OL" TEXT, -- W TEXT, -- PostENG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 1187 - Distinct count 6 - Null count 3091 GP TEXT, -- PostSHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 8 - Null count 2839 SA TEXT, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 4278 - Distinct count 3 - Null count 0 PostGP TEXT, -- tmID TEXT, -- year INTEGER not null, -- PostL TEXT, -- Example Values: `0`, `1`, `5`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 12 - Null count 2839 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE TeamsHalf ( GA INTEGER, -- year INTEGER not null, -- Example Values: `1916`, `1917`, `1918`, `1919`, `1920` | Value Statics: Total count 41 - Distinct count 5 - Null count 0 primary key (year, tmID, half), tmID TEXT not null, -- Example Values: `MOC`, `MOW`, `OT1`, `QU1`, `TBS` | Value Statics: Total count 41 - Distinct count 13 - Null count 0 rank INTEGER, -- Example Values: `1`, `3`, `5`, `4`, `2` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 L INTEGER, -- Example Values: `3`, `7`, `8`, `2`, `5` | Value Statics: Total count 41 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 half INTEGER not null, -- Example Values: `1`, `2` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 GF INTEGER, -- T INTEGER, -- Example Values: `0` | Value Statics: Total count 41 - Distinct count 1 - Null count 0 foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade, G INTEGER, -- Example Values: `10`, `4`, `14`, `8`, `6` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 W INTEGER, -- Example Values: `7`, `3`, `2`, `8`, `5` | Value Statics: Total count 41 - Distinct count 10 - Null count 0 ); CREATE TABLE ScoringSup ( SHA TEXT, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 41 - Distinct count 4 - Null count 96 year INTEGER, -- Example Values: `1988`, `1989`, `1987`, `1990` | Value Statics: Total count 137 - Distinct count 4 - Null count 0 playerID TEXT, -- PPA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, ); CREATE TABLE Coaches ( coachID TEXT not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 1812 - Distinct count 5 - Null count 0 t INTEGER, -- l INTEGER, -- tmID TEXT not null, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 1812 - Distinct count 3 - Null count 0 postw TEXT, -- Example Values: `3`, `0`, `2`, `6`, `5` | Value Statics: Total count 927 - Distinct count 17 - Null count 885 w INTEGER, -- year INTEGER not null, -- notes TEXT, -- Example Values: `interim`, `co-coach with Barry Smith`, `co-coach with Dave Lewis` | Value Statics: Total count 11 - Distinct count 3 - Null count 1801 postg TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, g INTEGER, -- postl TEXT, -- Example Values: `4`, `5`, `6`, `7`, `2` | Value Statics: Total count 927 - Distinct count 12 - Null count 885 postt TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 927 - Distinct count 5 - Null count 885 primary key (coachID, year, tmID, stint), ); CREATE TABLE TeamsSC ( GF INTEGER, -- Example Values: `12`, `16`, `13`, `8`, `26` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 GA INTEGER, -- Example Values: `16`, `12`, `8`, `13`, `26` | Value Statics: Total count 30 - Distinct count 16 - Null count 0 G INTEGER, -- Example Values: `3`, `5`, `4`, `2`, `6` | Value Statics: Total count 30 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `5` | Value Statics: Total count 30 - Distinct count 6 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 30 - Distinct count 2 - Null count 0 L INTEGER, -- Example Values: `2`, `1`, `0`, `3` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT not null, -- Example Values: `QU1`, `VA1`, `TBS`, `OT1`, `VML` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 PIM TEXT, -- Example Values: `24`, `20`, `75`, `53`, `50` | Value Statics: Total count 8 - Distinct count 7 - Null count 22 year INTEGER not null, -- Example Values: `1912`, `1913`, `1914`, `1915`, `1916` | Value Statics: Total count 30 - Distinct count 14 - Null count 0 primary key (year, tmID), );
student_loan
What is the employment and payment status of student110?
employment status is mentioned in unemployment; unemployed.name = 'student110' means the student is unemployed; if 'student110' can not be found in unemployed.name, it means the student is employed; payment status is mentioned in no_payment_due; bool = 'pos' means the student has payment due; bool = 'neg' means the student has no payment due; student110 is a name of student;
SELECT T1.bool FROM no_payment_due AS T1 INNER JOIN unemployed AS T2 ON T1.name = T2.name WHERE T1.name = 'student110'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ); CREATE TABLE bool ( "name" TEXT default '' not null primary key, ); CREATE TABLE enlist ( "name" TEXT not null, -- foreign key ("name") references person ("name") on update cascade on delete cascade, organ TEXT not null, -- Example Values: `fire_department`, `air_force`, `navy`, `marines`, `foreign_legion` | Value Statics: Total count 306 - Distinct count 7 - Null count 0 ); CREATE TABLE unemployed ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE male ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE disabled ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE filed_for_bankrupcy ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE person ( "name" TEXT default '' not null primary key, ); CREATE TABLE no_payment_due ( bool TEXT null, -- Example Values: `neg`, `pos` | Value Statics: Total count 1000 - Distinct count 2 - Null count 0 "name" TEXT default '' not null primary key, foreign key (bool) references bool ("name") on update cascade on delete cascade, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE enrolled ( `name` TEXT NOT NULL, -- PRIMARY KEY (`name`,`school`), `month` INTEGER NOT NULL DEFAULT 0, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 1194 - Distinct count 15 - Null count 0 `school` TEXT NOT NULL, -- Example Values: `occ`, `smc`, `ucb`, `ucla`, `ucsd` | Value Statics: Total count 1194 - Distinct count 6 - Null count 0 FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, );
shooting
List all cases from the year 2012 in which the subject was deceased
case refers to case_number; year 2012 refers to date between '2012-01-01' and '2012-12-31'; subject was deceased refers to subject_statuses = 'Deceased'
SELECT case_number FROM incidents WHERE STRFTIME('%Y', date) > '2011' AND subject_statuses = 'Deceased'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
food_inspection
List the business' name and risk category of businesses with a score greater than the 80% of average score of all businesses.
score greater than the 80% of average score of all businesses refers to score > MULTIPLY(0.8, avg(score) from inspections);
SELECT DISTINCT T1.name, T3.risk_category FROM businesses AS T1 INNER JOIN inspections AS T2 ON T1.business_id = T2.business_id INNER JOIN violations AS T3 ON T1.business_id = T3.business_id WHERE T2.score > 0.8 * ( SELECT AVG(score) FROM inspections )
CREATE TABLE violations ( `risk_category` TEXT NOT NULL, -- Example Values: `Moderate Risk`, `Low Risk`, `High Risk` | Value Statics: Total count 36050 - Distinct count 3 - Null count 0 `date` DATE NOT NULL, -- `violation_type_id` TEXT NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`), `description` TEXT NOT NULL, -- `business_id` INTEGER NOT NULL, -- ); CREATE TABLE businesses ( `phone_number` INTEGER DEFAULT NULL, -- `postal_code` TEXT DEFAULT NULL, -- `owner_city` TEXT DEFAULT NULL, -- `owner_name` TEXT NOT NULL, -- `business_certificate` INTEGER NOT NULL, -- PRIMARY KEY (`business_id`), `owner_zip` TEXT DEFAULT NULL, -- `address` TEXT DEFAULT NULL, -- `longitude` REAL DEFAULT NULL, -- `owner_state` TEXT DEFAULT NULL, -- `tax_code` TEXT DEFAULT NULL, -- `latitude` REAL DEFAULT NULL, -- `business_id` INTEGER NOT NULL, -- `name` TEXT NOT NULL, -- `city` TEXT DEFAULT NULL, -- `owner_address` TEXT DEFAULT NULL, -- `application_date` DATE DEFAULT NULL, -- ); CREATE TABLE inspections ( `type` TEXT NOT NULL, -- Example Values: `Routine - Unscheduled`, `Reinspection/Followup`, `Complaint Reinspection/Followup`, `Non-inspection site visit`, `Complaint` | Value Statics: Total count 23764 - Distinct count 13 - Null count 0 `score` INTEGER DEFAULT NULL, -- `business_id` INTEGER NOT NULL, -- FOREIGN KEY (`business_id`) REFERENCES `businesses` (`business_id`), `date` DATE NOT NULL, -- );
hockey
What is the total amount of assists of the NHL player with the most assists in history? Please indicate his/her full name.
NHL refers to lgID = 'NHL'; most assists refers to max(A); full name = nameGiven + lastName; total amount of assists = sum(A(playerID(max(A))))
SELECT SUM(T1.A), T2.firstName, T2.lastName FROM Scoring AS T1 INNER JOIN Master AS T2 ON T1.playerID = T2.playerID WHERE T1.lgID = 'NHL' GROUP BY T2.firstName, T2.lastName ORDER BY SUM(T1.A) DESC LIMIT 1
CREATE TABLE Scoring ( tmID TEXT, -- PIM INTEGER, -- PostA TEXT, -- GTG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 28106 - Distinct count 8 - Null count 17861 PostGP TEXT, -- GP INTEGER, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `PCHA`, `WCHL`, `NHA` | Value Statics: Total count 45967 - Distinct count 5 - Null count 0 PostG TEXT, -- PostSHG TEXT, -- Example Values: `0`, `1`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 4 - Null count 31475 "+/-" TEXT, -- "Post+/-" TEXT, -- PostSHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 8855 - Distinct count 5 - Null count 37112 PPA TEXT, -- SOG TEXT, -- PostSOG TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, pos TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostPPG TEXT, -- Example Values: `0`, `1`, `5`, `2`, `3` | Value Statics: Total count 14492 - Distinct count 10 - Null count 31475 SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 23214 - Distinct count 11 - Null count 22753 SHG TEXT, -- Example Values: `0`, `2`, `1`, `5`, `7` | Value Statics: Total count 37744 - Distinct count 14 - Null count 8223 Pts INTEGER, -- A INTEGER, -- PostPIM TEXT, -- G INTEGER, -- PostGWG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 15657 - Distinct count 8 - Null count 30310 PostPts TEXT, -- playerID TEXT, -- stint INTEGER, -- Example Values: `1`, `2`, `3`, `4` | Value Statics: Total count 45967 - Distinct count 4 - Null count 0 GWG TEXT, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 36567 - Distinct count 16 - Null count 9400 PPG TEXT, -- PostPPA TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 8854 - Distinct count 17 - Null count 37113 year INTEGER, -- ); CREATE TABLE AwardsCoaches ( coachID TEXT, -- foreign key (coachID) references Coaches (coachID), year INTEGER, -- note TEXT, -- award TEXT, -- Example Values: `First Team All-Star`, `Second Team All-Star`, `Jack Adams`, `Baldwin`, `Schmertz` | Value Statics: Total count 77 - Distinct count 5 - Null count 0 lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 77 - Distinct count 2 - Null count 0 ); CREATE TABLE HOF ( category TEXT, -- Example Values: `Player`, `Builder`, `Referee/Linesman` | Value Statics: Total count 365 - Distinct count 3 - Null count 0 hofID TEXT not null primary key, year INTEGER, -- name TEXT, -- ); CREATE TABLE SeriesPost ( GoalsLoser INTEGER, -- note TEXT, -- Example Values: `EX`, `TG`, `ND`, `DEF` | Value Statics: Total count 59 - Distinct count 4 - Null count 773 lgIDLoser TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDWinner TEXT, -- series TEXT, -- Example Values: `A`, `B`, `C`, `D`, `E` | Value Statics: Total count 739 - Distinct count 15 - Null count 93 L INTEGER, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 tmIDLoser TEXT, -- foreign key (year, tmIDLoser) references Teams (year, tmID) on update cascade on delete cascade, year INTEGER, -- foreign key (year, tmIDWinner) references Teams (year, tmID) on update cascade on delete cascade, T INTEGER, -- Example Values: `0`, `1`, `2` | Value Statics: Total count 832 - Distinct count 3 - Null count 0 lgIDWinner TEXT, -- Example Values: `PCHA`, `NHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 round TEXT, -- Example Values: `SCF`, `F`, `SF`, `SCSF`, `WP` | Value Statics: Total count 832 - Distinct count 13 - Null count 0 GoalsWinner INTEGER, -- W INTEGER, -- Example Values: `2`, `1`, `3`, `4`, `0` | Value Statics: Total count 832 - Distinct count 5 - Null count 0 ); CREATE TABLE abbrev ( Fullname TEXT, -- Code TEXT not null, -- primary key (Type, Code), Type TEXT not null, -- Example Values: `Conference`, `Division`, `Playoffs`, `Round` | Value Statics: Total count 58 - Distinct count 4 - Null count 0 ); CREATE TABLE AwardsMisc ( year INTEGER, -- lgID TEXT, -- Example Values: `NHL` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 note TEXT, -- Example Values: `posthumous` | Value Statics: Total count 15 - Distinct count 1 - Null count 109 name TEXT not null primary key, ID TEXT, -- award TEXT, -- Example Values: `Patrick` | Value Statics: Total count 124 - Distinct count 1 - Null count 0 ); CREATE TABLE ScoringShootout ( year INTEGER, -- Example Values: `2006`, `2005`, `2007`, `2009`, `2008` | Value Statics: Total count 2072 - Distinct count 7 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, stint INTEGER, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 2072 - Distinct count 3 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, G INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `5` | Value Statics: Total count 2072 - Distinct count 16 - Null count 0 tmID TEXT, -- GDG INTEGER, -- Example Values: `0`, `1`, `2`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 8 - Null count 0 S INTEGER, -- Example Values: `1`, `2`, `5`, `6`, `3` | Value Statics: Total count 2072 - Distinct count 19 - Null count 0 playerID TEXT, -- ); CREATE TABLE TeamSplits ( OctOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `5` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovL TEXT, -- Example Values: `1`, `4`, `3`, `2`, `0` | Value Statics: Total count 1358 - Distinct count 14 - Null count 161 FebOL TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 NovW TEXT, -- Example Values: `5`, `1`, `2`, `0`, `4` | Value Statics: Total count 1358 - Distinct count 13 - Null count 161 primary key (year, tmID), JanT INTEGER, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 1305 - Distinct count 9 - Null count 214 SepW TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 JanL INTEGER, -- Example Values: `1`, `3`, `2`, `0`, `6` | Value Statics: Total count 1515 - Distinct count 15 - Null count 4 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 OctW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1199 - Distinct count 12 - Null count 320 AprW TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 FebT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1300 - Distinct count 8 - Null count 219 JanW INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 1515 - Distinct count 14 - Null count 4 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, rT INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `6` | Value Statics: Total count 1309 - Distinct count 16 - Null count 210 tmID TEXT not null, -- DecW TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 year INTEGER not null, -- OctL TEXT, -- Example Values: `1`, `0`, `2`, `4`, `5` | Value Statics: Total count 1199 - Distinct count 13 - Null count 320 SepT TEXT, -- AprOL TEXT, -- Example Values: `1`, `0`, `2`, `3` | Value Statics: Total count 358 - Distinct count 4 - Null count 1161 NovOL TEXT, -- Example Values: `0`, `2`, `1`, `4`, `3` | Value Statics: Total count 358 - Distinct count 5 - Null count 1161 FebW INTEGER, -- Example Values: `2`, `1`, `6`, `5`, `4` | Value Statics: Total count 1510 - Distinct count 14 - Null count 9 MarOL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 7 - Null count 1161 hL INTEGER, -- MarL TEXT, -- Example Values: `4`, `0`, `2`, `1`, `3` | Value Statics: Total count 1485 - Distinct count 15 - Null count 34 hT INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1309 - Distinct count 14 - Null count 210 JanOL TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 rOTL TEXT, -- Example Values: `1`, `5`, `3`, `4`, `0` | Value Statics: Total count 358 - Distinct count 11 - Null count 1161 DecL TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 1473 - Distinct count 14 - Null count 46 MarT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 1275 - Distinct count 8 - Null count 244 FebL INTEGER, -- Example Values: `3`, `5`, `0`, `1`, `2` | Value Statics: Total count 1510 - Distinct count 13 - Null count 9 MarW TEXT, -- Example Values: `1`, `3`, `0`, `2`, `5` | Value Statics: Total count 1485 - Distinct count 14 - Null count 34 AprT TEXT, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 808 - Distinct count 6 - Null count 711 OctT TEXT, -- Example Values: `0`, `1`, `4`, `2`, `3` | Value Statics: Total count 989 - Distinct count 7 - Null count 530 DecOL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 358 - Distinct count 6 - Null count 1161 DecT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1263 - Distinct count 8 - Null count 256 NovT TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1148 - Distinct count 9 - Null count 371 hW INTEGER, -- AprL TEXT, -- Example Values: `0`, `2`, `1`, `3`, `4` | Value Statics: Total count 1018 - Distinct count 11 - Null count 501 SepOL TEXT, -- Example Values: `0` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 rW INTEGER, -- rL INTEGER, -- hOTL TEXT, -- Example Values: `2`, `3`, `1`, `0`, `4` | Value Statics: Total count 358 - Distinct count 12 - Null count 1161 SepL TEXT, -- Example Values: `1` | Value Statics: Total count 2 - Distinct count 1 - Null count 1517 ); CREATE TABLE Master ( lastNHL TEXT, -- deathMon TEXT, -- Example Values: `8`, `2`, `12`, `5`, `3` | Value Statics: Total count 1173 - Distinct count 12 - Null count 6588 birthCity TEXT, -- lastName TEXT not null, -- height TEXT, -- pos TEXT, -- Example Values: `C`, `D`, `G`, `L`, `R` | Value Statics: Total count 7447 - Distinct count 18 - Null count 314 nameGiven TEXT, -- playerID TEXT, -- deathDay TEXT, -- deathYear TEXT, -- hofID TEXT, -- deathCountry TEXT, -- Example Values: `USA`, `Canada`, `France`, `Belgium`, `Russia` | Value Statics: Total count 498 - Distinct count 14 - Null count 7263 deathState TEXT, -- firstNHL TEXT, -- birthCountry TEXT, -- birthDay TEXT, -- legendsID TEXT, -- hrefID TEXT, -- coachID TEXT, -- birthState TEXT, -- birthMon TEXT, -- Example Values: `3`, `8`, `2`, `5`, `12` | Value Statics: Total count 7506 - Distinct count 12 - Null count 255 deathCity TEXT, -- firstName TEXT, -- nameNick TEXT, -- firstWHA TEXT, -- Example Values: `1975`, `1976`, `1974`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 lastWHA TEXT, -- Example Values: `1975`, `1977`, `1976`, `1973`, `1978` | Value Statics: Total count 903 - Distinct count 7 - Null count 6858 foreign key (coachID) references Coaches (coachID) on update cascade on delete cascade, ihdbID TEXT, -- birthYear TEXT, -- weight TEXT, -- nameNote TEXT, -- Example Values: `also known as Bellehumeur`, `also listed as Bourdginon`, `born Bodnarchuk`, `also known as Bowcher`, `also known as Burmeister` | Value Statics: Total count 18 - Distinct count 18 - Null count 7743 shootCatch TEXT, -- Example Values: `L`, `R`, `B` | Value Statics: Total count 7048 - Distinct count 3 - Null count 713 ); CREATE TABLE TeamsPost ( year INTEGER not null, -- G INTEGER, -- PPG TEXT, -- L INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 12 - Null count 0 BenchMinor TEXT, -- Example Values: `0`, `6`, `2`, `4`, `10` | Value Statics: Total count 572 - Distinct count 8 - Null count 355 PKC TEXT, -- SHA TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 604 - Distinct count 9 - Null count 323 tmID TEXT not null, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL`, `WHA` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 PPC TEXT, -- PIM TEXT, -- GA INTEGER, -- GF INTEGER, -- SHF TEXT, -- Example Values: `0`, `1`, `3`, `5`, `2` | Value Statics: Total count 636 - Distinct count 11 - Null count 291 T INTEGER, -- Example Values: `0`, `1`, `2`, `4`, `3` | Value Statics: Total count 927 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `0`, `4`, `2`, `3` | Value Statics: Total count 927 - Distinct count 17 - Null count 0 primary key (year, tmID), PKG TEXT, -- ); CREATE TABLE AwardsPlayers ( primary key (playerID, award, year), playerID TEXT not null, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, award TEXT not null, -- year INTEGER not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA` | Value Statics: Total count 2091 - Distinct count 2 - Null count 0 note TEXT, -- Example Values: `tie`, `shared`, `Most Gentlemanly`, `Rookie`, `Best Goaltender` | Value Statics: Total count 127 - Distinct count 8 - Null count 1964 pos TEXT, -- Example Values: `C`, `LW`, `F`, `RW`, `D` | Value Statics: Total count 1231 - Distinct count 7 - Null count 860 ); CREATE TABLE GoaliesShootout ( year INTEGER, -- Example Values: `2005`, `2006`, `2008`, `2009`, `2010` | Value Statics: Total count 480 - Distinct count 7 - Null count 0 stint INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 480 - Distinct count 2 - Null count 0 tmID TEXT, -- W INTEGER, -- Example Values: `2`, `0`, `1`, `7`, `6` | Value Statics: Total count 480 - Distinct count 11 - Null count 0 L INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `4` | Value Statics: Total count 480 - Distinct count 10 - Null count 0 playerID TEXT, -- GA INTEGER, -- SA INTEGER, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE Teams ( L INTEGER, -- name TEXT, -- W INTEGER, -- confID TEXT, -- Example Values: `CC`, `WA`, `WC`, `EC` | Value Statics: Total count 902 - Distinct count 4 - Null count 617 GA INTEGER, -- SoL TEXT, -- Example Values: `7`, `5`, `8`, `2`, `3` | Value Statics: Total count 210 - Distinct count 12 - Null count 1309 BenchMinor TEXT, -- playoff TEXT, -- lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 1519 - Distinct count 5 - Null count 0 G INTEGER, -- GF INTEGER, -- OTL TEXT, -- Example Values: `3`, `4`, `6`, `5`, `0` | Value Statics: Total count 358 - Distinct count 18 - Null count 1161 tmID TEXT not null, -- franchID TEXT, -- primary key (year, tmID), PPC TEXT, -- SHF TEXT, -- T INTEGER, -- SoW TEXT, -- Example Values: `3`, `5`, `2`, `8`, `12` | Value Statics: Total count 210 - Distinct count 15 - Null count 1309 Pts INTEGER, -- PKG TEXT, -- PPG TEXT, -- PKC TEXT, -- divID TEXT, -- Example Values: `AM`, `CA`, `ED`, `WD`, `WW` | Value Statics: Total count 1171 - Distinct count 17 - Null count 348 PIM TEXT, -- rank INTEGER, -- Example Values: `4`, `5`, `7`, `6`, `1` | Value Statics: Total count 1519 - Distinct count 10 - Null count 0 SHA TEXT, -- year INTEGER not null, -- ); CREATE TABLE TeamVsTeam ( oppID TEXT not null, -- T INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 19962 - Distinct count 9 - Null count 5640 foreign key (oppID, year) references Teams (tmID, year) on update cascade on delete cascade, OTL TEXT, -- Example Values: `0`, `1`, `3`, `2`, `4` | Value Statics: Total count 9874 - Distinct count 5 - Null count 15728 tmID TEXT not null, -- primary key (year, tmID, oppID), lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL`, `WHA` | Value Statics: Total count 25602 - Distinct count 5 - Null count 0 year INTEGER not null, -- L INTEGER, -- Example Values: `1`, `0`, `2`, `4`, `3` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `0`, `3`, `4` | Value Statics: Total count 25602 - Distinct count 14 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE ScoringSC ( foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `VML`, `CAT`, `VIC`, `TRS`, `MOC` | Value Statics: Total count 284 - Distinct count 17 - Null count 0 year INTEGER, -- Example Values: `1920`, `1921`, `1923`, `1924`, `1925` | Value Statics: Total count 284 - Distinct count 14 - Null count 0 playerID TEXT, -- G INTEGER, -- Example Values: `0`, `2`, `6`, `1`, `3` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, GP INTEGER, -- Example Values: `4`, `5`, `2`, `1`, `3` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 A INTEGER, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 284 - Distinct count 6 - Null count 0 PIM INTEGER, -- pos TEXT, -- Example Values: `R`, `C`, `L`, `F`, `G` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `PCHA`, `WCHL`, `NHL`, `NHA` | Value Statics: Total count 284 - Distinct count 4 - Null count 0 Pts INTEGER, -- Example Values: `0`, `3`, `7`, `1`, `2` | Value Statics: Total count 284 - Distinct count 11 - Null count 0 ); CREATE TABLE CombinedShutouts ( foreign key (IDgoalie1) references Master (playerID) on update cascade on delete cascade, month INTEGER, -- Example Values: `3`, `2`, `11`, `1`, `12` | Value Statics: Total count 54 - Distinct count 8 - Null count 0 oppID TEXT, -- foreign key (IDgoalie2) references Master (playerID) on update cascade on delete cascade, "R/P" TEXT, -- Example Values: `R`, `P` | Value Statics: Total count 54 - Distinct count 2 - Null count 0 date INTEGER, -- tmID TEXT, -- IDgoalie1 TEXT, -- year INTEGER, -- IDgoalie2 TEXT, -- ); CREATE TABLE GoaliesSC ( GP INTEGER, -- Example Values: `3`, `5`, `6`, `4`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT, -- Example Values: `OT1`, `OTS`, `MTM`, `TBS`, `SEA` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 playerID TEXT not null, -- Example Values: `benedcl01`, `clancki01`, `holmeha01`, `lehmahu01`, `lindsbe01` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL`, `PCHA`, `WCHL` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 foreign key (playerID) references Master (playerID) on update cascade on delete cascade, Min INTEGER, -- Example Values: `180`, `300`, `361`, `240`, `2` | Value Statics: Total count 31 - Distinct count 11 - Null count 0 SHO INTEGER, -- Example Values: `0`, `1`, `3`, `2` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 W INTEGER, -- Example Values: `0`, `3`, `5`, `2`, `1` | Value Statics: Total count 31 - Distinct count 6 - Null count 0 GA INTEGER, -- Example Values: `26`, `11`, `12`, `8`, `3` | Value Statics: Total count 31 - Distinct count 17 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 31 - Distinct count 2 - Null count 0 year INTEGER not null, -- Example Values: `1914`, `1919`, `1920`, `1922`, `1925` | Value Statics: Total count 31 - Distinct count 14 - Null count 0 primary key (playerID, year), L INTEGER, -- Example Values: `3`, `2`, `1`, `0` | Value Statics: Total count 31 - Distinct count 4 - Null count 0 ); CREATE TABLE Goalies ( PostT TEXT, -- Example Values: `1`, `0`, `2`, `3`, `4` | Value Statics: Total count 106 - Distinct count 5 - Null count 4172 SHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 4257 - Distinct count 17 - Null count 21 L TEXT, -- PostMin TEXT, -- PostW TEXT, -- Example Values: `0`, `6`, `1`, `2`, `3` | Value Statics: Total count 1439 - Distinct count 17 - Null count 2839 Min TEXT, -- PostGA TEXT, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 4278 - Distinct count 5 - Null count 0 ENG TEXT, -- Example Values: `0`, `1`, `3`, `4`, `5` | Value Statics: Total count 3533 - Distinct count 13 - Null count 745 GA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, PostSA TEXT, -- primary key (playerID, year, stint), playerID TEXT not null, -- "T/OL" TEXT, -- W TEXT, -- PostENG TEXT, -- Example Values: `0`, `1`, `2`, `3`, `5` | Value Statics: Total count 1187 - Distinct count 6 - Null count 3091 GP TEXT, -- PostSHO TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 8 - Null count 2839 SA TEXT, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 4278 - Distinct count 3 - Null count 0 PostGP TEXT, -- tmID TEXT, -- year INTEGER not null, -- PostL TEXT, -- Example Values: `0`, `1`, `5`, `3`, `4` | Value Statics: Total count 1439 - Distinct count 12 - Null count 2839 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, ); CREATE TABLE TeamsHalf ( GA INTEGER, -- year INTEGER not null, -- Example Values: `1916`, `1917`, `1918`, `1919`, `1920` | Value Statics: Total count 41 - Distinct count 5 - Null count 0 primary key (year, tmID, half), tmID TEXT not null, -- Example Values: `MOC`, `MOW`, `OT1`, `QU1`, `TBS` | Value Statics: Total count 41 - Distinct count 13 - Null count 0 rank INTEGER, -- Example Values: `1`, `3`, `5`, `4`, `2` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 L INTEGER, -- Example Values: `3`, `7`, `8`, `2`, `5` | Value Statics: Total count 41 - Distinct count 11 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `NHL` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 half INTEGER not null, -- Example Values: `1`, `2` | Value Statics: Total count 41 - Distinct count 2 - Null count 0 GF INTEGER, -- T INTEGER, -- Example Values: `0` | Value Statics: Total count 41 - Distinct count 1 - Null count 0 foreign key (tmID, year) references Teams (tmID, year) on update cascade on delete cascade, G INTEGER, -- Example Values: `10`, `4`, `14`, `8`, `6` | Value Statics: Total count 41 - Distinct count 6 - Null count 0 W INTEGER, -- Example Values: `7`, `3`, `2`, `8`, `5` | Value Statics: Total count 41 - Distinct count 10 - Null count 0 ); CREATE TABLE ScoringSup ( SHA TEXT, -- Example Values: `1`, `2`, `4`, `3` | Value Statics: Total count 41 - Distinct count 4 - Null count 96 year INTEGER, -- Example Values: `1988`, `1989`, `1987`, `1990` | Value Statics: Total count 137 - Distinct count 4 - Null count 0 playerID TEXT, -- PPA TEXT, -- foreign key (playerID) references Master (playerID) on update cascade on delete cascade, ); CREATE TABLE Coaches ( coachID TEXT not null, -- lgID TEXT, -- Example Values: `NHL`, `WHA`, `NHA`, `WCHL`, `PCHA` | Value Statics: Total count 1812 - Distinct count 5 - Null count 0 t INTEGER, -- l INTEGER, -- tmID TEXT not null, -- stint INTEGER not null, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 1812 - Distinct count 3 - Null count 0 postw TEXT, -- Example Values: `3`, `0`, `2`, `6`, `5` | Value Statics: Total count 927 - Distinct count 17 - Null count 885 w INTEGER, -- year INTEGER not null, -- notes TEXT, -- Example Values: `interim`, `co-coach with Barry Smith`, `co-coach with Dave Lewis` | Value Statics: Total count 11 - Distinct count 3 - Null count 1801 postg TEXT, -- foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, g INTEGER, -- postl TEXT, -- Example Values: `4`, `5`, `6`, `7`, `2` | Value Statics: Total count 927 - Distinct count 12 - Null count 885 postt TEXT, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 927 - Distinct count 5 - Null count 885 primary key (coachID, year, tmID, stint), ); CREATE TABLE TeamsSC ( GF INTEGER, -- Example Values: `12`, `16`, `13`, `8`, `26` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 GA INTEGER, -- Example Values: `16`, `12`, `8`, `13`, `26` | Value Statics: Total count 30 - Distinct count 16 - Null count 0 G INTEGER, -- Example Values: `3`, `5`, `4`, `2`, `6` | Value Statics: Total count 30 - Distinct count 5 - Null count 0 W INTEGER, -- Example Values: `1`, `2`, `3`, `0`, `5` | Value Statics: Total count 30 - Distinct count 6 - Null count 0 T INTEGER, -- Example Values: `0`, `1` | Value Statics: Total count 30 - Distinct count 2 - Null count 0 L INTEGER, -- Example Values: `2`, `1`, `0`, `3` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 foreign key (year, tmID) references Teams (year, tmID) on update cascade on delete cascade, tmID TEXT not null, -- Example Values: `QU1`, `VA1`, `TBS`, `OT1`, `VML` | Value Statics: Total count 30 - Distinct count 17 - Null count 0 lgID TEXT, -- Example Values: `NHA`, `PCHA`, `NHL`, `WCHL` | Value Statics: Total count 30 - Distinct count 4 - Null count 0 PIM TEXT, -- Example Values: `24`, `20`, `75`, `53`, `50` | Value Statics: Total count 8 - Distinct count 7 - Null count 22 year INTEGER not null, -- Example Values: `1912`, `1913`, `1914`, `1915`, `1916` | Value Statics: Total count 30 - Distinct count 14 - Null count 0 primary key (year, tmID), );
student_loan
What is the school and gender of student34?
male.name = 'student34' means student34's gender is male; if 'student34' can't be found in 'male.name', it means student34 is female; student34 is a name of student;
SELECT T1.school , IIF(T3.name IS NULL, 'female', 'male') AS gender FROM enrolled AS T1 INNER JOIN person AS T2 ON T1.name = T2.name LEFT JOIN male AS T3 ON T2.name = T3.name WHERE T2.name = 'student34'
CREATE TABLE longest_absense_from_school ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, "month" INTEGER default 0 null, -- Example Values: `0`, `1`, `2`, `3`, `4` | Value Statics: Total count 1000 - Distinct count 10 - Null count 0 ); CREATE TABLE bool ( "name" TEXT default '' not null primary key, ); CREATE TABLE enlist ( "name" TEXT not null, -- foreign key ("name") references person ("name") on update cascade on delete cascade, organ TEXT not null, -- Example Values: `fire_department`, `air_force`, `navy`, `marines`, `foreign_legion` | Value Statics: Total count 306 - Distinct count 7 - Null count 0 ); CREATE TABLE unemployed ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE male ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE disabled ( foreign key ("name") references person ("name") on update cascade on delete cascade, "name" TEXT default '' not null primary key, ); CREATE TABLE filed_for_bankrupcy ( "name" TEXT default '' not null primary key, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE person ( "name" TEXT default '' not null primary key, ); CREATE TABLE no_payment_due ( bool TEXT null, -- Example Values: `neg`, `pos` | Value Statics: Total count 1000 - Distinct count 2 - Null count 0 "name" TEXT default '' not null primary key, foreign key (bool) references bool ("name") on update cascade on delete cascade, foreign key ("name") references person ("name") on update cascade on delete cascade, ); CREATE TABLE enrolled ( `name` TEXT NOT NULL, -- PRIMARY KEY (`name`,`school`), `month` INTEGER NOT NULL DEFAULT 0, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 1194 - Distinct count 15 - Null count 0 `school` TEXT NOT NULL, -- Example Values: `occ`, `smc`, `ucb`, `ucla`, `ucsd` | Value Statics: Total count 1194 - Distinct count 6 - Null count 0 FOREIGN KEY (`name`) REFERENCES `person` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, );
shooting
How many incidents in which the subject's weapon was a vehicle were investigated by a female officer?
subject's weapon was a vehicle refers to subject_weapon = 'Vehicle'; female refers to gender = 'F'
SELECT COUNT(T1.case_number) FROM incidents AS T1 INNER JOIN officers AS T2 ON T1.case_number = T2.case_number WHERE T1.subject_weapon = 'Vehicle' AND T2.gender = 'F'
CREATE TABLE officers ( full_name TEXT not null, -- foreign key (case_number) references incidents (case_number), case_number TEXT not null, -- last_name TEXT not null, -- first_name TEXT null, -- race TEXT null, -- Example Values: `L`, `W`, `B`, `A` | Value Statics: Total count 366 - Distinct count 4 - Null count 4 gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 370 - Distinct count 2 - Null count 0 ); CREATE TABLE incidents ( date DATE not null, -- case_number TEXT not null primary key, subjects TEXT not null, -- subject_weapon TEXT not null, -- subject_statuses TEXT not null, -- Example Values: `Deceased`, `Shoot and Miss`, `Injured`, `Other`, `Deceased Injured` | Value Statics: Total count 219 - Distinct count 7 - Null count 0 subject_count INTEGER not null, -- Example Values: `1`, `2`, `0`, `3` | Value Statics: Total count 219 - Distinct count 4 - Null count 0 officers TEXT not null, -- location TEXT not null, -- ); CREATE TABLE subjects ( case_number TEXT not null, -- last_name TEXT not null, -- foreign key (case_number) references incidents (case_number), full_name TEXT not null, -- gender TEXT not null, -- Example Values: `M`, `F` | Value Statics: Total count 223 - Distinct count 2 - Null count 0 first_name TEXT null, -- race TEXT not null, -- Example Values: `L`, `B`, `W`, `A` | Value Statics: Total count 223 - Distinct count 4 - Null count 0 ); CREATE TABLE cases ( case_number TEXT not null primary key, grand_jury_disposition TEXT, -- );
books
List the author's name of the books published by Abrams.
"Abrams" is the publisher_name; author's name refers to author_name
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id INNER JOIN publisher AS T4 ON T4.publisher_id = T1.publisher_id WHERE T4.publisher_name = 'Abrams'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Find and list the full name of customers who bought products above-average quantity.
full name of the customer = FirstName, MiddleInitial, LastName; above-average quantity = Quantity > AVG(Quantity);
SELECT T2.FirstName, T2.MiddleInitial, T2.LastName FROM Sales AS T1 INNER JOIN Customers AS T2 ON T1.CustomerID = T2.CustomerID GROUP BY T1.Quantity HAVING T1.Quantity > ( SELECT AVG(Quantity) FROM Sales )
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
List the title of the books purchased by the customer named Zia Roizin.
null
SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T4.first_name = 'Zia' AND T4.last_name = 'Roizin'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
books
List the email of customers that bought the book titled Switch on the Night.
"Switch on the Night" is the title
SELECT T4.email FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id INNER JOIN cust_order AS T3 ON T3.order_id = T2.order_id INNER JOIN customer AS T4 ON T4.customer_id = T3.customer_id WHERE T1.title = 'Switch on the Night'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
List the first name of all the customers whose last name is Chen.
null
SELECT FirstName, LastName FROM Customers WHERE LastName = 'Chen'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
sales
What is the average price of products that cost between 100 and 200?
average price = DIVIDE(SUM(Price, COUNT(Price))); cost refers to Price; Price BETWEEN 100 AND 200;
SELECT AVG(Price) FROM Products WHERE Price BETWEEN 100 AND 200
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
In books authored by Abraham Lincoln, what is the percentage of the books published in 1992?
"Abraham Lincoln" is the author_name; published in 1992 refers to publication_date LIKE '1992%'; percentage = Divide (Sum(publication_date LIKE '1992%'), Count(publication_date)) * 100
SELECT CAST(SUM(CASE WHEN STRFTIME('%Y', T1.publication_date) = '1992' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Abraham Lincoln'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Of the employees who sold Blade, who has the most amount of sales?
Blade' is name of product; most amount of sales refers to MAX(MULTIPLY(Quantity, Price));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID ORDER BY T2.Quantity * T3.Price DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
Who authored the book with greatest number of pages?
greatest number of pages refers to Max(num_pages); who authored refers to author_name
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id ORDER BY T1.num_pages DESC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Among the employee names, what is the most common middle initial?
most common middle initial refers to MAX(COUNT(MiddleInitial));
SELECT MiddleInitial FROM Employees GROUP BY MiddleInitial ORDER BY COUNT(MiddleInitial) DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
Provide the contact email of Moss Zarb.
null
SELECT email FROM customer WHERE first_name = 'Moss' AND last_name = 'Zarb'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Give the full name of the customer who bought the most amount of products.
full name of the customer = FirstName, MiddleInitial, LastName; most amount of products refers to MAX(MULTIPLY(Quantity, Price));
SELECT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID ORDER BY T2.Quantity * T1.Price DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
What is the publisher name of the book titled The Illuminati?
"The Illuminati" is the title of book
SELECT T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T1.title = 'The Illuminati'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
How many chainring bolts were sold under sales ID 551971?
Chainring Bolts' is name of product;
SELECT T1.Quantity FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T2.Name = 'Chainring Bolts' AND T1.SalesID = 551971
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
Count the number of books written by Orson Scott Card.
"Orson Scott Card" is the author_name
SELECT COUNT(*) FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Name the product that sold the most quantity.
most quantity refers to MAX(Quantity);
SELECT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID ORDER BY T1.Quantity DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
sales
What are the full names of the top 3 employees who handled the highest number of sales?
full names of employees = FirstName, MiddleInitital, LastName; highest number of sales refers to MAX(COUNT(SalesID));
SELECT T1.FirstName, T1.MiddleInitial, T1.LastName FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID GROUP BY T2.SalesPersonID, T1.FirstName, T1.MiddleInitial, T1.LastName ORDER BY COUNT(T2.SalesID) DESC LIMIT 3
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
Among the books published in 2004, list the name of the publisher of books with number of pages greater than 70% of the average number of pages of all books.
published in 2004 refers to publication_date LIKE '2004%'; books with number of pages greater than 70% of the average number of pages refers to num_pages > Multiply(Avg(num_pages), 0.7); name of publisher refers to publisher_name
SELECT T1.title, T2.publisher_name FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE STRFTIME('%Y', T1.publication_date) = '2004' AND T1.num_pages * 100 > ( SELECT AVG(num_pages) FROM book ) * 70
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
How many dishes do not have correct data for the year in which it appeared first?
do not have correct data refers to first_appeared < 1851 or first_appeared > 2012;
SELECT COUNT(*) FROM Dish WHERE first_appeared < 1851 OR first_appeared > 2012
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
books
Which books were released by Orson Scott Card in 2001?
"Orson Scott Card" is the author_name; released in 2001 refers to publication_date LIKE '2001%'; books refers to title
SELECT T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T3.author_name = 'Orson Scott Card' AND STRFTIME('%Y', T1.publication_date) = '2001'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
List the full name of customers who spend more than 50,000 in descending order the amount spend.
full name of the customer = FirstName, MiddleInitial, LastName; more than 50,000 in the amount refers to MULTIPLY(Quantity, Price) > 50000;
SELECT DISTINCT T3.FirstName, T3.MiddleInitial, T3.LastName FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T2.Quantity * T1.Price > 50000
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
books
List the ISBN of the book published in Spanish.
"Spanish" is the language_name; ISBN refers to isbn13
SELECT T1.isbn13 FROM book AS T1 INNER JOIN book_language AS T2 ON T1.language_id = T2.language_id WHERE T2.language_name = 'Spanish'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
Among all the dishes that were once free, what is the name of the dish that had appeared on most menus?
dishes that were once free refers to lowest_price = 0; appeared on most menus refers to MAX(menus_appeared);
SELECT name FROM Dish WHERE lowest_price = 0 ORDER BY menus_appeared DESC LIMIT 1
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Show the name of the university with the lowest number of students in 2015.
lowest number of students refers to MIN(num_students); in 2015 refers to year = 2015; name of university refers to university_name;
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 ORDER BY T1.num_students ASC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
Who wrote "The Prophet"?
"The Prophet" is the title of the book: who wrote refers to author_name
SELECT T3.author_name FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.title = 'The Prophet'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
sales
Find and list the products that sold below the average quantity.
below the average quantity refers to Quantity < AVG(Quantity);
SELECT DISTINCT T2.Name FROM Sales AS T1 INNER JOIN Products AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Quantity < ( SELECT AVG(Quantity) FROM Sales )
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Calculate the number of international students of University of Wisconsin-Madison in 2013.
international students refers to DIVIDE(MULTIPLY(num_students, pct_international_students), 100); University of Wisconsin-Madison refers to university_name = 'University of Wisconsin-Madison'; in 2013 refers to year = 2013
SELECT CAST(T1.num_students * T1.pct_international_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2013 AND T2.university_name = 'University of Wisconsin-Madison'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Which dish lasted longer, Anchovies or Fresh lobsters in every style?
if (SUBTRACT(last_appeared, first_appeared) WHERE name = 'Anchovies') > (SUBTRACT(last_appeared, first_appeared) WHERE name = 'Fresh lobsters in every style'), it means 'Anchovies' lasted longer; if (SUBTRACT(last_appeared , first_appeared) WHERE name = 'Fresh lobsters in every style') > (SUBTRACT(last_appeared , first_appeared) WHERE name = 'Anchovies') it means 'Fresh lobsters in every style' last longer;
SELECT CASE WHEN SUM(CASE WHEN name = 'Anchovies' THEN last_appeared - first_appeared ELSE 0 END) - SUM(CASE WHEN name = 'Fresh lobsters in every style' THEN last_appeared - first_appeared ELSE 0 END) > 0 THEN 'Anchovies' ELSE 'Fresh lobsters in every style' END FROM Dish WHERE name IN ('Fresh lobsters in every style', 'Anchovies')
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What was the score for University of Florida in "N and S" in 2014?
University of Florida refers to university_name = 'University of Florida'; in 2014 refers to year = 2014; in "N and S" refers to criteria_name = 'N and S'
SELECT T2.score FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'University of Florida' AND T2.year = 2014 AND T1.criteria_name = 'N and S'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
Name the streets in Dallas.
"Dallas" is the city; streets refers to street_name
SELECT street_name FROM address WHERE city = 'Dallas'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
What is the name of the dish that appeared on the upper left corner on menu page no. 1389?
appeared on the upper left corner on menu refers to xpos < 0.25 AND ypos < 0.25; menu page no. refers to menu_page_id; menu_page_id = 1389;
SELECT T1.name FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T2.menu_page_id = 1389 AND T2.xpos < 0.25 AND T2.ypos < 0.25
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
How many female students were there in Pierre and Marie Curie University in 2015?
female students refers to DIVIDE(MULTIPLY(pct_female_students, num_students), 100); in Pierre and Marie Curie University refers to university_name = 'Pierre and Marie Curie University'; in 2015 refers to year = 2015
SELECT CAST(T1.num_students * T1.pct_female_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2015 AND T2.university_name = 'Pierre and Marie Curie University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Which ranking system is criteria "Total Shanghai" in?
criteria "Total Shanghai" refers to criteria_name = 'Total Shanghai'; which ranking system refers to system_name
SELECT T1.system_name FROM ranking_system AS T1 INNER JOIN ranking_criteria AS T2 ON T1.id = T2.ranking_system_id WHERE T2.criteria_name = 'Total Shanghai'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many "Mountain-100 Silver, 38" were sold by Stearns MacFeather?
Mountain-100 Silver, 38' is name of product;
SELECT SUM(T2.Quantity) FROM Employees AS T1 INNER JOIN Sales AS T2 ON T1.EmployeeID = T2.SalesPersonID INNER JOIN Products AS T3 ON T2.ProductID = T3.ProductID WHERE T1.FirstName = 'Stearns' AND T1.LastName = 'MacFeather' AND T3.Name = 'Mountain-100 Silver, 38'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
For the University of Southampton in 2015, on which criteria did it score the best?
University of Southampton refers to university_name = 'University of Southampton'; in 2015 refers to year = 2015; score the best refers to MAX(score); which criteria refers to criteria_name
SELECT T1.criteria_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'University of Southampton' AND T2.year = 2015 ORDER BY T2.score DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Among all the menu pages with the appearance of the dish "Clear green turtle", how many of them have the dish at a stable price?
Clear green turtle is a name of dish; stable price refers to highest_price is null;
SELECT SUM(CASE WHEN T1.name = 'Clear green turtle' THEN 1 ELSE 0 END) FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.highest_price IS NULL
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What is the percentage of the international students in University of Oslo in 2015?
percentage of the international students refers to pct_international_students; in 2015 refers to year = 2015; in University of Oslo refers to university_name = 'University of Oslo';
SELECT T2.pct_international_students FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id WHERE T1.university_name = 'University of Oslo' AND T2.year = 2015
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
Provide the authors and titles of the books which have more than 3000 pages.
authors refers to author_name; more than 3000 pages refers to num_pages > 3000
SELECT T3.author_name, T1.title FROM book AS T1 INNER JOIN book_author AS T2 ON T1.book_id = T2.book_id INNER JOIN author AS T3 ON T3.author_id = T2.author_id WHERE T1.num_pages > 3000
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
How many menus with the name "Waldorf Astoria" have 4 pages?
4 pages refers to page_count = 4;
SELECT COUNT(*) FROM Menu WHERE name = 'Waldorf Astoria' AND page_count = 4
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
For Chosun University, what was its score on "Influence Rank" in 2015?
Chosun University refers to university_name = 'Chosun University'; in 2015 refers to year = 2015; on "Influence Rank" refers to criteria_name = 'Influence Rank';
SELECT T2.score FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'Chosun University' AND T1.criteria_name = 'Influence Rank' AND T2.year = 2015
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Please list the prices of the dish "Clear green turtle" on every menu page it appeared on.
Clear green turtle is a name of dish;
SELECT T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.name = 'Clear green turtle'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
How many students were there in University of Michigan in 2011?
in 2011 refers to year 2011; in University of Michigan refers to university_name = 'University of Michigan';
SELECT COUNT(*) FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id WHERE T1.university_name = 'University of Michigan' AND T2.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
How many books were published by Ace Hardcover?
"Ace Hardcover" is the publisher_name
SELECT COUNT(*) FROM book AS T1 INNER JOIN publisher AS T2 ON T1.publisher_id = T2.publisher_id WHERE T2.publisher_name = 'Ace Hardcover'
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
Please list the IDs of all the menus in which the dish "Clear green turtle" had appeared.
Clear green turtle is a name of dish;
SELECT T1.menu_id FROM MenuPage AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.menu_page_id INNER JOIN Dish AS T3 ON T2.dish_id = T3.id WHERE T3.name = 'Clear green turtle'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Which university had the most students in 2011? Show its name.
in 2011 refers to year 2011; the most students refers to MAX(num_students); which university refers to university_name;
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 ORDER BY T1.num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many type of products did Dalton M. Coleman purchase?
null
SELECT COUNT(T2.ProductID) FROM Customers AS T1 INNER JOIN Sales AS T2 ON T1.CustomerID = T2.CustomerID WHERE T1.FirstName = 'Dalton' AND T1.MiddleInitial = 'M' AND T1.LastName = 'Coleman'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
How many Turkish universities are there in the database?
Turkish universities refers to country_name = 'Turkey';
SELECT COUNT(*) FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Turkey'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Which country is McMaster University located in?
McMaster University refers to university_name = 'McMaster University'; which country refers to country_name
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'McMaster University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
What is the title of the most expensive book?
most expensive book refers to Max(price)
SELECT T1.title FROM book AS T1 INNER JOIN order_line AS T2 ON T1.book_id = T2.book_id ORDER BY T2.price DESC LIMIT 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
Among the menus in which the dish "Clear green turtle" had appeared, how many of them did not support taking out or booking in advance?
Clear green turtle is a name of dish; not support taking out or booking in advance refers to call_number is null;
SELECT SUM(CASE WHEN T4.name = 'Clear green turtle' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.call_number IS NULL
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Show the name of country id 66.
name of country refers to country_name
SELECT country_name FROM country WHERE id = 66
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
What is the highest price of the dish "Clear green turtle" on a menu page?
highest price refers to MAX(Price); Clear green turtle is a name of dish;
SELECT T2.price FROM Dish AS T1 INNER JOIN MenuItem AS T2 ON T1.id = T2.dish_id WHERE T1.name = 'Clear green turtle' ORDER BY T2.price DESC LIMIT 1
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
For the university id 268, show its number of students in 2013.
number of students refers to num_students; in 2013 refers to year = 2013
SELECT num_students FROM university_year WHERE university_id = 268 AND year = 2013
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Show the id of University of Orléans.
University of Orléans refers to university_name = 'University of Orléans';
SELECT id FROM university WHERE university_name = 'University of Orléans'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
What is the id of the criteria "Citations Rank"?
criteria "Citations Rank" refers to criteria_name = 'Citations Rank';
SELECT id FROM ranking_criteria WHERE criteria_name = 'Citations Rank'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Among the menus in which the dish "Clear green turtle" had appeared, how many of them used the dollar as their currency?
Clear green turtle is a name of dish; dollar as currency refers to currency = 'Dollars';
SELECT SUM(CASE WHEN T3.currency = 'Dollars' THEN 1 ELSE 0 END) FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T4.name = 'Clear green turtle'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Which country is University of Veterinary Medicine Vienna located in? Give its country id.
University of Veterinary Medicine Vienna refers to university_name = 'University of Veterinary Medicine Vienna';
SELECT country_id FROM university WHERE university_name = 'University of Veterinary Medicine Vienna'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Give the id of "Center for World University Rankings".
"Center for World University Rankings" refers to system_name = 'Center for World University Rankings';
SELECT id FROM ranking_system WHERE system_name = 'Center for World University Rankings'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Among the "Mountain-500 Black" product types, which type was purchased the most?
Mountain-500 Black product types refers to Name like 'Mountain-500 Black%'; purchased the most refers to MAX(SUM(Quantity));
SELECT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name LIKE 'Mountain-500 Black%' GROUP BY T2.Quantity, T1.Name ORDER BY SUM(T2.Quantity) DESC LIMIT 1
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Among the universities with a score in teaching of over 90 in 2011, what is the percentage of those in the United States of America?
in 2011 refers to year 2011; in teaching refers to  criteria_name = 'Teaching'; score in teaching of over 90 refers to score > 90; in the United States of America refers to country_name = 'United States of America'; percentage refers to DIVIDE(COUNT(country_name = 'United States of America'), COUNT(id))
SELECT CAST(SUM(CASE WHEN T4.country_name = 'United States of America' THEN 1 ELSE 0 END) AS REAL) * 100 / COUNT(*) AS per FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id INNER JOIN country AS T4 ON T4.id = T3.country_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 AND T2.score > 90
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many female students did Stanford University have in 2011?
in 2011 refers to year 2011; female students refers to DIVIDE(MULTIPLY(pct_female_students, num_students), 100); Stanford University refers to university_name = 'Stanford University';
SELECT CAST(T1.num_students * T1.pct_female_students AS REAL) / 100 FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 AND T2.university_name = 'Stanford University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
Give the product's name brought by Aaron Alexander.
null
SELECT DISTINCT T1.Name FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Aaron' AND T3.LastName = 'Alexander'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Among the universities in Australia, how many of them have a student staff ratio of over 15 in 2011?
in 2011 refers to year 2011; in Australia refers to country_name = 'Australia'; student staff ratio of over 15 refers to student_staff_ratio > 15
SELECT COUNT(*) FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'Australia' AND T2.student_staff_ratio > 15 AND T2.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Please list the names of all the universities that scored under 60 in teaching in 2011 and are in the United States of America.
scored under 60 refers to score < 60; in 2011 refers to year 2011; in teaching refers to criteria_name = 'Teaching'; in the United States of America refers to country_name = 'United States of America';
SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id INNER JOIN country AS T4 ON T4.id = T3.country_id WHERE T4.country_name = 'United States of America' AND T2.year = 2011 AND T2.score < 60 AND T1.criteria_name = 'Teaching'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Which dish has the highest price on the menu "Zentral Theater Terrace"? Please give its name.
highest price refers to MAX(Price); Zentral Theater Terrace is a name of menu;
SELECT T4.name FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.name = 'Zentral Theater Terrace' ORDER BY T1.price DESC LIMIT 1
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What are the names of the universities that got 98 in teaching in 2011?
in 2011 refers to year 2011; that got 98 refers to score = 98; in teaching refers to criteria_name = 'Teaching'; name of university refers to university_name
SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 AND T2.score = 98
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
How many employees sold "ML Road Frame-W - Yellow, 40"?
ML Road Frame-W - Yellow, 40' is name of product;
SELECT COUNT(T2.SalesPersonID) FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID WHERE T1.Name = 'ML Road Frame-W - Yellow, 40'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Please list the names of all the ranking criteria of Harvard University in 2011.
in 2011 refers to year 2011; Harvard University refers to university_name = 'Harvard University'; names of all the ranking criteria refers to criteria_name
SELECT T1.criteria_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T3.university_name = 'Harvard University' AND T2.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
books
Among the books that cost less than 1 dollar, how many were published by Berkley Trade?
book cost less than 1 dollar refers to price < 1; 'Berkley Trade' is the publisher_name;
SELECT COUNT(*) FROM publisher AS T1 INNER JOIN book AS T2 ON T1.publisher_id = T2.publisher_id INNER JOIN order_line AS T3 ON T3.book_id = T2.book_id WHERE T1.publisher_name = 'Berkley' AND T3.price < 1
CREATE TABLE order_line ( book_id INTEGER references book, -- price REAL, -- line_id INTEGER primary key autoincrement, order_id INTEGER references cust_order, -- ); CREATE TABLE customer ( customer_id INTEGER primary key, first_name TEXT, -- last_name TEXT, -- email TEXT, -- ); CREATE TABLE book_author ( author_id INTEGER, -- foreign key (book_id) references book(book_id), primary key (book_id, author_id), book_id INTEGER, -- foreign key (author_id) references author(author_id), ); CREATE TABLE address ( city TEXT, -- street_number TEXT, -- address_id INTEGER primary key, foreign key (country_id) references country(country_id), country_id INTEGER, -- street_name TEXT, -- ); CREATE TABLE cust_order ( shipping_method_id INTEGER references shipping_method, -- Example Values: `4`, `2`, `1`, `3` | Value Statics: Total count 7550 - Distinct count 4 - Null count 0 dest_address_id INTEGER references address, -- customer_id INTEGER references customer, -- order_date DATETIME, -- order_id INTEGER primary key autoincrement, ); CREATE TABLE author ( author_id INTEGER primary key, author_name TEXT, -- ); CREATE TABLE customer_address ( customer_id INTEGER, -- address_id INTEGER, -- status_id INTEGER, -- Example Values: `1`, `2` | Value Statics: Total count 3350 - Distinct count 2 - Null count 0 foreign key (address_id) references address(address_id), foreign key (customer_id) references customer(customer_id), primary key (customer_id, address_id), ); CREATE TABLE publisher ( publisher_name TEXT, -- publisher_id INTEGER primary key, ); CREATE TABLE order_status ( status_value TEXT, -- Example Values: `Order Received`, `Pending Delivery`, `Delivery In Progress`, `Delivered`, `Cancelled` | Value Statics: Total count 6 - Distinct count 6 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE book_language ( language_id INTEGER primary key, language_name TEXT, -- language_code TEXT, -- ); CREATE TABLE book ( title TEXT, -- num_pages INTEGER, -- publisher_id INTEGER, -- isbn13 TEXT, -- publication_date DATE, -- foreign key (publisher_id) references publisher(publisher_id), language_id INTEGER, -- book_id INTEGER primary key, foreign key (language_id) references book_language(language_id), foreign key (language_id) references book_language(language_id), ); CREATE TABLE address_status ( address_status TEXT, -- Example Values: `Active`, `Inactive` | Value Statics: Total count 2 - Distinct count 2 - Null count 0 status_id INTEGER primary key, ); CREATE TABLE shipping_method ( method_name TEXT, -- Example Values: `Standard`, `Priority`, `Express`, `International` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 cost REAL, -- Example Values: `5.9`, `8.9`, `11.9`, `24.5` | Value Statics: Total count 4 - Distinct count 4 - Null count 0 method_id INTEGER primary key, ); CREATE TABLE country ( country_id INTEGER primary key, country_name TEXT, -- ); CREATE TABLE order_history ( order_id INTEGER references cust_order, -- status_id INTEGER references order_status, -- Example Values: `1`, `2`, `3`, `4`, `5` | Value Statics: Total count 22348 - Distinct count 6 - Null count 0 status_date DATETIME, -- history_id INTEGER primary key autoincrement, );
menu
Please list the names of all the dishes that appeared on the menu "Zentral Theater Terrace".
Zentral Theater Terrace is a name of menu;
SELECT T4.name FROM MenuItem AS T1 INNER JOIN MenuPage AS T2 ON T1.menu_page_id = T2.id INNER JOIN Menu AS T3 ON T2.menu_id = T3.id INNER JOIN Dish AS T4 ON T1.dish_id = T4.id WHERE T3.name = 'Zentral Theater Terrace'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Among the universities with a score in teaching of over 90 in 2011, how many of them are in the United States of America?
in 2011 refers to year 2011; in teaching refers to  criteria_name = 'Teaching'; score in teaching of over 90 refers to score > 90; in the United States of America refers to country_name = 'United States of America';
SELECT COUNT(*) FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 AND T2.score > 90
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
sales
List the quantity and price of the product bought by Abigail Henderson.
null
SELECT T2.Quantity, T1.Price FROM Products AS T1 INNER JOIN Sales AS T2 ON T1.ProductID = T2.ProductID INNER JOIN Customers AS T3 ON T2.CustomerID = T3.CustomerID WHERE T3.FirstName = 'Abigail' AND T3.LastName = 'Henderson'
CREATE TABLE Sales ( CustomerID INTEGER not null, -- SalesID INTEGER not null primary key, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, foreign key (SalesPersonID) references Employees (EmployeeID) on update cascade on delete cascade, SalesPersonID INTEGER not null, -- foreign key (CustomerID) references Customers (CustomerID) on update cascade on delete cascade, Quantity INTEGER not null, -- ProductID INTEGER not null, -- foreign key (ProductID) references Products (ProductID) on update cascade on delete cascade, ); CREATE TABLE Customers ( MiddleInitial TEXT null, -- FirstName TEXT not null, -- LastName TEXT not null, -- CustomerID INTEGER not null primary key, ); CREATE TABLE Products ( Price REAL null, -- ProductID INTEGER not null primary key, Name TEXT not null, -- ); CREATE TABLE Employees ( EmployeeID INTEGER not null primary key, LastName TEXT not null, -- FirstName TEXT not null, -- MiddleInitial TEXT null, -- Example Values: `e`, `l`, `a`, `u`, `r` | Value Statics: Total count 22 - Distinct count 11 - Null count 0 );
university
Please list the names of the universities with a score in teaching of over 90 in 2011.
in 2011 refers to year 2011; in teaching refers to  criteria_name = 'Teaching'; score in teaching of over 90 refers to score > 90; name of university refers to university_name;
SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 AND T2.score > 90
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
What is the name of the university with the highest score in teaching in the year 2011?
with the highest score refers to MAX(score); in teaching refers to criteria_name = 'Teaching'; name of university refers to university_name;
SELECT T3.university_name FROM ranking_criteria AS T1 INNER JOIN university_ranking_year AS T2 ON T1.id = T2.ranking_criteria_id INNER JOIN university AS T3 ON T3.id = T2.university_id WHERE T1.criteria_name = 'Teaching' AND T2.year = 2011 ORDER BY T2.score DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Please describe the menu sponsored by Noviomagus physically.
describe the menu physically refers to physical_description; sponsored by Noviomagus refers to sponsor = 'Noviomagus';
SELECT physical_description FROM Menu WHERE sponsor = 'Noviomagus'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
Which country is Harvard University in?
Harvard University refers to university_name = 'Harvard University'; which country refers to country_name
SELECT T2.country_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T1.university_name = 'Harvard University'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Among the universities in Australia, how many of them have more than 15000 students in 2011?
in 2011 refers to year 2011; have more than 15000 students refers to num_students > 15000; in Australia refers to country_name = 'Australia';
SELECT COUNT(*) FROM university AS T1 INNER JOIN university_year AS T2 ON T1.id = T2.university_id INNER JOIN country AS T3 ON T3.id = T1.country_id WHERE T3.country_name = 'Australia' AND T2.year = 2011 AND T2.num_students > 15000
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
Please list the names of all the universities in Australia.
in Australia refers to country_name = 'Australia'; name of university refers to university_name
SELECT T1.university_name FROM university AS T1 INNER JOIN country AS T2 ON T1.country_id = T2.id WHERE T2.country_name = 'Australia'
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
List down the locations of menu sponsored by Norddeutscher Lloyd Bremen.
sponsored by Norddeutscher Lloyd Bremen refers to sponsor = 'Norddeutscher Lloyd Bremen';
SELECT location FROM Menu WHERE sponsor = 'Norddeutscher Lloyd Bremen'
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
What is the name of the university with the most international students in 2011?
in 2011 refers to year 2011; the most international students refers to MAX(DIVIDE(MULTIPLY(num_students,  pct_international_students), 100)); name of university refers to university_id
SELECT T2.university_name FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T1.year = 2011 ORDER BY T1.pct_international_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
university
How many students did Harvard University have in 2011?
in 2011 refers to year 2011; Harvard University refers to university_name = 'Harvard University';
SELECT T1.num_students FROM university_year AS T1 INNER JOIN university AS T2 ON T1.university_id = T2.id WHERE T2.university_name = 'Harvard University' AND T1.year = 2011
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );
menu
Where is the place that menu with ID 12472 was created for?
place refers to location;
SELECT location FROM Menu WHERE id = 12472
CREATE TABLE Dish ( menus_appeared INTEGER, -- highest_price REAL, -- description TEXT, -- Example Values: `` | Value Statics: Total count 7 - Distinct count 1 - Null count 99993 last_appeared INTEGER, -- name TEXT, -- id INTEGER primary key, first_appeared INTEGER, -- lowest_price REAL, -- times_appeared INTEGER, -- ); CREATE TABLE MenuPage ( menu_id INTEGER, -- uuid TEXT, -- foreign key (menu_id) references Menu(id), id INTEGER primary key, full_width INTEGER, -- image_id REAL, -- page_number INTEGER, -- full_height INTEGER, -- ); CREATE TABLE Menu ( language TEXT, -- currency TEXT, -- venue TEXT, -- keywords TEXT, -- currency_symbol TEXT, -- physical_description TEXT, -- page_count INTEGER, -- location TEXT, -- dish_count INTEGER, -- name TEXT, -- occasion TEXT, -- id INTEGER primary key, notes TEXT, -- sponsor TEXT, -- place TEXT, -- call_number TEXT, -- location_type TEXT, -- status TEXT, -- Example Values: `complete` | Value Statics: Total count 17527 - Distinct count 1 - Null count 0 date DATE, -- event TEXT, -- ); CREATE TABLE MenuItem ( foreign key (dish_id) references Dish(id), updated_at TEXT, -- id INTEGER primary key, ypos REAL, -- xpos REAL, -- price REAL, -- high_price REAL, -- dish_id INTEGER, -- menu_page_id INTEGER, -- created_at TEXT, -- foreign key (menu_page_id) references MenuPage(id), foreign key (menu_page_id) references MenuPage(id), );
university
In which year did university ID 1 have the most students?
have the most students refers to MAX(num_students)
SELECT year FROM university_year WHERE university_id = 1 ORDER BY num_students DESC LIMIT 1
CREATE TABLE ranking_system ( id INTEGER not null primary key, system_name TEXT default NULL, -- Example Values: `Times Higher Education World University Ranking`, `Shanghai Ranking`, `Center for World University Rankings` | Value Statics: Total count 3 - Distinct count 3 - Null count 0 ); CREATE TABLE country ( country_name TEXT default NULL, -- id INTEGER not null primary key, ); CREATE TABLE university ( university_name TEXT default NULL, -- id INTEGER not null primary key, country_id INTEGER default NULL, -- foreign key (country_id) references country(id), ); CREATE TABLE university_year ( pct_international_students INTEGER default NULL, -- pct_female_students INTEGER default NULL, -- student_staff_ratio REAL default NULL, -- foreign key (university_id) references university(id), num_students INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 1085 - Distinct count 6 - Null count 0 university_id INTEGER default NULL, -- ); CREATE TABLE ranking_criteria ( id INTEGER not null primary key, ranking_system_id INTEGER default NULL, -- Example Values: `1`, `2`, `3` | Value Statics: Total count 21 - Distinct count 3 - Null count 0 criteria_name TEXT default NULL, -- foreign key (ranking_system_id) references ranking_system(id), ); CREATE TABLE university_ranking_year ( ranking_criteria_id INTEGER default NULL, -- year INTEGER default NULL, -- Example Values: `2011`, `2012`, `2013`, `2014`, `2015` | Value Statics: Total count 29612 - Distinct count 12 - Null count 0 foreign key (ranking_criteria_id) references ranking_criteria(id), foreign key (university_id) references university(id), score INTEGER default NULL, -- university_id INTEGER default NULL, -- );