Datasets:

Modalities:
Text
Formats:
parquet
Size:
< 1K
Libraries:
Datasets
pandas
db_id
stringclasses
19 values
schema
stringclasses
19 values
schemaComEx
stringclasses
19 values
question_en
stringlengths
29
142
query
stringlengths
27
344
answer
stringlengths
17
111k
hardness
stringclasses
4 values
schema_llm
stringclasses
19 values
query_llm
stringlengths
27
403
selector
stringlengths
25
156
schema_reduzido
stringlengths
64
392
schema_reduzido_only_tables
stringlengths
129
994
course_teach
CREATE TABLE course ( "Course_ID" INTEGER, "Staring_Date" TEXT, "Course" TEXT, PRIMARY KEY ("Course_ID") ) CREATE TABLE course_arrange ( "Course_ID" INTEGER, "Teacher_ID" INTEGER, "Grade" INTEGER, PRIMARY KEY ("Course_ID", "Teacher_ID", "Grade"), FOREIGN KEY("Teacher_ID") REFERENCES teacher ("Teacher_ID"), FOREIGN KEY("Course_ID") REFERENCES course ("Course_ID") ) CREATE TABLE teacher ( "Teacher_ID" INTEGER, "Name" TEXT, "Age" TEXT, "Hometown" TEXT, PRIMARY KEY ("Teacher_ID") )
CREATE TABLE course ( "Course_ID" INTEGER, "Staring_Date" TEXT, "Course" TEXT, PRIMARY KEY ("Course_ID") ) /* 2 rows from course table: Course_ID Staring_Date Course 1 5 May Language Arts 2 6 May Math */ CREATE TABLE course_arrange ( "Course_ID" INTEGER, "Teacher_ID" INTEGER, "Grade" INTEGER, PRIMARY KEY ("Course_ID", "Teacher_ID", "Grade"), FOREIGN KEY("Teacher_ID") REFERENCES teacher ("Teacher_ID"), FOREIGN KEY("Course_ID") REFERENCES course ("Course_ID") ) /* 2 rows from course_arrange table: Course_ID Teacher_ID Grade 2 5 1 2 3 3 */ CREATE TABLE teacher ( "Teacher_ID" INTEGER, "Name" TEXT, "Age" TEXT, "Hometown" TEXT, PRIMARY KEY ("Teacher_ID") ) /* 2 rows from teacher table: Teacher_ID Name Age Hometown 1 Joseph Huts 32 Blackrod Urban District 2 Gustaaf Deloor 29 Bolton County Borough */
What are the towns from which at least two teachers come from?
SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2
[{'Nenhum': 'Nenhum resultado encontrado'}]
easy
Table course ( course.Course_ID (INT), course.Staring_Date (TEXT), course.Course (TEXT), ) Table course_arrange ( course_arrange.Course_ID (INT), course_arrange.Teacher_ID (INT), course_arrange.Grade (INT), ) Table teacher ( teacher.Teacher_ID (INT), teacher.Name (TEXT), teacher.Age (TEXT), teacher.Hometown (TEXT), ) Possible JOINs: course_arrange.Course_ID = course.Course_ID course_arrange.Teacher_ID = teacher.Teacher_ID
SELECT Hometown FROM teacher GROUP BY Hometown HAVING COUNT(*) >= 2
{ 'teacher': ['teacher_id', 'hometown'] }
Table teacher ( teacher.Teacher_ID (INT), teacher.Hometown (TEXT), ) Possible JOINs:
Table teacher ( teacher.Teacher_ID (INT), teacher.Name (TEXT), teacher.Age (TEXT), teacher.Hometown (TEXT), ) Possible JOINs:
world_1
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") )
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from city table: ID Name CountryCode District Population 1 Kabul AFG Kabol 1780000 2 Qandahar AFG Qandahar 237500 */ CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) /* 2 rows from country table: Code Name Continent Region SurfaceArea IndepYear Population LifeExpectancy GNP GNPOld LocalName GovernmentForm HeadOfState Capital Code2 ABW Aruba North America Caribbean 193.0000000000 None 103000 78.4000000000 828.0000000000 793.0000000000 Aruba Nonmetropolitan Territory of The Netherlands Beatrix 129 AW AFG Afghanistan Asia Southern and Central Asia 652090.0000000000 1919 22720000 45.9000000000 5976.0000000000 None Afganistan/Afqanestan Islamic Emirate Mohammad Omar 1 AF */ CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from countrylanguage table: CountryCode Language IsOfficial Percentage ABW Dutch T 5.3000000000 ABW English F 9.5000000000 */
What are the population, name and leader of the country with the largest area?
SELECT Name , population , HeadOfState FROM country ORDER BY SurfaceArea DESC LIMIT 1
[{'Name': 'Russian Federation', 'Population': 146934000, 'HeadOfState': 'Vladimir Putin'}]
medium
Table city ( city.ID (INTEGER), city.Name (char(35)), city.CountryCode (char(3)), city.District (char(20)), city.Population (INTEGER), ) Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Table countrylanguage ( countrylanguage.CountryCode (char(3)), countrylanguage.Language (char(30)), countrylanguage.IsOfficial (TEXT), countrylanguage.Percentage (float(4,1)), ) Possible JOINs: city.CountryCode = country.Code countrylanguage.CountryCode = country.Code
SELECT Name , population , HeadOfState FROM country ORDER BY SurfaceArea DESC LIMIT 1
{ 'country': ['code', 'name', 'surfacearea', 'population', 'headofstate'] }
Table country ( country.Code (char(3)), country.Name (char(52)), country.SurfaceArea (float(10,2)), country.Population (INTEGER), country.HeadOfState (char(60)), ) Possible JOINs:
Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Possible JOINs:
world_1
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") )
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from city table: ID Name CountryCode District Population 1 Kabul AFG Kabol 1780000 2 Qandahar AFG Qandahar 237500 */ CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) /* 2 rows from country table: Code Name Continent Region SurfaceArea IndepYear Population LifeExpectancy GNP GNPOld LocalName GovernmentForm HeadOfState Capital Code2 ABW Aruba North America Caribbean 193.0000000000 None 103000 78.4000000000 828.0000000000 793.0000000000 Aruba Nonmetropolitan Territory of The Netherlands Beatrix 129 AW AFG Afghanistan Asia Southern and Central Asia 652090.0000000000 1919 22720000 45.9000000000 5976.0000000000 None Afganistan/Afqanestan Islamic Emirate Mohammad Omar 1 AF */ CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from countrylanguage table: CountryCode Language IsOfficial Percentage ABW Dutch T 5.3000000000 ABW English F 9.5000000000 */
Return the names of the 3 most populated countries.
SELECT Name FROM country ORDER BY Population DESC LIMIT 3
[{'Name': 'China'}, {'Name': 'India'}, {'Name': 'United States'}]
medium
Table city ( city.ID (INTEGER), city.Name (char(35)), city.CountryCode (char(3)), city.District (char(20)), city.Population (INTEGER), ) Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Table countrylanguage ( countrylanguage.CountryCode (char(3)), countrylanguage.Language (char(30)), countrylanguage.IsOfficial (TEXT), countrylanguage.Percentage (float(4,1)), ) Possible JOINs: city.CountryCode = country.Code countrylanguage.CountryCode = country.Code
SELECT Name FROM country ORDER BY Population DESC LIMIT 3
{ 'country': ['code', 'name', 'population'] }
Table country ( country.Code (char(3)), country.Name (char(52)), country.Population (INTEGER), ) Possible JOINs:
Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Possible JOINs:
dog_kennels
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) )
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) /* 2 rows from Breeds table: breed_code breed_name ESK Eskimo HUS Husky */ CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) /* 2 rows from Charges table: charge_id charge_type charge_amount 1 Daily Accommodation 98.0000 2 Drugs 322.0000 */ CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) /* 2 rows from Dogs table: dog_id owner_id abandoned_yn breed_code size_code name age date_of_birth gender weight date_arrived date_adopted date_departed 1 3 1 ESK LGE Kacey 6 2012-01-27 05:11:53 1 7.57 2017-09-08 20:10:13 2018-03-06 16:32:11 2018-03-25 06:58:44 2 11 0 BUL LGE Hipolito 9 2013-02-13 05:15:21 0 1.72 2017-12-22 05:02:02 2018-03-25 08:12:51 2018-03-25 02:11:32 */ CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) /* 2 rows from Owners table: owner_id first_name last_name street city state zip_code email_address home_phone cell_number 1 Nora Haley 0647 Hintz Village Apt. 024 Lake Tia Wisconsin 93165 [email protected] 1-682-845-0116x63235 478.978.0729 2 Melisa DuBuque 1204 Mae Highway Apt. 107 Port Reannamouth Virginia 45244 [email protected] (799)563-0260x454 (722)768-5439x484 */ CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) /* 2 rows from Professionals table: professional_id role_code first_name street city state zip_code last_name email_address home_phone cell_number 1 Employee Taryn 6915 Oberbrunner Point Suite 491 Gleasonville, LA West Heidi Indiana 06646 Braun [email protected] +71(6)2898266914 (275)939-2435x80863 2 Employee Jayson 88665 Terence Lodge Apt. 904 Corneliusfort, NC 194 North Odellfurt Connecticut 43129 Ullrich [email protected] +02(1)0259033559 889-940-2676 */ CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) /* 2 rows from Sizes table: size_code size_description SML Small MED Medium */ CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) /* 2 rows from Treatment_Types table: treatment_type_code treatment_type_description EXAM Physical examination VAC Vaccination */ CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) ) /* 2 rows from Treatments table: treatment_id dog_id professional_id treatment_type_code date_of_treatment cost_of_treatment 1 14 9 WALK 2018-03-19 04:39:54 567.0000 2 4 10 VAC 2018-03-15 20:25:34 147.0000 */
What are the id, role, and first name of the professionals who have performed two or more treatments?
SELECT T1.professional_id , T1.role_code , T1.first_name FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id GROUP BY T1.professional_id HAVING count(*) >= 2
[{'professional_id': 4, 'role_code': 'Veterenarian', 'first_name': 'Vernice'}, {'professional_id': 6, 'role_code': 'Veterenarian', 'first_name': 'Ruben'}, {'professional_id': 8, 'role_code': 'Employee', 'first_name': 'Karley'}, {'professional_id': 9, 'role_code': 'Veterenarian', 'first_name': 'Monte'}, {'professional_id': 10, 'role_code': 'Employee', 'first_name': 'Domenica'}, {'professional_id': 14, 'role_code': 'Employee', 'first_name': 'Sigurd'}]
medium
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Charges ( Charges.charge_id (INTEGER), Charges.charge_type (VARCHAR(10)), Charges.charge_amount (DECIMAL(19,4)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Table Owners ( Owners.owner_id (INTEGER), Owners.first_name (VARCHAR(50)), Owners.last_name (VARCHAR(50)), Owners.street (VARCHAR(50)), Owners.city (VARCHAR(50)), Owners.state (VARCHAR(20)), Owners.zip_code (VARCHAR(20)), Owners.email_address (VARCHAR(50)), Owners.home_phone (VARCHAR(20)), Owners.cell_number (VARCHAR(20)), ) Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Sizes ( Sizes.size_code (VARCHAR(10)), Sizes.size_description (VARCHAR(80)), ) Table Treatment_Types ( Treatment_Types.treatment_type_code (VARCHAR(10)), Treatment_Types.treatment_type_description (VARCHAR(80)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
SELECT Professionals.professional_id , Professionals.role_code , Professionals.first_name FROM Professionals JOIN Treatments ON Professionals.professional_id = Treatments.professional_id GROUP BY Professionals.professional_id HAVING count(*) >= 2
{ 'professionals': ['professional_id', 'role_code', 'first_name'], 'treatments': ['treatment_id', 'professional_id'] }
Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.professional_id (INTEGER), ) Possible JOINs: Treatments.professional_id = Professionals.professional_id
Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
tvshow
CREATE TABLE "Cartoon" ( id REAL, "Title" TEXT, "Directed_by" TEXT, "Written_by" TEXT, "Original_air_date" TEXT, "Production_code" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) CREATE TABLE "TV_Channel" ( id TEXT, series_name TEXT, "Country" TEXT, "Language" TEXT, "Content" TEXT, "Pixel_aspect_ratio_PAR" TEXT, "Hight_definition_TV" TEXT, "Pay_per_view_PPV" TEXT, "Package_Option" TEXT, PRIMARY KEY (id) ) CREATE TABLE "TV_series" ( id REAL, "Episode" TEXT, "Air_Date" TEXT, "Rating" TEXT, "Share" REAL, "18_49_Rating_Share" TEXT, "Viewers_m" TEXT, "Weekly_Rank" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) )
CREATE TABLE "Cartoon" ( id REAL, "Title" TEXT, "Directed_by" TEXT, "Written_by" TEXT, "Original_air_date" TEXT, "Production_code" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) /* 2 rows from Cartoon table: id Title Directed_by Written_by Original_air_date Production_code Channel 1.0 The Rise of the Blue Beetle! Ben Jones Michael Jelenic November14,2008 101.0 700 2.0 Terror on Dinosaur Island! Brandon Vietti Steven Melching November21,2008 102.0 701 */ CREATE TABLE "TV_Channel" ( id TEXT, series_name TEXT, "Country" TEXT, "Language" TEXT, "Content" TEXT, "Pixel_aspect_ratio_PAR" TEXT, "Hight_definition_TV" TEXT, "Pay_per_view_PPV" TEXT, "Package_Option" TEXT, PRIMARY KEY (id) ) /* 2 rows from TV_Channel table: id series_name Country Language Content Pixel_aspect_ratio_PAR Hight_definition_TV Pay_per_view_PPV Package_Option 700 Sky Radio Italy Italian music 4:3 no no Sky Famiglia 701 Sky Music Italy Italian music 4:3 no no Sky Famiglia */ CREATE TABLE "TV_series" ( id REAL, "Episode" TEXT, "Air_Date" TEXT, "Rating" TEXT, "Share" REAL, "18_49_Rating_Share" TEXT, "Viewers_m" TEXT, "Weekly_Rank" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) /* 2 rows from TV_series table: id Episode Air_Date Rating Share 18_49_Rating_Share Viewers_m Weekly_Rank Channel 1.0 A Love of a Lifetime September 24, 2007 5.8 9.0 3.5/9 9.16 43.0 700 2.0 Friendly Skies October 1, 2007 5.3 9.0 3.2/8 8.23 50.0 701 */
What are the countries that have cartoons on TV that were written by Todd Casey?
SELECT T1.country FROM TV_Channel AS T1 JOIN cartoon AS T2 ON T1.id = T2.Channel WHERE T2.written_by = 'Todd Casey'
[{'Country': 'United Kingdom'}, {'Country': 'Italy'}]
medium
Table Cartoon ( Cartoon.id (REAL), Cartoon.Title (TEXT), Cartoon.Directed_by (TEXT), Cartoon.Written_by (TEXT), Cartoon.Original_air_date (TEXT), Cartoon.Production_code (REAL), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.series_name (TEXT), TV_Channel.Country (TEXT), TV_Channel.Language (TEXT), TV_Channel.Content (TEXT), TV_Channel.Pixel_aspect_ratio_PAR (TEXT), TV_Channel.Hight_definition_TV (TEXT), TV_Channel.Pay_per_view_PPV (TEXT), TV_Channel.Package_Option (TEXT), ) Table TV_series ( TV_series.id (REAL), TV_series.Episode (TEXT), TV_series.Air_Date (TEXT), TV_series.Rating (TEXT), TV_series.Share (REAL), TV_series.18_49_Rating_Share (TEXT), TV_series.Viewers_m (TEXT), TV_series.Weekly_Rank (REAL), TV_series.Channel (TEXT), ) Possible JOINs: Cartoon.Channel = TV_Channel.id TV_series.Channel = TV_Channel.id
SELECT TV_Channel.country FROM TV_Channel JOIN cartoon ON TV_Channel.id = cartoon.Channel WHERE cartoon.written_by = 'Todd Casey'
{ 'tv_channel': ['id', 'country'], 'cartoon': ['id', 'written_by', 'channel'] }
Table Cartoon ( Cartoon.id (REAL), Cartoon.Written_by (TEXT), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.Country (TEXT), )
Table Cartoon ( Cartoon.id (REAL), Cartoon.Title (TEXT), Cartoon.Directed_by (TEXT), Cartoon.Written_by (TEXT), Cartoon.Original_air_date (TEXT), Cartoon.Production_code (REAL), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.series_name (TEXT), TV_Channel.Country (TEXT), TV_Channel.Language (TEXT), TV_Channel.Content (TEXT), TV_Channel.Pixel_aspect_ratio_PAR (TEXT), TV_Channel.Hight_definition_TV (TEXT), TV_Channel.Pay_per_view_PPV (TEXT), TV_Channel.Package_Option (TEXT), ) Possible JOINs: Cartoon.Channel = TV_Channel.id
cre_Doc_Template_Mgt
CREATE TABLE "Documents" ( "Document_ID" INTEGER NOT NULL, "Template_ID" INTEGER, "Document_Name" VARCHAR(255), "Document_Description" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Document_ID"), FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID") ) CREATE TABLE "Paragraphs" ( "Paragraph_ID" INTEGER NOT NULL, "Document_ID" INTEGER NOT NULL, "Paragraph_Text" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Paragraph_ID"), FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID") ) CREATE TABLE "Ref_Template_Types" ( "Template_Type_Code" CHAR(15) NOT NULL, "Template_Type_Description" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_Type_Code") ) CREATE TABLE "Templates" ( "Template_ID" INTEGER NOT NULL, "Version_Number" INTEGER NOT NULL, "Template_Type_Code" CHAR(15) NOT NULL, "Date_Effective_From" DATETIME, "Date_Effective_To" DATETIME, "Template_Details" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_ID"), FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code") )
CREATE TABLE "Documents" ( "Document_ID" INTEGER NOT NULL, "Template_ID" INTEGER, "Document_Name" VARCHAR(255), "Document_Description" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Document_ID"), FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID") ) /* 2 rows from Documents table: Document_ID Template_ID Document_Name Document_Description Other_Details 0 7 Introduction of OS n None 1 25 Understanding DB y None */ CREATE TABLE "Paragraphs" ( "Paragraph_ID" INTEGER NOT NULL, "Document_ID" INTEGER NOT NULL, "Paragraph_Text" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Paragraph_ID"), FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID") ) /* 2 rows from Paragraphs table: Paragraph_ID Document_ID Paragraph_Text Other_Details 7 2394 Korea None 9 3 Somalia None */ CREATE TABLE "Ref_Template_Types" ( "Template_Type_Code" CHAR(15) NOT NULL, "Template_Type_Description" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_Type_Code") ) /* 2 rows from Ref_Template_Types table: Template_Type_Code Template_Type_Description PPT Presentation CV CV */ CREATE TABLE "Templates" ( "Template_ID" INTEGER NOT NULL, "Version_Number" INTEGER NOT NULL, "Template_Type_Code" CHAR(15) NOT NULL, "Date_Effective_From" DATETIME, "Date_Effective_To" DATETIME, "Template_Details" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_ID"), FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code") ) /* 2 rows from Templates table: Template_ID Version_Number Template_Type_Code Date_Effective_From Date_Effective_To Template_Details 0 5 PP 2005-11-12 07:09:48 2008-01-05 14:19:28 1 9 PP 2010-09-24 01:15:11 1999-07-08 03:31:04 */
What are the ids, names, and descriptions for all documents?
SELECT document_id , document_name , document_description FROM Documents
[{'Document_ID': 0, 'Document_Name': 'Introduction of OS', 'Document_Description': 'n'}, {'Document_ID': 1, 'Document_Name': 'Understanding DB', 'Document_Description': 'y'}, {'Document_ID': 3, 'Document_Name': 'Summer Show', 'Document_Description': 'u'}, {'Document_ID': 76, 'Document_Name': 'Robbin CV', 'Document_Description': 'y'}, {'Document_ID': 80, 'Document_Name': 'Welcome to NY', 'Document_Description': 'h'}, {'Document_ID': 82, 'Document_Name': 'Data base', 'Document_Description': 'w'}, {'Document_ID': 2394, 'Document_Name': 'Customer reviews', 'Document_Description': 'y'}, {'Document_ID': 3830, 'Document_Name': 'Do not panic', 'Document_Description': 'k'}, {'Document_ID': 33930, 'Document_Name': 'How Google people work', 'Document_Description': 'z'}, {'Document_ID': 50123, 'Document_Name': 'Learning French', 'Document_Description': 'r'}, {'Document_ID': 651512, 'Document_Name': 'How to write a CV', 'Document_Description': 'f'}, {'Document_ID': 801801, 'Document_Name': 'How to read a book', 'Document_Description': 'w'}, {'Document_ID': 3540024, 'Document_Name': 'Palm reading', 'Document_Description': 'y'}, {'Document_ID': 16514113, 'Document_Name': 'A history of Arts', 'Document_Description': 'h'}, {'Document_ID': 385906526, 'Document_Name': 'About Korea', 'Document_Description': 'b'}]
medium
Table Documents ( Documents.Document_ID (INTEGER), Documents.Template_ID (INTEGER), Documents.Document_Name (VARCHAR(255)), Documents.Document_Description (VARCHAR(255)), Documents.Other_Details (VARCHAR(255)), ) Table Paragraphs ( Paragraphs.Paragraph_ID (INTEGER), Paragraphs.Document_ID (INTEGER), Paragraphs.Paragraph_Text (VARCHAR(255)), Paragraphs.Other_Details (VARCHAR(255)), ) Table Ref_Template_Types ( Ref_Template_Types.Template_Type_Code (CHAR(15)), Ref_Template_Types.Template_Type_Description (VARCHAR(255)), ) Table Templates ( Templates.Template_ID (INTEGER), Templates.Version_Number (INTEGER), Templates.Template_Type_Code (CHAR(15)), Templates.Date_Effective_From (DATETIME), Templates.Date_Effective_To (DATETIME), Templates.Template_Details (VARCHAR(255)), ) Possible JOINs: Documents.Template_ID = Templates.Template_ID Paragraphs.Document_ID = Documents.Document_ID Templates.Template_Type_Code = Ref_Template_Types.Template_Type_Code
SELECT document_id , document_name , document_description FROM Documents
{ 'documents': ['document_id', 'document_name', 'document_description'] }
Table Documents ( Documents.Document_ID (INTEGER), Documents.Document_Name (VARCHAR(255)), Documents.Document_Description (VARCHAR(255)), )
Table Documents ( Documents.Document_ID (INTEGER), Documents.Template_ID (INTEGER), Documents.Document_Name (VARCHAR(255)), Documents.Document_Description (VARCHAR(255)), Documents.Other_Details (VARCHAR(255)), ) Possible JOINs: Documents.Template_ID = Templates.Template_ID
pets_1
CREATE TABLE "Has_Pet" ( "StuID" INTEGER, "PetID" INTEGER, FOREIGN KEY("PetID") REFERENCES "Pets" ("PetID"), FOREIGN KEY("StuID") REFERENCES "Student" ("StuID") ) CREATE TABLE "Pets" ( "PetID" INTEGER, "PetType" VARCHAR(20), pet_age INTEGER, weight REAL, PRIMARY KEY ("PetID") ) CREATE TABLE "Student" ( "StuID" INTEGER, "LName" VARCHAR(12), "Fname" VARCHAR(12), "Age" INTEGER, "Sex" VARCHAR(1), "Major" INTEGER, "Advisor" INTEGER, city_code VARCHAR(3), PRIMARY KEY ("StuID") )
CREATE TABLE "Has_Pet" ( "StuID" INTEGER, "PetID" INTEGER, FOREIGN KEY("PetID") REFERENCES "Pets" ("PetID"), FOREIGN KEY("StuID") REFERENCES "Student" ("StuID") ) /* 2 rows from Has_Pet table: StuID PetID 1001 2001 1002 2002 */ CREATE TABLE "Pets" ( "PetID" INTEGER, "PetType" VARCHAR(20), pet_age INTEGER, weight REAL, PRIMARY KEY ("PetID") ) /* 2 rows from Pets table: PetID PetType pet_age weight 2001 cat 3 12.0 2002 dog 2 13.4 */ CREATE TABLE "Student" ( "StuID" INTEGER, "LName" VARCHAR(12), "Fname" VARCHAR(12), "Age" INTEGER, "Sex" VARCHAR(1), "Major" INTEGER, "Advisor" INTEGER, city_code VARCHAR(3), PRIMARY KEY ("StuID") ) /* 2 rows from Student table: StuID LName Fname Age Sex Major Advisor city_code 1001 Smith Linda 18 F 600 1121 BAL 1002 Kim Tracy 19 F 600 7712 HKG */
Find the number of distinct type of pets.
SELECT count(DISTINCT pettype) FROM pets
[{'count(DISTINCT pettype)': 2}]
easy
Table Has_Pet ( Has_Pet.StuID (INTEGER), Has_Pet.PetID (INTEGER), ) Table Pets ( Pets.PetID (INTEGER), Pets.PetType (VARCHAR(20)), Pets.pet_age (INTEGER), Pets.weight (REAL), ) Table Student ( Student.StuID (INTEGER), Student.LName (VARCHAR(12)), Student.Fname (VARCHAR(12)), Student.Age (INTEGER), Student.Sex (VARCHAR(1)), Student.Major (INTEGER), Student.Advisor (INTEGER), Student.city_code (VARCHAR(3)), ) Possible JOINs: Has_Pet.StuID = Student.StuID Has_Pet.PetID = Pets.PetID
SELECT count(DISTINCT pettype) FROM pets
{ 'pets': ['petid', 'pettype'] }
Table Pets ( Pets.PetID (INTEGER), Pets.PetType (VARCHAR(20)), ) Possible JOINs:
Table Pets ( Pets.PetID (INTEGER), Pets.PetType (VARCHAR(20)), Pets.pet_age (INTEGER), Pets.weight (REAL), ) Possible JOINs:
car_1
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") )
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) /* 2 rows from car_makers table: Id Maker FullName Country 1 amc American Motor Company 1 2 volkswagen Volkswagen 2 */ CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) /* 2 rows from car_names table: MakeId Model Make 1 chevrolet chevrolet chevelle malibu 2 buick buick skylark 320 */ CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) /* 2 rows from cars_data table: Id MPG Cylinders Edispl Horsepower Weight Accelerate Year 1 18 8 307.0 130 3504 12.0 1970 2 15 8 350.0 165 3693 11.5 1970 */ CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) /* 2 rows from continents table: ContId Continent 1 america 2 europe */ CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) /* 2 rows from countries table: CountryId CountryName Continent 1 usa 1 2 germany 2 */ CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") ) /* 2 rows from model_list table: ModelId Maker Model 1 1 amc 2 2 audi */
What are the names and ids of all countries with at least one car maker?
SELECT T1.CountryName , T1.CountryId FROM COUNTRIES AS T1 JOIN CAR_MAKERS AS T2 ON T1.CountryId = T2.Country GROUP BY T1.CountryId HAVING count(*) >= 1;
[{'CountryName': 'usa', 'CountryId': 1}, {'CountryName': 'germany', 'CountryId': 2}, {'CountryName': 'france', 'CountryId': 3}, {'CountryName': 'japan', 'CountryId': 4}, {'CountryName': 'italy', 'CountryId': 5}, {'CountryName': 'sweden', 'CountryId': 6}, {'CountryName': 'uk', 'CountryId': 7}, {'CountryName': 'korea', 'CountryId': 8}]
medium
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_makers.Country = countries.CountryId car_names.Model = model_list.Model cars_data.Id = car_names.MakeId countries.Continent = continents.ContId model_list.Maker = car_makers.Id
SELECT COUNTRIES.CountryName , COUNTRIES.CountryId FROM COUNTRIES JOIN CAR_MAKERS ON COUNTRIES.CountryId = CAR_MAKERS.Country GROUP BY COUNTRIES.CountryId HAVING count(*) >= 1;
{ 'countries': ['countryid', 'countryname'], 'car_makers': ['id', 'country'] }
Table car_makers ( car_makers.Id (INTEGER), car_makers.Country (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), ) Possible JOINs:
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Possible JOINs: car_makers.Country = countries.CountryId countries.Continent = continents.ContId
wta_1
CREATE TABLE players( "player_id" INT PRIMARY KEY, "first_name" TEXT, "last_name" TEXT, "hand" TEXT, "birth_date" DATE, "country_code" TEXT ) /* 0 rows from players table: player_id first_name last_name hand birth_date country_code */ CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ) /* 0 rows from matches table: best_of draw_size loser_age loser_entry loser_hand loser_ht loser_id loser_ioc loser_name loser_rank loser_rank_points loser_seed match_num minutes round score surface tourney_date tourney_id tourney_level tourney_name winner_age winner_entry winner_hand winner_ht winner_id winner_ioc winner_name winner_rank winner_rank_points winner_seed year */ CREATE TABLE rankings("ranking_date" DATE,"ranking" INT,"player_id" INT,"ranking_points" INT,"tours" INT,FOREIGN KEY(player_id) REFERENCES players(player_id)) /* 0 rows from rankings table: ranking_date ranking player_id ranking_points tours */
CREATE TABLE players( "player_id" INT PRIMARY KEY, "first_name" TEXT, "last_name" TEXT, "hand" TEXT, "birth_date" DATE, "country_code" TEXT ) /* 2 rows from players table: player_id first_name last_name hand birth_date country_code 200001 Martina Hingis R 19800930 SUI 200002 Mirjana Lucic R 19820309 CRO */ CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ) /* 2 rows from matches table: best_of draw_size loser_age loser_entry loser_hand loser_ht loser_id loser_ioc loser_name loser_rank loser_rank_points loser_seed match_num minutes round score surface tourney_date tourney_id tourney_level tourney_name winner_age winner_entry winner_hand winner_ht winner_id winner_ioc winner_name winner_rank winner_rank_points winner_seed year 3 4 24.626967830300003 R 170 201474 POL Agnieszka Radwanska 4 5890 3 297 82 RR 6-2 6-4 Hard 20131021 2013-W-WT-TUR-01A-2013 W WTA Championships 32.0684462697 R 175 200033 USA Serena Williams 1 12040 1 2013 3 4 23.6221765914 L 183 201520 CZE Petra Kvitova 6 4370 5 296 72 RR 6-2 6-3 Hard 20131021 2013-W-WT-TUR-01A-2013 W WTA Championships 32.0684462697 R 175 200033 USA Serena Williams 1 12040 1 2013 */ CREATE TABLE rankings("ranking_date" DATE,"ranking" INT,"player_id" INT,"ranking_points" INT,"tours" INT,FOREIGN KEY(player_id) REFERENCES players(player_id)) /* 2 rows from rankings table: ranking_date ranking player_id ranking_points tours 20000101 3 200748 4378 13 20000101 4 200033 3021 15 */
List the first and last name of all players who are left / L hand in the order of birth date.
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
[{'first_name': 'Ann', 'last_name': 'Jones'}, {'first_name': 'Wendy', 'last_name': 'Gilchrist'}, {'first_name': 'Martina', 'last_name': 'Navratilova'}, {'first_name': 'Mary', 'last_name': 'Carillo'}, {'first_name': 'Katerina', 'last_name': 'Bohmova'}, {'first_name': 'Petra', 'last_name': 'Delhees Jauch'}, {'first_name': 'Nancy', 'last_name': 'Loeffler Caro'}, {'first_name': 'Lise', 'last_name': 'Gregory'}, {'first_name': 'Rene', 'last_name': 'Collins'}, {'first_name': 'Nicole', 'last_name': 'Arendt'}, {'first_name': 'Florencia', 'last_name': 'Labat'}, {'first_name': 'Sabine', 'last_name': 'Appelmans'}, {'first_name': 'Andreea', 'last_name': 'Ehritt Vanc'}, {'first_name': 'Monica', 'last_name': 'Seles'}, {'first_name': 'Gala', 'last_name': 'Leon Garcia'}, {'first_name': 'Karen', 'last_name': 'Cross'}, {'first_name': 'Julie', 'last_name': 'Pullin'}, {'first_name': 'Vanessa', 'last_name': 'Webb'}, {'first_name': 'Elena', 'last_name': 'Tatarkova'}, {'first_name': 'Anca', 'last_name': 'Barna'}, {'first_name': 'Francesca', 'last_name': 'Lubiani'}, {'first_name': 'Gaelle', 'last_name': 'Widmer'}, {'first_name': 'Amanda', 'last_name': 'Keen'}, {'first_name': 'Amanda', 'last_name': 'Augustus'}, {'first_name': 'Rita', 'last_name': 'Kuti Kis'}, {'first_name': 'Amelie', 'last_name': 'Cocheteux'}, {'first_name': 'Amelie', 'last_name': 'Castera'}, {'first_name': 'Saori', 'last_name': 'Obata'}, {'first_name': 'Marine', 'last_name': 'Nizri Spiegel'}, {'first_name': 'Patty', 'last_name': 'Schnyder'}, {'first_name': 'Julie', 'last_name': 'Ditty'}, {'first_name': 'Joana', 'last_name': 'Cortez'}, {'first_name': 'Barbara', 'last_name': 'Schwartz'}, {'first_name': 'Ludmilla', 'last_name': 'Varmuza'}, {'first_name': 'Magui', 'last_name': 'Serna'}, {'first_name': 'Amanda', 'last_name': 'Grahame'}, {'first_name': 'Kim', 'last_name': 'Kilsdonk'}, {'first_name': 'Emilie', 'last_name': 'Loit'}, {'first_name': 'Erika', 'last_name': 'Pineider'}, {'first_name': 'Anne Gaelle', 'last_name': 'Sidot'}, {'first_name': 'Erica', 'last_name': 'Biro'}, {'first_name': 'Stephanie', 'last_name': 'Kovacic'}, {'first_name': 'Sybille', 'last_name': 'Bammer'}, {'first_name': 'Lisa', 'last_name': 'Fritz'}, {'first_name': 'Maja', 'last_name': 'Matevzic'}, {'first_name': 'Leanne', 'last_name': 'Baker'}, {'first_name': 'Aurelie', 'last_name': 'Vedy'}, {'first_name': 'Carla', 'last_name': 'Tiene'}, {'first_name': 'Erika', 'last_name': 'Venere'}, {'first_name': 'Jelena', 'last_name': 'Kostanic Tosic'}, {'first_name': 'Clarisa', 'last_name': 'Fernandez'}, {'first_name': 'Ansley', 'last_name': 'Cargill'}, {'first_name': 'Dimana', 'last_name': 'Krastevitch'}, {'first_name': 'Maria Jose', 'last_name': 'Martinez Sanchez'}, {'first_name': 'Zerene', 'last_name': 'Reyes'}, {'first_name': 'Melinda', 'last_name': 'Czink'}, {'first_name': 'Sandra', 'last_name': 'Klemenschits'}, {'first_name': 'Maria Elizabeth', 'last_name': 'Lopez'}, {'first_name': 'Salome', 'last_name': 'Llaguno'}, {'first_name': 'Lindsay', 'last_name': 'Cox'}, {'first_name': 'Iveta', 'last_name': 'Benesova'}, {'first_name': 'Eugenia', 'last_name': 'Chialvo'}, {'first_name': 'Chun Yan', 'last_name': 'He'}, {'first_name': 'Maria Fernanda', 'last_name': 'Alves'}, {'first_name': 'Emily', 'last_name': 'Quin'}, {'first_name': 'Fernanda', 'last_name': 'Oliveira Da Silva'}, {'first_name': 'Annabel', 'last_name': 'Blow'}, {'first_name': 'Julia', 'last_name': 'Smith'}, {'first_name': 'Ana Lucia', 'last_name': 'Migliarini De Leon'}, {'first_name': 'Elizabeth', 'last_name': 'Bondi'}, {'first_name': 'Galina', 'last_name': 'Fokina'}, {'first_name': 'Elise', 'last_name': 'Tamaela'}, {'first_name': 'Bit Na', 'last_name': 'Lee'}, {'first_name': 'Sonia', 'last_name': 'Iacovacci'}, {'first_name': 'Mariana Pires', 'last_name': 'Junqueira'}, {'first_name': 'Natalia', 'last_name': 'Bogdanova'}, {'first_name': 'Irina', 'last_name': 'Smirnova'}, {'first_name': 'Meghha', 'last_name': 'Vakaria'}, {'first_name': 'Angela', 'last_name': 'Haynes'}, {'first_name': 'Karly', 'last_name': 'Olson'}, {'first_name': 'Casey', 'last_name': 'Dellacqua'}, {'first_name': 'Kathrin', 'last_name': 'Hegel'}, {'first_name': 'Beatrix', 'last_name': 'Csordas'}, {'first_name': 'Zsuzsanna', 'last_name': 'Babos'}, {'first_name': 'Emily', 'last_name': 'Applegate'}, {'first_name': 'Olga', 'last_name': 'Pasichnichenko'}, {'first_name': 'Theresa', 'last_name': 'Logar'}, {'first_name': 'Jin A', 'last_name': 'Lee'}, {'first_name': 'Hannah', 'last_name': 'Kuervers'}, {'first_name': 'Andreea', 'last_name': 'Novaceanu'}, {'first_name': 'Valentina', 'last_name': 'Tizzano'}, {'first_name': 'Helen', 'last_name': 'Fritche'}, {'first_name': 'Sandra', 'last_name': 'Sasidharan'}, {'first_name': 'Isha', 'last_name': 'Lakhani'}, {'first_name': 'Krushmi', 'last_name': 'Chheda'}, {'first_name': 'Ljubica', 'last_name': 'Avramovic'}, {'first_name': 'Avel Romaly', 'last_name': 'Coronado'}, {'first_name': 'Shadisha', 'last_name': 'Robinson'}, {'first_name': 'Carla', 'last_name': 'Zabaleta'}, {'first_name': 'Diana', 'last_name': 'Arutyunova'}, {'first_name': 'Cecile', 'last_name': 'Baijot'}, {'first_name': 'Laura', 'last_name': 'Rocchi'}, {'first_name': 'Rie', 'last_name': 'Imai'}, {'first_name': 'Danielle', 'last_name': 'Harmsen'}, {'first_name': 'Alejandra', 'last_name': 'Obregon'}, {'first_name': 'Ariela', 'last_name': 'Perez'}, {'first_name': 'Vasilisa', 'last_name': 'Davydova'}, {'first_name': 'Emilia', 'last_name': 'Yorio'}, {'first_name': 'Lizaan', 'last_name': 'Du Plessis'}, {'first_name': 'Claire', 'last_name': 'Feuerstein'}, {'first_name': 'Alexandria', 'last_name': 'Liles'}, {'first_name': 'Katharine', 'last_name': 'Baker'}, {'first_name': 'Emma', 'last_name': 'Laine'}, {'first_name': 'Geraldine', 'last_name': 'Roma'}, {'first_name': 'Aya', 'last_name': 'El Akkad'}, {'first_name': 'Alexandra', 'last_name': 'Kazanova'}, {'first_name': 'Allison', 'last_name': 'Baker'}, {'first_name': 'Lucy', 'last_name': 'Fletcher'}, {'first_name': 'Monika', 'last_name': 'Musilova'}, {'first_name': 'Jitka', 'last_name': 'Gavdunova'}, {'first_name': 'Elena', 'last_name': 'Petrucciano'}, {'first_name': 'Varvara', 'last_name': 'Lepchenko'}, {'first_name': 'Claire', 'last_name': 'De Gubernatis'}, {'first_name': 'Seheno', 'last_name': 'Razafindramaso'}, {'first_name': 'Karolina', 'last_name': 'Soor'}, {'first_name': 'Melisa', 'last_name': 'Cabrera Handt'}, {'first_name': 'Shraddha', 'last_name': 'Lodha'}, {'first_name': 'Sylvia', 'last_name': 'Krywacz'}, {'first_name': 'Amina', 'last_name': 'El Sahn'}, {'first_name': 'Hendrike Lea', 'last_name': 'Heitmann'}, {'first_name': 'Dunja', 'last_name': 'Antunovic'}, {'first_name': 'Micaela', 'last_name': 'Acosta'}, {'first_name': 'Katerina', 'last_name': 'Bohmova'}, {'first_name': 'Catherine', 'last_name': 'Grotz'}, {'first_name': 'Yurika', 'last_name': 'Sema'}, {'first_name': 'Sheng Nan', 'last_name': 'Sun'}, {'first_name': 'Lucie', 'last_name': 'Safarova'}, {'first_name': 'Jitka', 'last_name': 'Kleisnerova'}, {'first_name': 'Carolina', 'last_name': 'Escamilla'}, {'first_name': 'Tapiwa', 'last_name': 'Marobela'}, {'first_name': 'Punam', 'last_name': 'Reddy'}, {'first_name': 'Katia', 'last_name': 'Sabate Orera'}, {'first_name': 'Shana', 'last_name': 'Claes'}, {'first_name': 'Chrissie', 'last_name': 'Seredni'}, {'first_name': 'Yui', 'last_name': 'Nagasawa'}, {'first_name': 'Marcela', 'last_name': 'Vojtiskova'}, {'first_name': 'Seul Ki', 'last_name': 'Chin'}, {'first_name': 'Nina', 'last_name': 'Munch Soegaard'}, {'first_name': 'Hannah', 'last_name': 'Grady'}, {'first_name': 'Karen', 'last_name': 'Castiblanco'}, {'first_name': 'Angelique', 'last_name': 'Kerber'}, {'first_name': 'Lauren', 'last_name': 'Lui'}, {'first_name': 'Rana', 'last_name': 'Tharwat Hafez'}, {'first_name': 'Nicole', 'last_name': 'Grunwald'}, {'first_name': 'Ana', 'last_name': 'Veselinovic'}, {'first_name': 'Sanaa', 'last_name': 'Bhambri'}, {'first_name': 'Diana Andreea', 'last_name': 'Gae'}, {'first_name': 'Ana', 'last_name': 'Beltran Trigueros'}, {'first_name': 'Barbora', 'last_name': 'Bozkova'}, {'first_name': 'Camila', 'last_name': 'Belassi'}, {'first_name': 'Violette', 'last_name': 'Huck'}, {'first_name': 'Megumi', 'last_name': 'Fukui'}, {'first_name': 'Rita', 'last_name': 'Gouveia'}, {'first_name': 'Mihaela', 'last_name': 'Buzarnescu'}, {'first_name': 'Liset', 'last_name': 'Brito Herrera'}, {'first_name': 'Paulina', 'last_name': 'Jorquera'}, {'first_name': 'Ekaterina', 'last_name': 'Makarova'}, {'first_name': 'Dessislava', 'last_name': 'Mladenova'}, {'first_name': 'Sanaz', 'last_name': 'Marand'}, {'first_name': 'Cristina', 'last_name': 'Greco Naccarato'}, {'first_name': 'Cagla', 'last_name': 'Urcu'}, {'first_name': 'Liege', 'last_name': 'Vieira'}, {'first_name': 'Chang', 'last_name': 'Xu'}, {'first_name': 'Jessica', 'last_name': 'Sweeting'}, {'first_name': 'Yi Fan', 'last_name': 'Xu'}, {'first_name': 'Eloisa Maria', 'last_name': 'Compostizo De Andres'}, {'first_name': 'Karina', 'last_name': 'Porushkevich'}, {'first_name': 'Ornella', 'last_name': 'Gentile'}, {'first_name': 'Valeria', 'last_name': 'Casillo'}, {'first_name': 'Bianca Ioana', 'last_name': 'Bonifate'}, {'first_name': 'Michelle', 'last_name': 'Russ'}, {'first_name': 'Monika', 'last_name': 'Lalewicz'}, {'first_name': 'Amandine', 'last_name': 'Cazeaux'}, {'first_name': 'Fatima', 'last_name': 'El Allami'}, {'first_name': 'Simonetta', 'last_name': 'Miori'}, {'first_name': 'Gabriela', 'last_name': 'Roux'}, {'first_name': 'Sherazad', 'last_name': 'Benamar'}, {'first_name': 'Sherazad', 'last_name': 'Reix'}, {'first_name': 'Zora', 'last_name': 'Vlckova'}, {'first_name': 'Naomi', 'last_name': 'Cavaday'}, {'first_name': 'Nathalia', 'last_name': 'Rossi'}, {'first_name': 'Maria Eugenia', 'last_name': 'Roca Recarey'}, {'first_name': 'Lauren', 'last_name': 'Jones'}, {'first_name': 'Roxane', 'last_name': 'Vaisemberg'}, {'first_name': 'Ivana', 'last_name': 'Belejova'}, {'first_name': 'Petra', 'last_name': 'Vogel'}, {'first_name': 'Majdouline', 'last_name': 'Akrate'}, {'first_name': 'Laura', 'last_name': 'Sadria'}, {'first_name': 'Ia', 'last_name': 'Jikia'}, {'first_name': 'Alessandra', 'last_name': 'Caprara'}, {'first_name': 'Guadalupe', 'last_name': 'Moreno'}, {'first_name': 'Lucie', 'last_name': 'Sipkova'}, {'first_name': 'Xenia', 'last_name': 'Samoilova'}, {'first_name': 'Kotomi', 'last_name': 'Takahata'}, {'first_name': 'Stephanie', 'last_name': 'Theiler'}, {'first_name': 'Maria', 'last_name': 'Prishlyak'}, {'first_name': 'Grace', 'last_name': 'Leake'}, {'first_name': 'Ioana Alexandra', 'last_name': 'Oprea'}, {'first_name': 'Sanne', 'last_name': 'Bakker'}, {'first_name': 'Katerina', 'last_name': 'Vankova'}, {'first_name': 'Kristy', 'last_name': 'Frilling'}, {'first_name': 'Tatiana', 'last_name': 'Bua'}, {'first_name': 'Anastasia', 'last_name': 'Kontratevidi'}, {'first_name': 'Chane', 'last_name': 'Hines'}, {'first_name': 'Julia', 'last_name': 'Gavenko'}, {'first_name': 'Yuuki', 'last_name': 'Tanaka'}, {'first_name': 'Petra', 'last_name': 'Kvitova'}, {'first_name': 'Leticia', 'last_name': 'Costas'}, {'first_name': 'Sandra', 'last_name': 'Roma'}, {'first_name': 'Nina', 'last_name': 'Mujezinovic'}, {'first_name': 'Stella', 'last_name': 'Papaspyrou'}, {'first_name': 'Chinami', 'last_name': 'Ogi'}, {'first_name': 'Martina', 'last_name': 'Balogova'}, {'first_name': 'Xinyun', 'last_name': 'Han'}, {'first_name': 'Nicole', 'last_name': 'Riner'}, {'first_name': 'Lara', 'last_name': 'Meccico'}, {'first_name': 'Mai', 'last_name': 'Iwasaki'}, {'first_name': 'Oksana', 'last_name': 'Kalashnikova'}, {'first_name': 'Dipti', 'last_name': 'Srivastava'}, {'first_name': 'Claudia', 'last_name': 'Mercado'}, {'first_name': 'Margarita', 'last_name': 'Lazareva'}, {'first_name': 'Shaozhuo', 'last_name': 'Liu'}, {'first_name': 'Ana Maria', 'last_name': 'Chavez Franco'}, {'first_name': 'Arantxa', 'last_name': 'Rus'}, {'first_name': 'Ekaterina', 'last_name': 'Kamendova'}, {'first_name': 'Monika', 'last_name': 'Tumova'}, {'first_name': 'Gabriella', 'last_name': 'Boboc'}, {'first_name': 'Ganna', 'last_name': 'Lukianchykova'}, {'first_name': 'Sofia', 'last_name': 'Medina'}, {'first_name': 'Ekaterina', 'last_name': 'Abaeva'}, {'first_name': 'Andressa', 'last_name': 'Garcia'}, {'first_name': 'Giulia', 'last_name': 'Bruzzone'}, {'first_name': 'Catia', 'last_name': 'Rodrigues'}, {'first_name': 'Danielle', 'last_name': 'Mills'}, {'first_name': 'Flavia', 'last_name': 'Borges'}, {'first_name': 'Misaki', 'last_name': 'Doi'}, {'first_name': 'Veronika', 'last_name': 'Domagala'}, {'first_name': 'Cindy', 'last_name': 'Chala'}, {'first_name': 'Ksenia', 'last_name': 'Pervak'}, {'first_name': 'Bianca', 'last_name': 'Botto'}, {'first_name': 'Marianna', 'last_name': 'Natali'}, {'first_name': 'Carolina', 'last_name': 'Orsi'}, {'first_name': 'Aleksandra', 'last_name': 'Vukadinovic'}, {'first_name': 'Elixane', 'last_name': 'Lechemia'}, {'first_name': 'Sonya', 'last_name': 'Dayal'}, {'first_name': 'Francesca', 'last_name': 'Campigotto'}, {'first_name': 'Cristina Bianca', 'last_name': 'Danaila'}, {'first_name': 'Tereza', 'last_name': 'Budilova'}, {'first_name': 'Gemma', 'last_name': 'Praditngam'}, {'first_name': 'Ekaterine', 'last_name': 'Gorgodze'}, {'first_name': 'Dejana', 'last_name': 'Raickovic'}, {'first_name': 'Alena', 'last_name': 'Gerasimova'}, {'first_name': 'Quirine', 'last_name': 'Lemoine'}, {'first_name': 'Chieh Yu', 'last_name': 'Hsu'}, {'first_name': 'Anastasiya', 'last_name': 'Vasylyeva'}, {'first_name': 'Alexia', 'last_name': 'Quartetto'}, {'first_name': 'Joanna', 'last_name': 'Bougon'}, {'first_name': 'Kristyna', 'last_name': 'Pliskova'}, {'first_name': 'Elena', 'last_name': 'Bogdan'}, {'first_name': 'Fiorella', 'last_name': 'Jerardino'}, {'first_name': 'Julie', 'last_name': 'Gonzalez Rodriguez'}, {'first_name': 'Alejandra', 'last_name': 'Barragan'}, {'first_name': 'Renata', 'last_name': 'Bakieva'}, {'first_name': 'Ashley', 'last_name': 'Krysiak'}, {'first_name': 'Sarah Rebecca', 'last_name': 'Sekulic'}, {'first_name': 'Na Lae', 'last_name': 'Han'}, {'first_name': 'Natali', 'last_name': 'Coronel'}, {'first_name': 'Kristyna', 'last_name': 'Hancarova'}, {'first_name': 'Doroteja', 'last_name': 'Eric'}, {'first_name': 'Chanel', 'last_name': 'Simmonds'}, {'first_name': 'Kobkanok', 'last_name': 'Upapong'}, {'first_name': 'Annie', 'last_name': 'Sullivan'}, {'first_name': 'Jenny Thuy', 'last_name': 'Le'}, {'first_name': 'Xenia', 'last_name': 'Knoll'}, {'first_name': 'Francisca', 'last_name': 'Matos'}, {'first_name': 'Christina', 'last_name': 'Madenoglou'}, {'first_name': 'Alexandra', 'last_name': 'Avirvarei'}, {'first_name': 'Georgina', 'last_name': 'Fedosenkova'}, {'first_name': 'Alicia', 'last_name': 'Doms Golobart'}, {'first_name': 'Amy', 'last_name': 'Hoburn'}, {'first_name': 'Monica', 'last_name': 'Turewicz'}, {'first_name': 'Martina', 'last_name': 'Zerbola'}, {'first_name': 'Mashaal', 'last_name': 'Hameed'}, {'first_name': 'Sabrina', 'last_name': 'Dos Reis'}, {'first_name': 'Maria Sol', 'last_name': 'Carrasco'}, {'first_name': 'Ruxandra', 'last_name': 'Ababii'}, {'first_name': 'Daniella', 'last_name': 'Patton'}, {'first_name': 'Veronika', 'last_name': 'Zavodska'}, {'first_name': 'Briar', 'last_name': 'Preston'}, {'first_name': 'Gabriela', 'last_name': 'Ce'}, {'first_name': 'Amanda', 'last_name': 'Rodgers'}, {'first_name': 'Constanze', 'last_name': 'Lotz'}, {'first_name': 'Paula', 'last_name': 'Mocete Talamantes'}, {'first_name': 'Verena', 'last_name': 'Gantschnig'}, {'first_name': 'Ainhoa', 'last_name': 'Atucha Gomez'}, {'first_name': 'Katarzyna', 'last_name': 'Kossowska'}, {'first_name': 'Julia', 'last_name': 'Stamatova'}, {'first_name': 'Vorranavaporn', 'last_name': 'Vorrarattanamongkol'}, {'first_name': 'Michaela', 'last_name': 'Jasenakova'}, {'first_name': 'Agustina Sol', 'last_name': 'Eskenazi'}, {'first_name': 'Maja', 'last_name': 'Mladenovic'}, {'first_name': 'Sandra', 'last_name': 'Garriga Catala'}, {'first_name': 'Rita', 'last_name': 'Vilaca'}, {'first_name': 'Zanmarie', 'last_name': 'Pienaar'}, {'first_name': 'Julia', 'last_name': 'Kimmelmann'}, {'first_name': 'Martina', 'last_name': 'Trevisan'}, {'first_name': 'Charitomeni', 'last_name': 'Matoula'}, {'first_name': 'Andreea', 'last_name': 'Istrate'}, {'first_name': 'Sowjanya', 'last_name': 'Bavisetti'}, {'first_name': 'Gabrielle', 'last_name': 'Moxey'}, {'first_name': 'Viktoryia', 'last_name': 'Kisialeva'}, {'first_name': 'Sarahi', 'last_name': 'Garcia Carrera'}, {'first_name': 'Rachel', 'last_name': 'Girard'}, {'first_name': 'Laura', 'last_name': 'Robson'}, {'first_name': 'Kate', 'last_name': 'Vialle'}, {'first_name': 'Anna', 'last_name': 'Montserrat Sanchez'}, {'first_name': 'Elena Teodora', 'last_name': 'Cadar'}, {'first_name': 'Carol', 'last_name': 'Augustine Benito'}, {'first_name': 'Kamila', 'last_name': 'Pavelkova'}, {'first_name': 'Arantxa', 'last_name': 'Sanchez'}, {'first_name': 'Ana Sofia', 'last_name': 'Sanchez'}, {'first_name': 'Julia', 'last_name': 'Wachaczyk'}, {'first_name': 'Ecaterina', 'last_name': 'Oproiu'}, {'first_name': 'Snigdha', 'last_name': 'Padamata'}, {'first_name': 'Rona', 'last_name': 'Berisha'}, {'first_name': 'Olga', 'last_name': 'Doroshina'}, {'first_name': 'So Ra', 'last_name': 'Lee'}, {'first_name': 'Brandy', 'last_name': 'Mina'}, {'first_name': 'Natalie', 'last_name': 'Novakova'}, {'first_name': 'Storm', 'last_name': 'Sanders'}, {'first_name': 'Alexandra', 'last_name': 'Martinez'}, {'first_name': 'Ysaline', 'last_name': 'Bonaventure'}, {'first_name': 'Barbora', 'last_name': 'Trestikova'}, {'first_name': 'Stefania', 'last_name': 'Hristov'}, {'first_name': 'Ana Maria', 'last_name': 'Crisan'}, {'first_name': 'Elpida', 'last_name': 'Papanelopoulou'}, {'first_name': 'Tereza', 'last_name': 'Jankovska'}, {'first_name': 'Rebecca', 'last_name': 'Andrade'}, {'first_name': 'Kelly', 'last_name': 'Williford'}, {'first_name': 'Tina', 'last_name': 'Rupert'}, {'first_name': 'Mia Nicole', 'last_name': 'Eklund'}, {'first_name': 'Bernarda', 'last_name': 'Pera'}, {'first_name': 'Montserrat', 'last_name': 'Alonso'}, {'first_name': 'Rosalie', 'last_name': 'Van Der Hoek'}, {'first_name': 'Hedda', 'last_name': 'Odegaard'}, {'first_name': 'Samira', 'last_name': 'Radjaa'}, {'first_name': 'Zuzanna', 'last_name': 'Maciejewska'}, {'first_name': 'Saumya', 'last_name': 'Vig'}, {'first_name': 'Marie', 'last_name': 'Benoit'}, {'first_name': 'Iga', 'last_name': 'Odrzywolek'}, {'first_name': 'Shakhlo', 'last_name': 'Saidova'}, {'first_name': 'Irina', 'last_name': 'Khromacheva'}, {'first_name': 'Yuliya', 'last_name': 'Lysa'}, {'first_name': 'Sophie', 'last_name': 'Blom'}, {'first_name': 'Jennifer', 'last_name': 'Zerbone'}, {'first_name': 'Kristina', 'last_name': 'Chasovskikh'}, {'first_name': 'Maria Camila', 'last_name': 'Trujillo Hoyos'}, {'first_name': 'Karina', 'last_name': 'Rovira'}, {'first_name': 'Teodora Adina', 'last_name': 'Ardeleanu'}, {'first_name': 'Yasmine', 'last_name': 'Rashad'}, {'first_name': 'Judit', 'last_name': 'Vives Joan'}, {'first_name': 'Sarah Beth', 'last_name': 'Askew'}, {'first_name': 'Yasmine', 'last_name': 'Xantos'}, {'first_name': 'Lea', 'last_name': 'Tholey'}, {'first_name': 'Hikari', 'last_name': 'Yamamoto'}, {'first_name': 'Ines Miren', 'last_name': 'De Pablo'}, {'first_name': 'Stuti', 'last_name': 'Singh Tomar'}, {'first_name': 'Naomi', 'last_name': 'Totka'}, {'first_name': 'Polina', 'last_name': 'Bezsmertnaya'}, {'first_name': 'Hannah', 'last_name': 'King'}, {'first_name': 'Gabriele', 'last_name': 'Bertasiute'}, {'first_name': 'Rebecca', 'last_name': 'Smaller'}, {'first_name': 'Busra', 'last_name': 'Kayrun'}, {'first_name': 'Stephani', 'last_name': 'Rodriguez'}, {'first_name': 'Raquel', 'last_name': 'Montalvo'}, {'first_name': 'Oana', 'last_name': 'Irimescu'}, {'first_name': 'Taylor', 'last_name': 'Townsend'}, {'first_name': 'Carmen', 'last_name': 'Blasco Robaina'}, {'first_name': 'Giulia', 'last_name': 'Della Cioppa'}, {'first_name': 'Nadege', 'last_name': 'Jorda'}, {'first_name': 'Beatriz', 'last_name': 'Haddad Maia'}, {'first_name': 'Nelise', 'last_name': 'Verster'}, {'first_name': 'Eleonore', 'last_name': 'Barrere'}, {'first_name': 'Anastasia', 'last_name': 'Prokopenko'}, {'first_name': 'Dzina', 'last_name': 'Milovanovic'}, {'first_name': 'Isabelle', 'last_name': 'Wallace'}, {'first_name': 'Katelyn', 'last_name': 'Jackson'}, {'first_name': 'Polina', 'last_name': 'Novoselova'}, {'first_name': 'Maite', 'last_name': 'Cano'}, {'first_name': 'Ria', 'last_name': 'Vaidya'}, {'first_name': 'Ana Lorena', 'last_name': 'Garcia Navas'}, {'first_name': 'Aayushi', 'last_name': 'Chouhan'}, {'first_name': 'Ivona', 'last_name': 'Cudina'}, {'first_name': 'Karina', 'last_name': 'Gurgenyan'}, {'first_name': 'Maria', 'last_name': 'Patrascu'}, {'first_name': 'Denisa', 'last_name': 'Chereches'}, {'first_name': 'Mirabelle', 'last_name': 'Njoze'}, {'first_name': 'Vasanti', 'last_name': 'Shinde'}, {'first_name': 'Amanda', 'last_name': 'Schneider'}, {'first_name': 'Katharina', 'last_name': 'Herpertz'}, {'first_name': 'Tayisiya', 'last_name': 'Morderger'}, {'first_name': 'Tamara', 'last_name': 'Tomic'}, {'first_name': 'Maria Fernanda', 'last_name': 'Herazo Gonzalez'}, {'first_name': 'Andra Maria', 'last_name': 'Nitescu'}, {'first_name': 'Micheline', 'last_name': 'Aubuchon'}, {'first_name': 'Ilayda', 'last_name': 'Yondem'}, {'first_name': 'Birgit', 'last_name': 'Burk'}, {'first_name': 'Kanako', 'last_name': 'Osafune'}, {'first_name': 'Anastasiya', 'last_name': 'Komardina'}, {'first_name': 'Nina', 'last_name': 'Holanova'}, {'first_name': 'Jil Belen', 'last_name': 'Teichmann'}, {'first_name': 'Francesca', 'last_name': 'Di Lorenzo'}, {'first_name': 'Natsuho', 'last_name': 'Arakawa'}, {'first_name': 'Emerald', 'last_name': 'Able'}, {'first_name': 'Manca', 'last_name': 'Pislak'}, {'first_name': 'Irys', 'last_name': 'Ekani'}, {'first_name': 'Veronica', 'last_name': 'Miroshnichenko'}, {'first_name': 'Martina', 'last_name': 'Capurro Taborda'}, {'first_name': 'Mariam', 'last_name': 'Bolkvadze'}, {'first_name': 'Diana', 'last_name': 'Valverde'}, {'first_name': 'Do Hee', 'last_name': 'Bae'}, {'first_name': 'Daniela', 'last_name': 'Morales Beckmann'}, {'first_name': 'Ioana Diana', 'last_name': 'Pietroiu'}, {'first_name': 'Luisa Fernanda', 'last_name': 'Echeverry Rodriguez'}, {'first_name': 'Mayuka', 'last_name': 'Aikawa'}, {'first_name': 'Nicole', 'last_name': 'Frenkel'}, {'first_name': 'Daria', 'last_name': 'Kruzhkova'}, {'first_name': 'Alejandra', 'last_name': 'Tamayo Gomez'}, {'first_name': 'Tereza', 'last_name': 'Koplova'}, {'first_name': 'Chiara', 'last_name': 'Lommer'}, {'first_name': 'Laura', 'last_name': 'Illanes'}, {'first_name': 'Olga', 'last_name': 'Fridman'}, {'first_name': 'Ana Paula', 'last_name': 'Leal'}, {'first_name': 'Shiraz', 'last_name': 'Bronstein'}, {'first_name': 'Nicole', 'last_name': 'Bunea'}, {'first_name': 'Charlotte', 'last_name': 'Robillard Millette'}, {'first_name': 'Ashley', 'last_name': 'Kratzer'}, {'first_name': 'Momoka', 'last_name': 'Chimura'}, {'first_name': 'Anna', 'last_name': 'Slovakova'}, {'first_name': 'Ai Qi', 'last_name': 'Chen'}, {'first_name': 'Jiaying', 'last_name': 'He'}, {'first_name': 'Ysabel', 'last_name': 'Gonzalez Rico'}, {'first_name': 'Andreea', 'last_name': 'Stanescu'}, {'first_name': 'Marketa', 'last_name': 'Vondrousova'}, {'first_name': 'Ecaterina', 'last_name': 'Ivasco'}, {'first_name': 'Ivon', 'last_name': 'Mihaleva'}, {'first_name': 'Jasmine', 'last_name': 'Boyd'}, {'first_name': 'Andrea', 'last_name': 'Arratia Fernandez'}, {'first_name': 'Kayla', 'last_name': 'Day'}, {'first_name': 'Ekaterina', 'last_name': 'Davletova'}, {'first_name': 'Irina', 'last_name': 'Cantos Siemers'}, {'first_name': 'Oceane', 'last_name': 'Mialon'}, {'first_name': 'Watsachol', 'last_name': 'Sawasdee'}, {'first_name': 'Ellen', 'last_name': 'Ashley'}, {'first_name': 'Mila', 'last_name': 'Mejic'}, {'first_name': 'Natalia', 'last_name': 'Nikolopoulou'}, {'first_name': 'Marta', 'last_name': 'Del Pino Maturano'}, {'first_name': 'Jayci', 'last_name': 'Goldsmith'}, {'first_name': 'Yang', 'last_name': 'Lee'}, {'first_name': 'Isabella', 'last_name': 'Tcherkes Zade'}, {'first_name': 'Mara', 'last_name': 'Vidal'}, {'first_name': 'Taylor', 'last_name': 'Johnson'}, {'first_name': 'Julia', 'last_name': 'Vulpio'}, {'first_name': 'Dagmar', 'last_name': 'Zdrubecka'}, {'first_name': 'Olga', 'last_name': 'Danilovic'}, {'first_name': 'Xiyu', 'last_name': 'Wang'}, {'first_name': 'Lina', 'last_name': 'Shokry'}, {'first_name': 'Ya Hsin', 'last_name': 'Lee'}, {'first_name': 'Ruxandra', 'last_name': 'Schech'}, {'first_name': 'Yasmina', 'last_name': 'Karimjanova'}, {'first_name': 'Lara', 'last_name': 'Biter'}, {'first_name': 'Najah', 'last_name': 'Dawson'}, {'first_name': 'Giulia', 'last_name': 'Morlet'}, {'first_name': 'Matilde', 'last_name': 'Mariani'}, {'first_name': 'Isabella', 'last_name': 'Nunez'}, {'first_name': 'Betina', 'last_name': 'Tokac'}, {'first_name': 'Noa', 'last_name': 'Krznaric'}]
medium
Table matches ( matches.best_of (INT), matches.draw_size (INT), matches.loser_age (FLOAT), matches.loser_entry (TEXT), matches.loser_hand (TEXT), matches.loser_ht (INT), matches.loser_id (INT), matches.loser_ioc (TEXT), matches.loser_name (TEXT), matches.loser_rank (INT), matches.loser_rank_points (INT), matches.loser_seed (INT), matches.match_num (INT), matches.minutes (INT), matches.round (TEXT), matches.score (TEXT), matches.surface (TEXT), matches.tourney_date (DATE), matches.tourney_id (TEXT), matches.tourney_level (TEXT), matches.tourney_name (TEXT), matches.winner_age (FLOAT), matches.winner_entry (TEXT), matches.winner_hand (TEXT), matches.winner_ht (INT), matches.winner_id (INT), matches.winner_ioc (TEXT), matches.winner_name (TEXT), matches.winner_rank (INT), matches.winner_rank_points (INT), matches.winner_seed (INT), matches.year (INT), ) Table players ( players.player_id (INT), players.first_name (TEXT), players.last_name (TEXT), players.hand (TEXT), players.birth_date (DATE), players.country_code (TEXT), ) Table rankings ( rankings.ranking_date (DATE), rankings.ranking (INT), rankings.player_id (INT), rankings.ranking_points (INT), rankings.tours (INT), ) Possible JOINs: matches.loser_id = players.player_id matches.winner_id = players.player_id rankings.player_id = players.player_id
SELECT first_name , last_name FROM players WHERE hand = 'L' ORDER BY birth_date
{ 'players': ['player_id', 'first_name', 'last_name', 'hand', 'birth_date'] }
Table players ( players.player_id (INT), players.first_name (TEXT), players.last_name (TEXT), players.hand (TEXT), players.birth_date (DATE), ) Possible JOINs:
Table players ( players.player_id (INT), players.first_name (TEXT), players.last_name (TEXT), players.hand (TEXT), players.birth_date (DATE), players.country_code (TEXT), ) Possible JOINs:
car_1
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") )
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) /* 2 rows from car_makers table: Id Maker FullName Country 1 amc American Motor Company 1 2 volkswagen Volkswagen 2 */ CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) /* 2 rows from car_names table: MakeId Model Make 1 chevrolet chevrolet chevelle malibu 2 buick buick skylark 320 */ CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) /* 2 rows from cars_data table: Id MPG Cylinders Edispl Horsepower Weight Accelerate Year 1 18 8 307.0 130 3504 12.0 1970 2 15 8 350.0 165 3693 11.5 1970 */ CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) /* 2 rows from continents table: ContId Continent 1 america 2 europe */ CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) /* 2 rows from countries table: CountryId CountryName Continent 1 usa 1 2 germany 2 */ CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") ) /* 2 rows from model_list table: ModelId Maker Model 1 1 amc 2 2 audi */
What are the different models for the cards produced after 1980?
SELECT DISTINCT T1.model FROM MODEL_LIST AS T1 JOIN CAR_NAMES AS T2 ON T1.model = T2.model JOIN CARS_DATA AS T3 ON T2.MakeId = T3.id WHERE T3.year > 1980;
[{'Model': 'plymouth'}, {'Model': 'buick'}, {'Model': 'dodge'}, {'Model': 'chevrolet'}, {'Model': 'toyota'}, {'Model': 'honda'}, {'Model': 'subaru'}, {'Model': 'datsun'}, {'Model': 'mazda'}, {'Model': 'ford'}, {'Model': 'volkswagen'}, {'Model': 'renault'}, {'Model': 'peugeot'}, {'Model': 'saab'}, {'Model': 'volvo'}, {'Model': 'oldsmobile'}, {'Model': 'chrysler'}, {'Model': 'pontiac'}, {'Model': 'amc'}, {'Model': 'mercury'}, {'Model': 'nissan'}]
hard
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_makers.Country = countries.CountryId car_names.Model = model_list.Model cars_data.Id = car_names.MakeId countries.Continent = continents.ContId model_list.Maker = car_makers.Id
SELECT DISTINCT MODEL_LIST.model FROM MODEL_LIST JOIN CAR_NAMES ON MODEL_LIST.model = CAR_NAMES.model JOIN CARS_DATA ON CAR_NAMES.MakeId = CARS_DATA.id WHERE CARS_DATA.year > 1980;
{ 'model_list': ['modelid', 'model'], 'car_names': ['makeid', 'model'], 'cars_data': ['id', 'year'] }
Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.Year (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Model (TEXT), ) Possible JOINs:
Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_names.Model = model_list.Model cars_data.Id = car_names.MakeId model_list.Maker = car_makers.Id
orchestra
CREATE TABLE conductor ( "Conductor_ID" INTEGER, "Name" TEXT, "Age" INTEGER, "Nationality" TEXT, "Year_of_Work" INTEGER, PRIMARY KEY ("Conductor_ID") ) CREATE TABLE orchestra ( "Orchestra_ID" INTEGER, "Orchestra" TEXT, "Conductor_ID" INTEGER, "Record_Company" TEXT, "Year_of_Founded" REAL, "Major_Record_Format" TEXT, PRIMARY KEY ("Orchestra_ID"), FOREIGN KEY("Conductor_ID") REFERENCES conductor ("Conductor_ID") ) CREATE TABLE performance ( "Performance_ID" INTEGER, "Orchestra_ID" INTEGER, "Type" TEXT, "Date" TEXT, "Official_ratings_(millions)" REAL, "Weekly_rank" TEXT, "Share" TEXT, PRIMARY KEY ("Performance_ID"), FOREIGN KEY("Orchestra_ID") REFERENCES orchestra ("Orchestra_ID") ) CREATE TABLE show ( "Show_ID" INTEGER, "Performance_ID" INTEGER, "If_first_show" BOOLEAN, "Result" TEXT, "Attendance" REAL, FOREIGN KEY("Performance_ID") REFERENCES performance ("Performance_ID") )
CREATE TABLE conductor ( "Conductor_ID" INTEGER, "Name" TEXT, "Age" INTEGER, "Nationality" TEXT, "Year_of_Work" INTEGER, PRIMARY KEY ("Conductor_ID") ) /* 2 rows from conductor table: Conductor_ID Name Age Nationality Year_of_Work 1 Antal Doráti 40 USA 10 2 Igor Stravinsky 41 UK 11 */ CREATE TABLE orchestra ( "Orchestra_ID" INTEGER, "Orchestra" TEXT, "Conductor_ID" INTEGER, "Record_Company" TEXT, "Year_of_Founded" REAL, "Major_Record_Format" TEXT, PRIMARY KEY ("Orchestra_ID"), FOREIGN KEY("Conductor_ID") REFERENCES conductor ("Conductor_ID") ) /* 2 rows from orchestra table: Orchestra_ID Orchestra Conductor_ID Record_Company Year_of_Founded Major_Record_Format 1 London Symphony Orchestra 1 Mercury Records 2003.0 CD 2 Columbia Symphony Orchestra 2 Columbia Masterworks 2009.0 CD / LP */ CREATE TABLE performance ( "Performance_ID" INTEGER, "Orchestra_ID" INTEGER, "Type" TEXT, "Date" TEXT, "Official_ratings_(millions)" REAL, "Weekly_rank" TEXT, "Share" TEXT, PRIMARY KEY ("Performance_ID"), FOREIGN KEY("Orchestra_ID") REFERENCES orchestra ("Orchestra_ID") ) /* 2 rows from performance table: Performance_ID Orchestra_ID Type Date Official_ratings_(millions) Weekly_rank Share 1 1 Auditions 1 9 June 5.2 12 22.7% 2 2 Auditions 2 10 June 6.73 8 28.0% */ CREATE TABLE show ( "Show_ID" INTEGER, "Performance_ID" INTEGER, "If_first_show" BOOLEAN, "Result" TEXT, "Attendance" REAL, FOREIGN KEY("Performance_ID") REFERENCES performance ("Performance_ID") ) /* 2 rows from show table: Show_ID Performance_ID If_first_show Result Attendance 1 1 True T 1026.0 2 2 True T 695.0 */
What are the names of conductors who have conducted orchestras founded after the year 2008?
SELECT T1.Name FROM conductor AS T1 JOIN orchestra AS T2 ON T1.Conductor_ID = T2.Conductor_ID WHERE Year_of_Founded > 2008
[{'Name': 'Igor Stravinsky'}]
medium
Table conductor ( conductor.Conductor_ID (INT), conductor.Name (TEXT), conductor.Age (INT), conductor.Nationality (TEXT), conductor.Year_of_Work (INT), ) Table orchestra ( orchestra.Orchestra_ID (INT), orchestra.Orchestra (TEXT), orchestra.Conductor_ID (INT), orchestra.Record_Company (TEXT), orchestra.Year_of_Founded (REAL), orchestra.Major_Record_Format (TEXT), ) Table performance ( performance.Performance_ID (INT), performance.Orchestra_ID (INT), performance.Type (TEXT), performance.Date (TEXT), performance.Official_ratings_(millions) (REAL), performance.Weekly_rank (TEXT), performance.Share (TEXT), ) Table show ( show.Show_ID (INT), show.Performance_ID (INT), show.If_first_show (bool), show.Result (TEXT), show.Attendance (REAL), ) Possible JOINs: orchestra.Conductor_ID = conductor.Conductor_ID performance.Orchestra_ID = orchestra.Orchestra_ID show.Performance_ID = performance.Performance_ID
SELECT conductor.Name FROM conductor JOIN orchestra ON conductor.Conductor_ID = orchestra.Conductor_ID WHERE Year_of_Founded > 2008
{ 'conductor': ['conductor_id', 'name'], 'orchestra': ['orchestra_id', 'orchestra', 'conductor_id', 'year_of_founded'] }
Table conductor ( conductor.Conductor_ID (INT), conductor.Name (TEXT), ) Table orchestra ( orchestra.Orchestra_ID (INT), orchestra.Orchestra (TEXT), orchestra.Conductor_ID (INT), orchestra.Year_of_Founded (REAL), )
Table conductor ( conductor.Conductor_ID (INT), conductor.Name (TEXT), conductor.Age (INT), conductor.Nationality (TEXT), conductor.Year_of_Work (INT), ) Table orchestra ( orchestra.Orchestra_ID (INT), orchestra.Orchestra (TEXT), orchestra.Conductor_ID (INT), orchestra.Record_Company (TEXT), orchestra.Year_of_Founded (REAL), orchestra.Major_Record_Format (TEXT), ) Possible JOINs: orchestra.Conductor_ID = conductor.Conductor_ID
poker_player
CREATE TABLE people ( "People_ID" INTEGER, "Nationality" TEXT, "Name" TEXT, "Birth_Date" TEXT, "Height" REAL, PRIMARY KEY ("People_ID") ) CREATE TABLE poker_player ( "Poker_Player_ID" INTEGER, "People_ID" INTEGER, "Final_Table_Made" REAL, "Best_Finish" REAL, "Money_Rank" REAL, "Earnings" REAL, PRIMARY KEY ("Poker_Player_ID"), FOREIGN KEY("People_ID") REFERENCES people ("People_ID") )
CREATE TABLE people ( "People_ID" INTEGER, "Nationality" TEXT, "Name" TEXT, "Birth_Date" TEXT, "Height" REAL, PRIMARY KEY ("People_ID") ) /* 2 rows from people table: People_ID Nationality Name Birth_Date Height 1 Russia Aleksey Ostapenko May 26, 1986 207.0 2 Bulgaria Teodor Salparov August 16, 1982 182.0 */ CREATE TABLE poker_player ( "Poker_Player_ID" INTEGER, "People_ID" INTEGER, "Final_Table_Made" REAL, "Best_Finish" REAL, "Money_Rank" REAL, "Earnings" REAL, PRIMARY KEY ("Poker_Player_ID"), FOREIGN KEY("People_ID") REFERENCES people ("People_ID") ) /* 2 rows from poker_player table: Poker_Player_ID People_ID Final_Table_Made Best_Finish Money_Rank Earnings 1 1 42.0 1.0 68.0 476090.0 2 2 10.0 2.0 141.0 189233.0 */
How many poker players are there?
SELECT count(*) FROM poker_player
[{'count(*)': 5}]
easy
Table people ( people.People_ID (INT), people.Nationality (TEXT), people.Name (TEXT), people.Birth_Date (TEXT), people.Height (REAL), ) Table poker_player ( poker_player.Poker_Player_ID (INT), poker_player.People_ID (INT), poker_player.Final_Table_Made (REAL), poker_player.Best_Finish (REAL), poker_player.Money_Rank (REAL), poker_player.Earnings (REAL), ) Possible JOINs: poker_player.People_ID = people.People_ID
SELECT count(*) FROM poker_player
{ 'poker_player': ['poker_player_id'] }
Table poker_player ( poker_player.Poker_Player_ID (INT), )
Table poker_player ( poker_player.Poker_Player_ID (INT), poker_player.People_ID (INT), poker_player.Final_Table_Made (REAL), poker_player.Best_Finish (REAL), poker_player.Money_Rank (REAL), poker_player.Earnings (REAL), ) Possible JOINs: poker_player.People_ID = people.People_ID
tvshow
CREATE TABLE "Cartoon" ( id REAL, "Title" TEXT, "Directed_by" TEXT, "Written_by" TEXT, "Original_air_date" TEXT, "Production_code" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) CREATE TABLE "TV_Channel" ( id TEXT, series_name TEXT, "Country" TEXT, "Language" TEXT, "Content" TEXT, "Pixel_aspect_ratio_PAR" TEXT, "Hight_definition_TV" TEXT, "Pay_per_view_PPV" TEXT, "Package_Option" TEXT, PRIMARY KEY (id) ) CREATE TABLE "TV_series" ( id REAL, "Episode" TEXT, "Air_Date" TEXT, "Rating" TEXT, "Share" REAL, "18_49_Rating_Share" TEXT, "Viewers_m" TEXT, "Weekly_Rank" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) )
CREATE TABLE "Cartoon" ( id REAL, "Title" TEXT, "Directed_by" TEXT, "Written_by" TEXT, "Original_air_date" TEXT, "Production_code" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) /* 2 rows from Cartoon table: id Title Directed_by Written_by Original_air_date Production_code Channel 1.0 The Rise of the Blue Beetle! Ben Jones Michael Jelenic November14,2008 101.0 700 2.0 Terror on Dinosaur Island! Brandon Vietti Steven Melching November21,2008 102.0 701 */ CREATE TABLE "TV_Channel" ( id TEXT, series_name TEXT, "Country" TEXT, "Language" TEXT, "Content" TEXT, "Pixel_aspect_ratio_PAR" TEXT, "Hight_definition_TV" TEXT, "Pay_per_view_PPV" TEXT, "Package_Option" TEXT, PRIMARY KEY (id) ) /* 2 rows from TV_Channel table: id series_name Country Language Content Pixel_aspect_ratio_PAR Hight_definition_TV Pay_per_view_PPV Package_Option 700 Sky Radio Italy Italian music 4:3 no no Sky Famiglia 701 Sky Music Italy Italian music 4:3 no no Sky Famiglia */ CREATE TABLE "TV_series" ( id REAL, "Episode" TEXT, "Air_Date" TEXT, "Rating" TEXT, "Share" REAL, "18_49_Rating_Share" TEXT, "Viewers_m" TEXT, "Weekly_Rank" REAL, "Channel" TEXT, PRIMARY KEY (id), FOREIGN KEY("Channel") REFERENCES "TV_Channel" (id) ) /* 2 rows from TV_series table: id Episode Air_Date Rating Share 18_49_Rating_Share Viewers_m Weekly_Rank Channel 1.0 A Love of a Lifetime September 24, 2007 5.8 9.0 3.5/9 9.16 43.0 700 2.0 Friendly Skies October 1, 2007 5.3 9.0 3.2/8 8.23 50.0 701 */
List the title of all Cartoons showed on TV Channel with series name "Sky Radio".
SELECT T2.Title FROM TV_Channel AS T1 JOIN Cartoon AS T2 ON T1.id = T2.Channel WHERE T1.series_name = "Sky Radio";
[{'Title': 'The Rise of the Blue Beetle!'}, {'Title': 'Return of the Fearsome Fangs!'}]
medium
Table Cartoon ( Cartoon.id (REAL), Cartoon.Title (TEXT), Cartoon.Directed_by (TEXT), Cartoon.Written_by (TEXT), Cartoon.Original_air_date (TEXT), Cartoon.Production_code (REAL), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.series_name (TEXT), TV_Channel.Country (TEXT), TV_Channel.Language (TEXT), TV_Channel.Content (TEXT), TV_Channel.Pixel_aspect_ratio_PAR (TEXT), TV_Channel.Hight_definition_TV (TEXT), TV_Channel.Pay_per_view_PPV (TEXT), TV_Channel.Package_Option (TEXT), ) Table TV_series ( TV_series.id (REAL), TV_series.Episode (TEXT), TV_series.Air_Date (TEXT), TV_series.Rating (TEXT), TV_series.Share (REAL), TV_series.18_49_Rating_Share (TEXT), TV_series.Viewers_m (TEXT), TV_series.Weekly_Rank (REAL), TV_series.Channel (TEXT), ) Possible JOINs: Cartoon.Channel = TV_Channel.id TV_series.Channel = TV_Channel.id
SELECT Cartoon.Title FROM TV_Channel JOIN Cartoon ON TV_Channel.id = Cartoon.Channel WHERE TV_Channel.series_name = "Sky Radio";
{ 'tv_channel': ['id', 'series_name'], 'cartoon': ['id', 'title', 'channel'] }
Table Cartoon ( Cartoon.id (REAL), Cartoon.Title (TEXT), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.series_name (TEXT), )
Table Cartoon ( Cartoon.id (REAL), Cartoon.Title (TEXT), Cartoon.Directed_by (TEXT), Cartoon.Written_by (TEXT), Cartoon.Original_air_date (TEXT), Cartoon.Production_code (REAL), Cartoon.Channel (TEXT), ) Table TV_Channel ( TV_Channel.id (TEXT), TV_Channel.series_name (TEXT), TV_Channel.Country (TEXT), TV_Channel.Language (TEXT), TV_Channel.Content (TEXT), TV_Channel.Pixel_aspect_ratio_PAR (TEXT), TV_Channel.Hight_definition_TV (TEXT), TV_Channel.Pay_per_view_PPV (TEXT), TV_Channel.Package_Option (TEXT), ) Possible JOINs: Cartoon.Channel = TV_Channel.id
flight_2
CREATE TABLE airlines ( uid INTEGER, "Airline" TEXT, "Abbreviation" TEXT, "Country" TEXT, PRIMARY KEY (uid) ) CREATE TABLE airports ( "City" TEXT, "AirportCode" TEXT, "AirportName" TEXT, "Country" TEXT, "CountryAbbrev" TEXT, PRIMARY KEY ("AirportCode") ) CREATE TABLE flights ( "Airline" INTEGER, "FlightNo" INTEGER, "SourceAirport" TEXT, "DestAirport" TEXT, PRIMARY KEY ("Airline", "FlightNo"), FOREIGN KEY("SourceAirport") REFERENCES airports ("AirportCode"), FOREIGN KEY("DestAirport") REFERENCES airports ("AirportCode") )
CREATE TABLE airlines ( uid INTEGER, "Airline" TEXT, "Abbreviation" TEXT, "Country" TEXT, PRIMARY KEY (uid) ) /* 2 rows from airlines table: uid Airline Abbreviation Country 1 United Airlines UAL USA 2 US Airways USAir USA */ CREATE TABLE airports ( "City" TEXT, "AirportCode" TEXT, "AirportName" TEXT, "Country" TEXT, "CountryAbbrev" TEXT, PRIMARY KEY ("AirportCode") ) /* 2 rows from airports table: City AirportCode AirportName Country CountryAbbrev Aberdeen APG Phillips AAF United States US Aberdeen ABR Municipal United States US */ CREATE TABLE flights ( "Airline" INTEGER, "FlightNo" INTEGER, "SourceAirport" TEXT, "DestAirport" TEXT, PRIMARY KEY ("Airline", "FlightNo"), FOREIGN KEY("SourceAirport") REFERENCES airports ("AirportCode"), FOREIGN KEY("DestAirport") REFERENCES airports ("AirportCode") ) /* 2 rows from flights table: Airline FlightNo SourceAirport DestAirport 1 28 APG ASY 1 29 ASY APG */
What are flight numbers of flights departing from City "Aberdeen "?
SELECT T1.FlightNo FROM FLIGHTS AS T1 JOIN AIRPORTS AS T2 ON T1.SourceAirport = T2.AirportCode WHERE T2.City = "Aberdeen"
[{'Nenhum': 'Nenhum resultado encontrado'}]
medium
Table airlines ( airlines.uid (INTEGER), airlines.Airline (TEXT), airlines.Abbreviation (TEXT), airlines.Country (TEXT), ) Table airports ( airports.City (TEXT), airports.AirportCode (TEXT), airports.AirportName (TEXT), airports.Country (TEXT), airports.CountryAbbrev (TEXT), ) Table flights ( flights.Airline (INTEGER), flights.FlightNo (INTEGER), flights.SourceAirport (TEXT), flights.DestAirport (TEXT), ) Possible JOINs: flights.SourceAirport = airports.AirportCode flights.DestAirport = airports.AirportCode
SELECT FLIGHTS.FlightNo FROM FLIGHTS JOIN AIRPORTS ON FLIGHTS.SourceAirport = AIRPORTS.AirportCode WHERE AIRPORTS.City = "Aberdeen"
{ 'flights': ['airline', 'flightno', 'sourceairport'], 'airports': ['city', 'airportcode'] }
Table airports ( airports.City (TEXT), airports.AirportCode (TEXT), ) Table flights ( flights.Airline (INTEGER), flights.FlightNo (INTEGER), flights.SourceAirport (TEXT), )
Table airports ( airports.City (TEXT), airports.AirportCode (TEXT), airports.AirportName (TEXT), airports.Country (TEXT), airports.CountryAbbrev (TEXT), ) Table flights ( flights.Airline (INTEGER), flights.FlightNo (INTEGER), flights.SourceAirport (TEXT), flights.DestAirport (TEXT), ) Possible JOINs: flights.SourceAirport = airports.AirportCode flights.DestAirport = airports.AirportCode
wta_1
CREATE TABLE players( "player_id" INT PRIMARY KEY, "first_name" TEXT, "last_name" TEXT, "hand" TEXT, "birth_date" DATE, "country_code" TEXT ) /* 0 rows from players table: player_id first_name last_name hand birth_date country_code */ CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ) /* 0 rows from matches table: best_of draw_size loser_age loser_entry loser_hand loser_ht loser_id loser_ioc loser_name loser_rank loser_rank_points loser_seed match_num minutes round score surface tourney_date tourney_id tourney_level tourney_name winner_age winner_entry winner_hand winner_ht winner_id winner_ioc winner_name winner_rank winner_rank_points winner_seed year */ CREATE TABLE rankings("ranking_date" DATE,"ranking" INT,"player_id" INT,"ranking_points" INT,"tours" INT,FOREIGN KEY(player_id) REFERENCES players(player_id)) /* 0 rows from rankings table: ranking_date ranking player_id ranking_points tours */
CREATE TABLE players( "player_id" INT PRIMARY KEY, "first_name" TEXT, "last_name" TEXT, "hand" TEXT, "birth_date" DATE, "country_code" TEXT ) /* 2 rows from players table: player_id first_name last_name hand birth_date country_code 200001 Martina Hingis R 19800930 SUI 200002 Mirjana Lucic R 19820309 CRO */ CREATE TABLE matches( "best_of" INT, "draw_size" INT, "loser_age" FLOAT, "loser_entry" TEXT, "loser_hand" TEXT, "loser_ht" INT, "loser_id" INT, "loser_ioc" TEXT, "loser_name" TEXT, "loser_rank" INT, "loser_rank_points" INT, "loser_seed" INT, "match_num" INT, "minutes" INT, "round" TEXT, "score" TEXT, "surface" TEXT, "tourney_date" DATE, "tourney_id" TEXT, "tourney_level" TEXT, "tourney_name" TEXT, "winner_age" FLOAT, "winner_entry" TEXT, "winner_hand" TEXT, "winner_ht" INT, "winner_id" INT, "winner_ioc" TEXT, "winner_name" TEXT, "winner_rank" INT, "winner_rank_points" INT, "winner_seed" INT, "year" INT, FOREIGN KEY(loser_id) REFERENCES players(player_id), FOREIGN KEY(winner_id) REFERENCES players(player_id) ) /* 2 rows from matches table: best_of draw_size loser_age loser_entry loser_hand loser_ht loser_id loser_ioc loser_name loser_rank loser_rank_points loser_seed match_num minutes round score surface tourney_date tourney_id tourney_level tourney_name winner_age winner_entry winner_hand winner_ht winner_id winner_ioc winner_name winner_rank winner_rank_points winner_seed year 3 4 24.626967830300003 R 170 201474 POL Agnieszka Radwanska 4 5890 3 297 82 RR 6-2 6-4 Hard 20131021 2013-W-WT-TUR-01A-2013 W WTA Championships 32.0684462697 R 175 200033 USA Serena Williams 1 12040 1 2013 3 4 23.6221765914 L 183 201520 CZE Petra Kvitova 6 4370 5 296 72 RR 6-2 6-3 Hard 20131021 2013-W-WT-TUR-01A-2013 W WTA Championships 32.0684462697 R 175 200033 USA Serena Williams 1 12040 1 2013 */ CREATE TABLE rankings("ranking_date" DATE,"ranking" INT,"player_id" INT,"ranking_points" INT,"tours" INT,FOREIGN KEY(player_id) REFERENCES players(player_id)) /* 2 rows from rankings table: ranking_date ranking player_id ranking_points tours 20000101 3 200748 4378 13 20000101 4 200033 3021 15 */
Find the first name and country code of the oldest player.
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
[{'first_name': 'Thelma', 'country_code': 'AUS'}]
medium
Table matches ( matches.best_of (INT), matches.draw_size (INT), matches.loser_age (FLOAT), matches.loser_entry (TEXT), matches.loser_hand (TEXT), matches.loser_ht (INT), matches.loser_id (INT), matches.loser_ioc (TEXT), matches.loser_name (TEXT), matches.loser_rank (INT), matches.loser_rank_points (INT), matches.loser_seed (INT), matches.match_num (INT), matches.minutes (INT), matches.round (TEXT), matches.score (TEXT), matches.surface (TEXT), matches.tourney_date (DATE), matches.tourney_id (TEXT), matches.tourney_level (TEXT), matches.tourney_name (TEXT), matches.winner_age (FLOAT), matches.winner_entry (TEXT), matches.winner_hand (TEXT), matches.winner_ht (INT), matches.winner_id (INT), matches.winner_ioc (TEXT), matches.winner_name (TEXT), matches.winner_rank (INT), matches.winner_rank_points (INT), matches.winner_seed (INT), matches.year (INT), ) Table players ( players.player_id (INT), players.first_name (TEXT), players.last_name (TEXT), players.hand (TEXT), players.birth_date (DATE), players.country_code (TEXT), ) Table rankings ( rankings.ranking_date (DATE), rankings.ranking (INT), rankings.player_id (INT), rankings.ranking_points (INT), rankings.tours (INT), ) Possible JOINs: matches.loser_id = players.player_id matches.winner_id = players.player_id rankings.player_id = players.player_id
SELECT first_name , country_code FROM players ORDER BY birth_date LIMIT 1
{ 'players': ['player_id', 'first_name', 'birth_date', 'country_code'] }
Table players ( players.player_id (INT), players.first_name (TEXT), players.birth_date (DATE), players.country_code (TEXT), ) Possible JOINs:
Table players ( players.player_id (INT), players.first_name (TEXT), players.last_name (TEXT), players.hand (TEXT), players.birth_date (DATE), players.country_code (TEXT), ) Possible JOINs:
dog_kennels
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) )
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) /* 2 rows from Breeds table: breed_code breed_name ESK Eskimo HUS Husky */ CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) /* 2 rows from Charges table: charge_id charge_type charge_amount 1 Daily Accommodation 98.0000 2 Drugs 322.0000 */ CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) /* 2 rows from Dogs table: dog_id owner_id abandoned_yn breed_code size_code name age date_of_birth gender weight date_arrived date_adopted date_departed 1 3 1 ESK LGE Kacey 6 2012-01-27 05:11:53 1 7.57 2017-09-08 20:10:13 2018-03-06 16:32:11 2018-03-25 06:58:44 2 11 0 BUL LGE Hipolito 9 2013-02-13 05:15:21 0 1.72 2017-12-22 05:02:02 2018-03-25 08:12:51 2018-03-25 02:11:32 */ CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) /* 2 rows from Owners table: owner_id first_name last_name street city state zip_code email_address home_phone cell_number 1 Nora Haley 0647 Hintz Village Apt. 024 Lake Tia Wisconsin 93165 [email protected] 1-682-845-0116x63235 478.978.0729 2 Melisa DuBuque 1204 Mae Highway Apt. 107 Port Reannamouth Virginia 45244 [email protected] (799)563-0260x454 (722)768-5439x484 */ CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) /* 2 rows from Professionals table: professional_id role_code first_name street city state zip_code last_name email_address home_phone cell_number 1 Employee Taryn 6915 Oberbrunner Point Suite 491 Gleasonville, LA West Heidi Indiana 06646 Braun [email protected] +71(6)2898266914 (275)939-2435x80863 2 Employee Jayson 88665 Terence Lodge Apt. 904 Corneliusfort, NC 194 North Odellfurt Connecticut 43129 Ullrich [email protected] +02(1)0259033559 889-940-2676 */ CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) /* 2 rows from Sizes table: size_code size_description SML Small MED Medium */ CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) /* 2 rows from Treatment_Types table: treatment_type_code treatment_type_description EXAM Physical examination VAC Vaccination */ CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) ) /* 2 rows from Treatments table: treatment_id dog_id professional_id treatment_type_code date_of_treatment cost_of_treatment 1 14 9 WALK 2018-03-19 04:39:54 567.0000 2 4 10 VAC 2018-03-15 20:25:34 147.0000 */
How many professionals did not operate any treatment on dogs?
SELECT count(*) FROM Professionals WHERE professional_id NOT IN ( SELECT professional_id FROM Treatments )
[{'count(*)': 7}]
extra
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Charges ( Charges.charge_id (INTEGER), Charges.charge_type (VARCHAR(10)), Charges.charge_amount (DECIMAL(19,4)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Table Owners ( Owners.owner_id (INTEGER), Owners.first_name (VARCHAR(50)), Owners.last_name (VARCHAR(50)), Owners.street (VARCHAR(50)), Owners.city (VARCHAR(50)), Owners.state (VARCHAR(20)), Owners.zip_code (VARCHAR(20)), Owners.email_address (VARCHAR(50)), Owners.home_phone (VARCHAR(20)), Owners.cell_number (VARCHAR(20)), ) Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Sizes ( Sizes.size_code (VARCHAR(10)), Sizes.size_description (VARCHAR(80)), ) Table Treatment_Types ( Treatment_Types.treatment_type_code (VARCHAR(10)), Treatment_Types.treatment_type_description (VARCHAR(80)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
SELECT count(*) FROM Professionals WHERE professional_id NOT IN ( SELECT professional_id FROM Treatments )
{ 'professionals': ['professional_id'], 'treatments': ['treatment_id', 'professional_id'] }
Table Professionals ( Professionals.professional_id (INTEGER), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.professional_id (INTEGER), ) Possible JOINs: Treatments.professional_id = Professionals.professional_id
Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
flight_2
CREATE TABLE airlines ( uid INTEGER, "Airline" TEXT, "Abbreviation" TEXT, "Country" TEXT, PRIMARY KEY (uid) ) CREATE TABLE airports ( "City" TEXT, "AirportCode" TEXT, "AirportName" TEXT, "Country" TEXT, "CountryAbbrev" TEXT, PRIMARY KEY ("AirportCode") ) CREATE TABLE flights ( "Airline" INTEGER, "FlightNo" INTEGER, "SourceAirport" TEXT, "DestAirport" TEXT, PRIMARY KEY ("Airline", "FlightNo"), FOREIGN KEY("SourceAirport") REFERENCES airports ("AirportCode"), FOREIGN KEY("DestAirport") REFERENCES airports ("AirportCode") )
CREATE TABLE airlines ( uid INTEGER, "Airline" TEXT, "Abbreviation" TEXT, "Country" TEXT, PRIMARY KEY (uid) ) /* 2 rows from airlines table: uid Airline Abbreviation Country 1 United Airlines UAL USA 2 US Airways USAir USA */ CREATE TABLE airports ( "City" TEXT, "AirportCode" TEXT, "AirportName" TEXT, "Country" TEXT, "CountryAbbrev" TEXT, PRIMARY KEY ("AirportCode") ) /* 2 rows from airports table: City AirportCode AirportName Country CountryAbbrev Aberdeen APG Phillips AAF United States US Aberdeen ABR Municipal United States US */ CREATE TABLE flights ( "Airline" INTEGER, "FlightNo" INTEGER, "SourceAirport" TEXT, "DestAirport" TEXT, PRIMARY KEY ("Airline", "FlightNo"), FOREIGN KEY("SourceAirport") REFERENCES airports ("AirportCode"), FOREIGN KEY("DestAirport") REFERENCES airports ("AirportCode") ) /* 2 rows from flights table: Airline FlightNo SourceAirport DestAirport 1 28 APG ASY 1 29 ASY APG */
What is the airport name for airport 'AKO'?
SELECT AirportName FROM AIRPORTS WHERE AirportCode = "AKO"
[{'AirportName': 'Colorado Plains Regional Airport '}]
easy
Table airlines ( airlines.uid (INTEGER), airlines.Airline (TEXT), airlines.Abbreviation (TEXT), airlines.Country (TEXT), ) Table airports ( airports.City (TEXT), airports.AirportCode (TEXT), airports.AirportName (TEXT), airports.Country (TEXT), airports.CountryAbbrev (TEXT), ) Table flights ( flights.Airline (INTEGER), flights.FlightNo (INTEGER), flights.SourceAirport (TEXT), flights.DestAirport (TEXT), ) Possible JOINs: flights.SourceAirport = airports.AirportCode flights.DestAirport = airports.AirportCode
SELECT AirportName FROM AIRPORTS WHERE AirportCode = "AKO"
{ 'airports': ['airportcode', 'airportname'] }
Table airports ( airports.AirportCode (TEXT), airports.AirportName (TEXT), ) Possible JOINs:
Table airports ( airports.City (TEXT), airports.AirportCode (TEXT), airports.AirportName (TEXT), airports.Country (TEXT), airports.CountryAbbrev (TEXT), ) Possible JOINs:
world_1
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") )
CREATE TABLE city ( "ID" INTEGER NOT NULL, "Name" CHAR(35) DEFAULT '' NOT NULL, "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "District" CHAR(20) DEFAULT '' NOT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, PRIMARY KEY ("ID"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from city table: ID Name CountryCode District Population 1 Kabul AFG Kabol 1780000 2 Qandahar AFG Qandahar 237500 */ CREATE TABLE country ( "Code" CHAR(3) DEFAULT '' NOT NULL, "Name" CHAR(52) DEFAULT '' NOT NULL, "Continent" TEXT DEFAULT 'Asia' NOT NULL, "Region" CHAR(26) DEFAULT '' NOT NULL, "SurfaceArea" FLOAT DEFAULT '0.00' NOT NULL, "IndepYear" INTEGER DEFAULT NULL, "Population" INTEGER DEFAULT '0' NOT NULL, "LifeExpectancy" FLOAT DEFAULT NULL, "GNP" FLOAT DEFAULT NULL, "GNPOld" FLOAT DEFAULT NULL, "LocalName" CHAR(45) DEFAULT '' NOT NULL, "GovernmentForm" CHAR(45) DEFAULT '' NOT NULL, "HeadOfState" CHAR(60) DEFAULT NULL, "Capital" INTEGER DEFAULT NULL, "Code2" CHAR(2) DEFAULT '' NOT NULL, PRIMARY KEY ("Code") ) /* 2 rows from country table: Code Name Continent Region SurfaceArea IndepYear Population LifeExpectancy GNP GNPOld LocalName GovernmentForm HeadOfState Capital Code2 ABW Aruba North America Caribbean 193.0000000000 None 103000 78.4000000000 828.0000000000 793.0000000000 Aruba Nonmetropolitan Territory of The Netherlands Beatrix 129 AW AFG Afghanistan Asia Southern and Central Asia 652090.0000000000 1919 22720000 45.9000000000 5976.0000000000 None Afganistan/Afqanestan Islamic Emirate Mohammad Omar 1 AF */ CREATE TABLE countrylanguage ( "CountryCode" CHAR(3) DEFAULT '' NOT NULL, "Language" CHAR(30) DEFAULT '' NOT NULL, "IsOfficial" TEXT DEFAULT 'F' NOT NULL, "Percentage" FLOAT DEFAULT '0.0' NOT NULL, PRIMARY KEY ("CountryCode", "Language"), FOREIGN KEY("CountryCode") REFERENCES country ("Code") ) /* 2 rows from countrylanguage table: CountryCode Language IsOfficial Percentage ABW Dutch T 5.3000000000 ABW English F 9.5000000000 */
Which continent is Anguilla in?
SELECT Continent FROM country WHERE Name = "Anguilla"
[{'Continent': 'North America'}]
easy
Table city ( city.ID (INTEGER), city.Name (char(35)), city.CountryCode (char(3)), city.District (char(20)), city.Population (INTEGER), ) Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Table countrylanguage ( countrylanguage.CountryCode (char(3)), countrylanguage.Language (char(30)), countrylanguage.IsOfficial (TEXT), countrylanguage.Percentage (float(4,1)), ) Possible JOINs: city.CountryCode = country.Code countrylanguage.CountryCode = country.Code
SELECT Continent FROM country WHERE Name = "Anguilla"
{ 'country': ['code', 'name', 'continent'] }
Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), ) Possible JOINs:
Table country ( country.Code (char(3)), country.Name (char(52)), country.Continent (TEXT), country.Region (char(26)), country.SurfaceArea (float(10,2)), country.IndepYear (INTEGER), country.Population (INTEGER), country.LifeExpectancy (float(3,1)), country.GNP (float(10,2)), country.GNPOld (float(10,2)), country.LocalName (char(45)), country.GovernmentForm (char(45)), country.HeadOfState (char(60)), country.Capital (INTEGER), country.Code2 (char(2)), ) Possible JOINs:
cre_Doc_Template_Mgt
CREATE TABLE "Documents" ( "Document_ID" INTEGER NOT NULL, "Template_ID" INTEGER, "Document_Name" VARCHAR(255), "Document_Description" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Document_ID"), FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID") ) CREATE TABLE "Paragraphs" ( "Paragraph_ID" INTEGER NOT NULL, "Document_ID" INTEGER NOT NULL, "Paragraph_Text" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Paragraph_ID"), FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID") ) CREATE TABLE "Ref_Template_Types" ( "Template_Type_Code" CHAR(15) NOT NULL, "Template_Type_Description" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_Type_Code") ) CREATE TABLE "Templates" ( "Template_ID" INTEGER NOT NULL, "Version_Number" INTEGER NOT NULL, "Template_Type_Code" CHAR(15) NOT NULL, "Date_Effective_From" DATETIME, "Date_Effective_To" DATETIME, "Template_Details" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_ID"), FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code") )
CREATE TABLE "Documents" ( "Document_ID" INTEGER NOT NULL, "Template_ID" INTEGER, "Document_Name" VARCHAR(255), "Document_Description" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Document_ID"), FOREIGN KEY("Template_ID") REFERENCES "Templates" ("Template_ID") ) /* 2 rows from Documents table: Document_ID Template_ID Document_Name Document_Description Other_Details 0 7 Introduction of OS n None 1 25 Understanding DB y None */ CREATE TABLE "Paragraphs" ( "Paragraph_ID" INTEGER NOT NULL, "Document_ID" INTEGER NOT NULL, "Paragraph_Text" VARCHAR(255), "Other_Details" VARCHAR(255), PRIMARY KEY ("Paragraph_ID"), FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID") ) /* 2 rows from Paragraphs table: Paragraph_ID Document_ID Paragraph_Text Other_Details 7 2394 Korea None 9 3 Somalia None */ CREATE TABLE "Ref_Template_Types" ( "Template_Type_Code" CHAR(15) NOT NULL, "Template_Type_Description" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_Type_Code") ) /* 2 rows from Ref_Template_Types table: Template_Type_Code Template_Type_Description PPT Presentation CV CV */ CREATE TABLE "Templates" ( "Template_ID" INTEGER NOT NULL, "Version_Number" INTEGER NOT NULL, "Template_Type_Code" CHAR(15) NOT NULL, "Date_Effective_From" DATETIME, "Date_Effective_To" DATETIME, "Template_Details" VARCHAR(255) NOT NULL, PRIMARY KEY ("Template_ID"), FOREIGN KEY("Template_Type_Code") REFERENCES "Ref_Template_Types" ("Template_Type_Code") ) /* 2 rows from Templates table: Template_ID Version_Number Template_Type_Code Date_Effective_From Date_Effective_To Template_Details 0 5 PP 2005-11-12 07:09:48 2008-01-05 14:19:28 1 9 PP 2010-09-24 01:15:11 1999-07-08 03:31:04 */
Show ids for all templates that are used by more than one document.
SELECT template_id FROM Documents GROUP BY template_id HAVING count(*) > 1
[{'Template_ID': 11}, {'Template_ID': 14}, {'Template_ID': 25}]
easy
Table Documents ( Documents.Document_ID (INTEGER), Documents.Template_ID (INTEGER), Documents.Document_Name (VARCHAR(255)), Documents.Document_Description (VARCHAR(255)), Documents.Other_Details (VARCHAR(255)), ) Table Paragraphs ( Paragraphs.Paragraph_ID (INTEGER), Paragraphs.Document_ID (INTEGER), Paragraphs.Paragraph_Text (VARCHAR(255)), Paragraphs.Other_Details (VARCHAR(255)), ) Table Ref_Template_Types ( Ref_Template_Types.Template_Type_Code (CHAR(15)), Ref_Template_Types.Template_Type_Description (VARCHAR(255)), ) Table Templates ( Templates.Template_ID (INTEGER), Templates.Version_Number (INTEGER), Templates.Template_Type_Code (CHAR(15)), Templates.Date_Effective_From (DATETIME), Templates.Date_Effective_To (DATETIME), Templates.Template_Details (VARCHAR(255)), ) Possible JOINs: Documents.Template_ID = Templates.Template_ID Paragraphs.Document_ID = Documents.Document_ID Templates.Template_Type_Code = Ref_Template_Types.Template_Type_Code
SELECT template_id FROM Documents GROUP BY template_id HAVING count(*) > 1
{ 'documents': ['document_id', 'template_id'] }
Table Documents ( Documents.Document_ID (INTEGER), Documents.Template_ID (INTEGER), )
Table Documents ( Documents.Document_ID (INTEGER), Documents.Template_ID (INTEGER), Documents.Document_Name (VARCHAR(255)), Documents.Document_Description (VARCHAR(255)), Documents.Other_Details (VARCHAR(255)), ) Possible JOINs: Documents.Template_ID = Templates.Template_ID
dog_kennels
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) )
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) /* 2 rows from Breeds table: breed_code breed_name ESK Eskimo HUS Husky */ CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) /* 2 rows from Charges table: charge_id charge_type charge_amount 1 Daily Accommodation 98.0000 2 Drugs 322.0000 */ CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) /* 2 rows from Dogs table: dog_id owner_id abandoned_yn breed_code size_code name age date_of_birth gender weight date_arrived date_adopted date_departed 1 3 1 ESK LGE Kacey 6 2012-01-27 05:11:53 1 7.57 2017-09-08 20:10:13 2018-03-06 16:32:11 2018-03-25 06:58:44 2 11 0 BUL LGE Hipolito 9 2013-02-13 05:15:21 0 1.72 2017-12-22 05:02:02 2018-03-25 08:12:51 2018-03-25 02:11:32 */ CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) /* 2 rows from Owners table: owner_id first_name last_name street city state zip_code email_address home_phone cell_number 1 Nora Haley 0647 Hintz Village Apt. 024 Lake Tia Wisconsin 93165 [email protected] 1-682-845-0116x63235 478.978.0729 2 Melisa DuBuque 1204 Mae Highway Apt. 107 Port Reannamouth Virginia 45244 [email protected] (799)563-0260x454 (722)768-5439x484 */ CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) /* 2 rows from Professionals table: professional_id role_code first_name street city state zip_code last_name email_address home_phone cell_number 1 Employee Taryn 6915 Oberbrunner Point Suite 491 Gleasonville, LA West Heidi Indiana 06646 Braun [email protected] +71(6)2898266914 (275)939-2435x80863 2 Employee Jayson 88665 Terence Lodge Apt. 904 Corneliusfort, NC 194 North Odellfurt Connecticut 43129 Ullrich [email protected] +02(1)0259033559 889-940-2676 */ CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) /* 2 rows from Sizes table: size_code size_description SML Small MED Medium */ CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) /* 2 rows from Treatment_Types table: treatment_type_code treatment_type_description EXAM Physical examination VAC Vaccination */ CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) ) /* 2 rows from Treatments table: treatment_id dog_id professional_id treatment_type_code date_of_treatment cost_of_treatment 1 14 9 WALK 2018-03-19 04:39:54 567.0000 2 4 10 VAC 2018-03-15 20:25:34 147.0000 */
Which breed do the most dogs have? Give me the breed name.
SELECT T1.breed_name FROM Breeds AS T1 JOIN Dogs AS T2 ON T1.breed_code = T2.breed_code GROUP BY T1.breed_name ORDER BY count(*) DESC LIMIT 1
[{'breed_name': 'Bulldog'}]
extra
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Charges ( Charges.charge_id (INTEGER), Charges.charge_type (VARCHAR(10)), Charges.charge_amount (DECIMAL(19,4)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Table Owners ( Owners.owner_id (INTEGER), Owners.first_name (VARCHAR(50)), Owners.last_name (VARCHAR(50)), Owners.street (VARCHAR(50)), Owners.city (VARCHAR(50)), Owners.state (VARCHAR(20)), Owners.zip_code (VARCHAR(20)), Owners.email_address (VARCHAR(50)), Owners.home_phone (VARCHAR(20)), Owners.cell_number (VARCHAR(20)), ) Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Sizes ( Sizes.size_code (VARCHAR(10)), Sizes.size_description (VARCHAR(80)), ) Table Treatment_Types ( Treatment_Types.treatment_type_code (VARCHAR(10)), Treatment_Types.treatment_type_description (VARCHAR(80)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
SELECT Breeds.breed_name FROM Breeds JOIN Dogs ON Breeds.breed_code = Dogs.breed_code GROUP BY Breeds.breed_name ORDER BY count(*) DESC LIMIT 1
{ 'breeds': ['breed_code', 'breed_name'], 'dogs': ['dog_id', 'breed_code'] }
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.breed_code (VARCHAR(10)), ) Possible JOINs: Dogs.breed_code = Breeds.breed_code
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code
car_1
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") )
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) /* 2 rows from car_makers table: Id Maker FullName Country 1 amc American Motor Company 1 2 volkswagen Volkswagen 2 */ CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) /* 2 rows from car_names table: MakeId Model Make 1 chevrolet chevrolet chevelle malibu 2 buick buick skylark 320 */ CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) /* 2 rows from cars_data table: Id MPG Cylinders Edispl Horsepower Weight Accelerate Year 1 18 8 307.0 130 3504 12.0 1970 2 15 8 350.0 165 3693 11.5 1970 */ CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) /* 2 rows from continents table: ContId Continent 1 america 2 europe */ CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) /* 2 rows from countries table: CountryId CountryName Continent 1 usa 1 2 germany 2 */ CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") ) /* 2 rows from model_list table: ModelId Maker Model 1 1 amc 2 2 audi */
What is the number of cars with more than 4 cylinders?
SELECT count(*) FROM CARS_DATA WHERE Cylinders > 4;
[{'count(*)': 195}]
easy
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_makers.Country = countries.CountryId car_names.Model = model_list.Model cars_data.Id = car_names.MakeId countries.Continent = continents.ContId model_list.Maker = car_makers.Id
SELECT count(*) FROM CARS_DATA WHERE Cylinders > 4;
{ 'cars_data': ['id', 'cylinders'] }
Table cars_data ( cars_data.Id (INTEGER), cars_data.Cylinders (INTEGER), )
Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Possible JOINs: cars_data.Id = car_names.MakeId
car_1
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") )
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) /* 2 rows from car_makers table: Id Maker FullName Country 1 amc American Motor Company 1 2 volkswagen Volkswagen 2 */ CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) /* 2 rows from car_names table: MakeId Model Make 1 chevrolet chevrolet chevelle malibu 2 buick buick skylark 320 */ CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) /* 2 rows from cars_data table: Id MPG Cylinders Edispl Horsepower Weight Accelerate Year 1 18 8 307.0 130 3504 12.0 1970 2 15 8 350.0 165 3693 11.5 1970 */ CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) /* 2 rows from continents table: ContId Continent 1 america 2 europe */ CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) /* 2 rows from countries table: CountryId CountryName Continent 1 usa 1 2 germany 2 */ CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") ) /* 2 rows from model_list table: ModelId Maker Model 1 1 amc 2 2 audi */
What is the model of the car with the smallest amount of horsepower?
SELECT T1.Model FROM CAR_NAMES AS T1 JOIN CARS_DATA AS T2 ON T1.MakeId = T2.Id ORDER BY T2.horsepower ASC LIMIT 1;
[{'Model': 'amc'}]
hard
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_makers.Country = countries.CountryId car_names.Model = model_list.Model cars_data.Id = car_names.MakeId countries.Continent = continents.ContId model_list.Maker = car_makers.Id
SELECT CAR_NAMES.Model FROM CAR_NAMES JOIN CARS_DATA ON CAR_NAMES.MakeId = CARS_DATA.Id ORDER BY CARS_DATA.horsepower ASC LIMIT 1;
{ 'car_names': ['makeid', 'model'], 'cars_data': ['id', 'horsepower'] }
Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.Horsepower (TEXT), ) Possible JOINs:
Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Possible JOINs: car_names.Model = model_list.Model cars_data.Id = car_names.MakeId
dog_kennels
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) )
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) /* 2 rows from Breeds table: breed_code breed_name ESK Eskimo HUS Husky */ CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) /* 2 rows from Charges table: charge_id charge_type charge_amount 1 Daily Accommodation 98.0000 2 Drugs 322.0000 */ CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) /* 2 rows from Dogs table: dog_id owner_id abandoned_yn breed_code size_code name age date_of_birth gender weight date_arrived date_adopted date_departed 1 3 1 ESK LGE Kacey 6 2012-01-27 05:11:53 1 7.57 2017-09-08 20:10:13 2018-03-06 16:32:11 2018-03-25 06:58:44 2 11 0 BUL LGE Hipolito 9 2013-02-13 05:15:21 0 1.72 2017-12-22 05:02:02 2018-03-25 08:12:51 2018-03-25 02:11:32 */ CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) /* 2 rows from Owners table: owner_id first_name last_name street city state zip_code email_address home_phone cell_number 1 Nora Haley 0647 Hintz Village Apt. 024 Lake Tia Wisconsin 93165 [email protected] 1-682-845-0116x63235 478.978.0729 2 Melisa DuBuque 1204 Mae Highway Apt. 107 Port Reannamouth Virginia 45244 [email protected] (799)563-0260x454 (722)768-5439x484 */ CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) /* 2 rows from Professionals table: professional_id role_code first_name street city state zip_code last_name email_address home_phone cell_number 1 Employee Taryn 6915 Oberbrunner Point Suite 491 Gleasonville, LA West Heidi Indiana 06646 Braun [email protected] +71(6)2898266914 (275)939-2435x80863 2 Employee Jayson 88665 Terence Lodge Apt. 904 Corneliusfort, NC 194 North Odellfurt Connecticut 43129 Ullrich [email protected] +02(1)0259033559 889-940-2676 */ CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) /* 2 rows from Sizes table: size_code size_description SML Small MED Medium */ CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) /* 2 rows from Treatment_Types table: treatment_type_code treatment_type_description EXAM Physical examination VAC Vaccination */ CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) ) /* 2 rows from Treatments table: treatment_id dog_id professional_id treatment_type_code date_of_treatment cost_of_treatment 1 14 9 WALK 2018-03-19 04:39:54 567.0000 2 4 10 VAC 2018-03-15 20:25:34 147.0000 */
Find the distinct breed type and size type combinations for dogs.
SELECT DISTINCT breed_code , size_code FROM dogs
[{'breed_code': 'ESK', 'size_code': 'LGE'}, {'breed_code': 'BUL', 'size_code': 'LGE'}, {'breed_code': 'BUL', 'size_code': 'MED'}, {'breed_code': 'HUS', 'size_code': 'MED'}, {'breed_code': 'ESK', 'size_code': 'SML'}, {'breed_code': 'HUS', 'size_code': 'SML'}, {'breed_code': 'ESK', 'size_code': 'MED'}]
medium
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Charges ( Charges.charge_id (INTEGER), Charges.charge_type (VARCHAR(10)), Charges.charge_amount (DECIMAL(19,4)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Table Owners ( Owners.owner_id (INTEGER), Owners.first_name (VARCHAR(50)), Owners.last_name (VARCHAR(50)), Owners.street (VARCHAR(50)), Owners.city (VARCHAR(50)), Owners.state (VARCHAR(20)), Owners.zip_code (VARCHAR(20)), Owners.email_address (VARCHAR(50)), Owners.home_phone (VARCHAR(20)), Owners.cell_number (VARCHAR(20)), ) Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Sizes ( Sizes.size_code (VARCHAR(10)), Sizes.size_description (VARCHAR(80)), ) Table Treatment_Types ( Treatment_Types.treatment_type_code (VARCHAR(10)), Treatment_Types.treatment_type_description (VARCHAR(80)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
SELECT DISTINCT breed_code , size_code FROM dogs
{ 'dogs': ['dog_id', 'breed_code', 'size_code'] }
Table Dogs ( Dogs.dog_id (INTEGER), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), )
Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code
employee_hire_evaluation
CREATE TABLE employee ( "Employee_ID" INTEGER, "Name" TEXT, "Age" INTEGER, "City" TEXT, PRIMARY KEY ("Employee_ID") ) CREATE TABLE evaluation ( "Employee_ID" TEXT, "Year_awarded" TEXT, "Bonus" REAL, PRIMARY KEY ("Employee_ID", "Year_awarded"), FOREIGN KEY("Employee_ID") REFERENCES employee ("Employee_ID") ) CREATE TABLE hiring ( "Shop_ID" INTEGER, "Employee_ID" INTEGER, "Start_from" TEXT, "Is_full_time" BOOLEAN, PRIMARY KEY ("Employee_ID"), FOREIGN KEY("Employee_ID") REFERENCES employee ("Employee_ID"), FOREIGN KEY("Shop_ID") REFERENCES shop ("Shop_ID") ) CREATE TABLE shop ( "Shop_ID" INTEGER, "Name" TEXT, "Location" TEXT, "District" TEXT, "Number_products" INTEGER, "Manager_name" TEXT, PRIMARY KEY ("Shop_ID") )
CREATE TABLE employee ( "Employee_ID" INTEGER, "Name" TEXT, "Age" INTEGER, "City" TEXT, PRIMARY KEY ("Employee_ID") ) /* 2 rows from employee table: Employee_ID Name Age City 1 George Chuter 23 Bristol 2 Lee Mears 29 Bath */ CREATE TABLE evaluation ( "Employee_ID" TEXT, "Year_awarded" TEXT, "Bonus" REAL, PRIMARY KEY ("Employee_ID", "Year_awarded"), FOREIGN KEY("Employee_ID") REFERENCES employee ("Employee_ID") ) /* 2 rows from evaluation table: Employee_ID Year_awarded Bonus 1 2011 3000.0 2 2015 3200.0 */ CREATE TABLE hiring ( "Shop_ID" INTEGER, "Employee_ID" INTEGER, "Start_from" TEXT, "Is_full_time" BOOLEAN, PRIMARY KEY ("Employee_ID"), FOREIGN KEY("Employee_ID") REFERENCES employee ("Employee_ID"), FOREIGN KEY("Shop_ID") REFERENCES shop ("Shop_ID") ) /* 2 rows from hiring table: Shop_ID Employee_ID Start_from Is_full_time 1 1 2009 True 1 2 2003 True */ CREATE TABLE shop ( "Shop_ID" INTEGER, "Name" TEXT, "Location" TEXT, "District" TEXT, "Number_products" INTEGER, "Manager_name" TEXT, PRIMARY KEY ("Shop_ID") ) /* 2 rows from shop table: Shop_ID Name Location District Number_products Manager_name 1 FC Haka Valkeakoski Tehtaan kenttä 3516 Olli Huttunen 2 HJK Helsinki Finnair Stadium 10770 Antti Muurinen */
What is total bonus given in all evaluations?
SELECT sum(bonus) FROM evaluation
[{'sum(bonus)': 19500.0}]
easy
Table employee ( employee.Employee_ID (INT), employee.Name (TEXT), employee.Age (INT), employee.City (TEXT), ) Table evaluation ( evaluation.Employee_ID (TEXT), evaluation.Year_awarded (TEXT), evaluation.Bonus (REAL), ) Table hiring ( hiring.Shop_ID (INT), hiring.Employee_ID (INT), hiring.Start_from (TEXT), hiring.Is_full_time (bool), ) Table shop ( shop.Shop_ID (INT), shop.Name (TEXT), shop.Location (TEXT), shop.District (TEXT), shop.Number_products (INT), shop.Manager_name (TEXT), ) Possible JOINs: evaluation.Employee_ID = employee.Employee_ID hiring.Shop_ID = shop.Shop_ID hiring.Employee_ID = employee.Employee_ID
SELECT sum(bonus) FROM evaluation
{ 'evaluation': ['employee_id', 'bonus'] }
Table evaluation ( evaluation.Employee_ID (TEXT), evaluation.Bonus (REAL), )
Table evaluation ( evaluation.Employee_ID (TEXT), evaluation.Year_awarded (TEXT), evaluation.Bonus (REAL), ) Possible JOINs: evaluation.Employee_ID = employee.Employee_ID
dog_kennels
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) )
CREATE TABLE "Breeds" ( breed_code VARCHAR(10), breed_name VARCHAR(80), PRIMARY KEY (breed_code) ) /* 2 rows from Breeds table: breed_code breed_name ESK Eskimo HUS Husky */ CREATE TABLE "Charges" ( charge_id INTEGER, charge_type VARCHAR(10), charge_amount DECIMAL(19, 4), PRIMARY KEY (charge_id) ) /* 2 rows from Charges table: charge_id charge_type charge_amount 1 Daily Accommodation 98.0000 2 Drugs 322.0000 */ CREATE TABLE "Dogs" ( dog_id INTEGER, owner_id INTEGER NOT NULL, abandoned_yn VARCHAR(1), breed_code VARCHAR(10) NOT NULL, size_code VARCHAR(10) NOT NULL, name VARCHAR(50), age VARCHAR(20), date_of_birth DATETIME, gender VARCHAR(1), weight VARCHAR(20), date_arrived DATETIME, date_adopted DATETIME, date_departed DATETIME, PRIMARY KEY (dog_id), FOREIGN KEY(owner_id) REFERENCES "Owners" (owner_id), FOREIGN KEY(size_code) REFERENCES "Sizes" (size_code), FOREIGN KEY(breed_code) REFERENCES "Breeds" (breed_code) ) /* 2 rows from Dogs table: dog_id owner_id abandoned_yn breed_code size_code name age date_of_birth gender weight date_arrived date_adopted date_departed 1 3 1 ESK LGE Kacey 6 2012-01-27 05:11:53 1 7.57 2017-09-08 20:10:13 2018-03-06 16:32:11 2018-03-25 06:58:44 2 11 0 BUL LGE Hipolito 9 2013-02-13 05:15:21 0 1.72 2017-12-22 05:02:02 2018-03-25 08:12:51 2018-03-25 02:11:32 */ CREATE TABLE "Owners" ( owner_id INTEGER, first_name VARCHAR(50), last_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (owner_id) ) /* 2 rows from Owners table: owner_id first_name last_name street city state zip_code email_address home_phone cell_number 1 Nora Haley 0647 Hintz Village Apt. 024 Lake Tia Wisconsin 93165 [email protected] 1-682-845-0116x63235 478.978.0729 2 Melisa DuBuque 1204 Mae Highway Apt. 107 Port Reannamouth Virginia 45244 [email protected] (799)563-0260x454 (722)768-5439x484 */ CREATE TABLE "Professionals" ( professional_id INTEGER, role_code VARCHAR(10) NOT NULL, first_name VARCHAR(50), street VARCHAR(50), city VARCHAR(50), state VARCHAR(20), zip_code VARCHAR(20), last_name VARCHAR(50), email_address VARCHAR(50), home_phone VARCHAR(20), cell_number VARCHAR(20), PRIMARY KEY (professional_id) ) /* 2 rows from Professionals table: professional_id role_code first_name street city state zip_code last_name email_address home_phone cell_number 1 Employee Taryn 6915 Oberbrunner Point Suite 491 Gleasonville, LA West Heidi Indiana 06646 Braun [email protected] +71(6)2898266914 (275)939-2435x80863 2 Employee Jayson 88665 Terence Lodge Apt. 904 Corneliusfort, NC 194 North Odellfurt Connecticut 43129 Ullrich [email protected] +02(1)0259033559 889-940-2676 */ CREATE TABLE "Sizes" ( size_code VARCHAR(10), size_description VARCHAR(80), PRIMARY KEY (size_code) ) /* 2 rows from Sizes table: size_code size_description SML Small MED Medium */ CREATE TABLE "Treatment_Types" ( treatment_type_code VARCHAR(10), treatment_type_description VARCHAR(80), PRIMARY KEY (treatment_type_code) ) /* 2 rows from Treatment_Types table: treatment_type_code treatment_type_description EXAM Physical examination VAC Vaccination */ CREATE TABLE "Treatments" ( treatment_id INTEGER, dog_id INTEGER NOT NULL, professional_id INTEGER NOT NULL, treatment_type_code VARCHAR(10) NOT NULL, date_of_treatment DATETIME, cost_of_treatment DECIMAL(19, 4), PRIMARY KEY (treatment_id), FOREIGN KEY(dog_id) REFERENCES "Dogs" (dog_id), FOREIGN KEY(professional_id) REFERENCES "Professionals" (professional_id), FOREIGN KEY(treatment_type_code) REFERENCES "Treatment_Types" (treatment_type_code) ) /* 2 rows from Treatments table: treatment_id dog_id professional_id treatment_type_code date_of_treatment cost_of_treatment 1 14 9 WALK 2018-03-19 04:39:54 567.0000 2 4 10 VAC 2018-03-15 20:25:34 147.0000 */
Find the id, last name and cell phone of the professionals who live in the state of Indiana or have performed more than two treatments.
SELECT professional_id , last_name , cell_number FROM Professionals WHERE state = 'Indiana' UNION SELECT T1.professional_id , T1.last_name , T1.cell_number FROM Professionals AS T1 JOIN Treatments AS T2 ON T1.professional_id = T2.professional_id GROUP BY T1.professional_id HAVING count(*) > 2
[{'professional_id': 1, 'last_name': 'Braun', 'cell_number': '(275)939-2435x80863'}, {'professional_id': 8, 'last_name': 'Hyatt', 'cell_number': '328.842.3792'}, {'professional_id': 9, 'last_name': 'Kshlerin', 'cell_number': '962-983-8109x3509'}]
extra
Table Breeds ( Breeds.breed_code (VARCHAR(10)), Breeds.breed_name (VARCHAR(80)), ) Table Charges ( Charges.charge_id (INTEGER), Charges.charge_type (VARCHAR(10)), Charges.charge_amount (DECIMAL(19,4)), ) Table Dogs ( Dogs.dog_id (INTEGER), Dogs.owner_id (INTEGER), Dogs.abandoned_yn (VARCHAR(1)), Dogs.breed_code (VARCHAR(10)), Dogs.size_code (VARCHAR(10)), Dogs.name (VARCHAR(50)), Dogs.age (VARCHAR(20)), Dogs.date_of_birth (DATETIME), Dogs.gender (VARCHAR(1)), Dogs.weight (VARCHAR(20)), Dogs.date_arrived (DATETIME), Dogs.date_adopted (DATETIME), Dogs.date_departed (DATETIME), ) Table Owners ( Owners.owner_id (INTEGER), Owners.first_name (VARCHAR(50)), Owners.last_name (VARCHAR(50)), Owners.street (VARCHAR(50)), Owners.city (VARCHAR(50)), Owners.state (VARCHAR(20)), Owners.zip_code (VARCHAR(20)), Owners.email_address (VARCHAR(50)), Owners.home_phone (VARCHAR(20)), Owners.cell_number (VARCHAR(20)), ) Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Sizes ( Sizes.size_code (VARCHAR(10)), Sizes.size_description (VARCHAR(80)), ) Table Treatment_Types ( Treatment_Types.treatment_type_code (VARCHAR(10)), Treatment_Types.treatment_type_description (VARCHAR(80)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Dogs.owner_id = Owners.owner_id Dogs.breed_code = Breeds.breed_code Dogs.size_code = Sizes.size_code Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
SELECT professional_id , last_name , cell_number FROM Professionals WHERE state = 'Indiana' UNION SELECT Professionals.professional_id , Professionals.last_name , Professionals.cell_number FROM Professionals JOIN Treatments ON Professionals.professional_id = Treatments.professional_id GROUP BY Professionals.professional_id HAVING count(*) > 2
{ 'professionals': ['professional_id', 'state', 'last_name', 'cell_number'], 'treatments': ['treatment_id', 'professional_id'] }
Table Professionals ( Professionals.professional_id (INTEGER), Professionals.state (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.cell_number (VARCHAR(20)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.professional_id (INTEGER), ) Possible JOINs: Treatments.professional_id = Professionals.professional_id
Table Professionals ( Professionals.professional_id (INTEGER), Professionals.role_code (VARCHAR(10)), Professionals.first_name (VARCHAR(50)), Professionals.street (VARCHAR(50)), Professionals.city (VARCHAR(50)), Professionals.state (VARCHAR(20)), Professionals.zip_code (VARCHAR(20)), Professionals.last_name (VARCHAR(50)), Professionals.email_address (VARCHAR(50)), Professionals.home_phone (VARCHAR(20)), Professionals.cell_number (VARCHAR(20)), ) Table Treatments ( Treatments.treatment_id (INTEGER), Treatments.dog_id (INTEGER), Treatments.professional_id (INTEGER), Treatments.treatment_type_code (VARCHAR(10)), Treatments.date_of_treatment (DATETIME), Treatments.cost_of_treatment (DECIMAL(19,4)), ) Possible JOINs: Treatments.dog_id = Dogs.dog_id Treatments.professional_id = Professionals.professional_id Treatments.treatment_type_code = Treatment_Types.treatment_type_code
poker_player
CREATE TABLE people ( "People_ID" INTEGER, "Nationality" TEXT, "Name" TEXT, "Birth_Date" TEXT, "Height" REAL, PRIMARY KEY ("People_ID") ) CREATE TABLE poker_player ( "Poker_Player_ID" INTEGER, "People_ID" INTEGER, "Final_Table_Made" REAL, "Best_Finish" REAL, "Money_Rank" REAL, "Earnings" REAL, PRIMARY KEY ("Poker_Player_ID"), FOREIGN KEY("People_ID") REFERENCES people ("People_ID") )
CREATE TABLE people ( "People_ID" INTEGER, "Nationality" TEXT, "Name" TEXT, "Birth_Date" TEXT, "Height" REAL, PRIMARY KEY ("People_ID") ) /* 2 rows from people table: People_ID Nationality Name Birth_Date Height 1 Russia Aleksey Ostapenko May 26, 1986 207.0 2 Bulgaria Teodor Salparov August 16, 1982 182.0 */ CREATE TABLE poker_player ( "Poker_Player_ID" INTEGER, "People_ID" INTEGER, "Final_Table_Made" REAL, "Best_Finish" REAL, "Money_Rank" REAL, "Earnings" REAL, PRIMARY KEY ("Poker_Player_ID"), FOREIGN KEY("People_ID") REFERENCES people ("People_ID") ) /* 2 rows from poker_player table: Poker_Player_ID People_ID Final_Table_Made Best_Finish Money_Rank Earnings 1 1 42.0 1.0 68.0 476090.0 2 2 10.0 2.0 141.0 189233.0 */
Return the names of poker players sorted by their earnings descending.
SELECT T1.Name FROM people AS T1 JOIN poker_player AS T2 ON T1.People_ID = T2.People_ID ORDER BY T2.Earnings DESC
[{'Name': 'Maksim Botin'}, {'Name': 'Aleksey Ostapenko'}, {'Name': 'Teodor Salparov'}, {'Name': 'Semen Poltavskiy'}, {'Name': 'Yevgeni Sivozhelez'}]
medium
Table people ( people.People_ID (INT), people.Nationality (TEXT), people.Name (TEXT), people.Birth_Date (TEXT), people.Height (REAL), ) Table poker_player ( poker_player.Poker_Player_ID (INT), poker_player.People_ID (INT), poker_player.Final_Table_Made (REAL), poker_player.Best_Finish (REAL), poker_player.Money_Rank (REAL), poker_player.Earnings (REAL), ) Possible JOINs: poker_player.People_ID = people.People_ID
SELECT people.Name FROM people JOIN poker_player ON people.People_ID = poker_player.People_ID ORDER BY poker_player.Earnings DESC
{ 'people': ['people_id', 'name'], 'poker_player': ['poker_player_id', 'people_id', 'earnings'] }
Table people ( people.People_ID (INT), people.Name (TEXT), ) Table poker_player ( poker_player.Poker_Player_ID (INT), poker_player.People_ID (INT), poker_player.Earnings (REAL), )
Table people ( people.People_ID (INT), people.Nationality (TEXT), people.Name (TEXT), people.Birth_Date (TEXT), people.Height (REAL), ) Table poker_player ( poker_player.Poker_Player_ID (INT), poker_player.People_ID (INT), poker_player.Final_Table_Made (REAL), poker_player.Best_Finish (REAL), poker_player.Money_Rank (REAL), poker_player.Earnings (REAL), ) Possible JOINs: poker_player.People_ID = people.People_ID
network_1
CREATE TABLE "Friend" ( student_id INTEGER, friend_id INTEGER, PRIMARY KEY (student_id, friend_id), FOREIGN KEY(student_id) REFERENCES "Highschooler" ("ID"), FOREIGN KEY(friend_id) REFERENCES "Highschooler" ("ID") ) CREATE TABLE "Highschooler" ( "ID" INTEGER, name TEXT, grade INTEGER, PRIMARY KEY ("ID") ) CREATE TABLE "Likes" ( student_id INTEGER, liked_id INTEGER, PRIMARY KEY (student_id, liked_id), FOREIGN KEY(liked_id) REFERENCES "Highschooler" ("ID"), FOREIGN KEY(student_id) REFERENCES "Highschooler" ("ID") )
CREATE TABLE "Friend" ( student_id INTEGER, friend_id INTEGER, PRIMARY KEY (student_id, friend_id), FOREIGN KEY(student_id) REFERENCES "Highschooler" ("ID"), FOREIGN KEY(friend_id) REFERENCES "Highschooler" ("ID") ) /* 2 rows from Friend table: student_id friend_id 1510 1381 1510 1689 */ CREATE TABLE "Highschooler" ( "ID" INTEGER, name TEXT, grade INTEGER, PRIMARY KEY ("ID") ) /* 2 rows from Highschooler table: ID name grade 1510 Jordan 9 1689 Gabriel 9 */ CREATE TABLE "Likes" ( student_id INTEGER, liked_id INTEGER, PRIMARY KEY (student_id, liked_id), FOREIGN KEY(liked_id) REFERENCES "Highschooler" ("ID"), FOREIGN KEY(student_id) REFERENCES "Highschooler" ("ID") ) /* 2 rows from Likes table: student_id liked_id 1689 1709 1709 1689 */
Show the names of students who have at least 2 likes.
SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id HAVING count(*) >= 2
[{'Nenhum': 'Nenhum resultado encontrado'}]
medium
Table Friend ( Friend.student_id (INT), Friend.friend_id (INT), ) Table Highschooler ( Highschooler.ID (INT), Highschooler.name (TEXT), Highschooler.grade (INT), ) Table Likes ( Likes.student_id (INT), Likes.liked_id (INT), ) Possible JOINs: Friend.student_id = Highschooler.ID Friend.friend_id = Highschooler.ID Likes.student_id = Highschooler.ID Likes.liked_id = Highschooler.ID
SELECT Highschooler.name FROM Likes JOIN Highschooler ON Likes.student_id = Highschooler.id GROUP BY Likes.student_id HAVING count(*) >= 2
{ 'likes': ['student_id'], 'highschooler': ['id', 'name'] }
Table Highschooler ( Highschooler.ID (INT), Highschooler.name (TEXT), ) Table Likes ( Likes.student_id (INT), ) Possible JOINs: Likes.student_id = Highschooler.ID
Table Highschooler ( Highschooler.ID (INT), Highschooler.name (TEXT), Highschooler.grade (INT), ) Table Likes ( Likes.student_id (INT), Likes.liked_id (INT), ) Possible JOINs: Likes.student_id = Highschooler.ID Likes.liked_id = Highschooler.ID
car_1
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") )
CREATE TABLE car_makers ( "Id" INTEGER, "Maker" TEXT, "FullName" TEXT, "Country" TEXT, PRIMARY KEY ("Id"), FOREIGN KEY("Country") REFERENCES countries ("CountryId") ) /* 2 rows from car_makers table: Id Maker FullName Country 1 amc American Motor Company 1 2 volkswagen Volkswagen 2 */ CREATE TABLE car_names ( "MakeId" INTEGER, "Model" TEXT, "Make" TEXT, PRIMARY KEY ("MakeId"), FOREIGN KEY("Model") REFERENCES model_list ("Model") ) /* 2 rows from car_names table: MakeId Model Make 1 chevrolet chevrolet chevelle malibu 2 buick buick skylark 320 */ CREATE TABLE cars_data ( "Id" INTEGER, "MPG" TEXT, "Cylinders" INTEGER, "Edispl" REAL, "Horsepower" TEXT, "Weight" INTEGER, "Accelerate" REAL, "Year" INTEGER, PRIMARY KEY ("Id"), FOREIGN KEY("Id") REFERENCES car_names ("MakeId") ) /* 2 rows from cars_data table: Id MPG Cylinders Edispl Horsepower Weight Accelerate Year 1 18 8 307.0 130 3504 12.0 1970 2 15 8 350.0 165 3693 11.5 1970 */ CREATE TABLE continents ( "ContId" INTEGER, "Continent" TEXT, PRIMARY KEY ("ContId") ) /* 2 rows from continents table: ContId Continent 1 america 2 europe */ CREATE TABLE countries ( "CountryId" INTEGER, "CountryName" TEXT, "Continent" INTEGER, PRIMARY KEY ("CountryId"), FOREIGN KEY("Continent") REFERENCES continents ("ContId") ) /* 2 rows from countries table: CountryId CountryName Continent 1 usa 1 2 germany 2 */ CREATE TABLE model_list ( "ModelId" INTEGER, "Maker" INTEGER, "Model" TEXT, PRIMARY KEY ("ModelId"), FOREIGN KEY("Maker") REFERENCES car_makers ("Id"), UNIQUE ("Model") ) /* 2 rows from model_list table: ModelId Maker Model 1 1 amc 2 2 audi */
How many car makers are there in each continents? List the continent name and the count.
SELECT T1.Continent , count(*) FROM CONTINENTS AS T1 JOIN COUNTRIES AS T2 ON T1.ContId = T2.continent JOIN car_makers AS T3 ON T2.CountryId = T3.Country GROUP BY T1.Continent;
[{'Continent': 'america', 'count(*)': 4}, {'Continent': 'asia', 'count(*)': 7}, {'Continent': 'europe', 'count(*)': 11}]
hard
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table car_names ( car_names.MakeId (INTEGER), car_names.Model (TEXT), car_names.Make (TEXT), ) Table cars_data ( cars_data.Id (INTEGER), cars_data.MPG (TEXT), cars_data.Cylinders (INTEGER), cars_data.Edispl (REAL), cars_data.Horsepower (TEXT), cars_data.Weight (INTEGER), cars_data.Accelerate (REAL), cars_data.Year (INTEGER), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Table model_list ( model_list.ModelId (INTEGER), model_list.Maker (INTEGER), model_list.Model (TEXT), ) Possible JOINs: car_makers.Country = countries.CountryId car_names.Model = model_list.Model cars_data.Id = car_names.MakeId countries.Continent = continents.ContId model_list.Maker = car_makers.Id
SELECT CONTINENTS.Continent , count(*) FROM CONTINENTS JOIN COUNTRIES ON CONTINENTS.ContId = COUNTRIES.continent JOIN car_makers ON COUNTRIES.CountryId = car_makers.Country GROUP BY CONTINENTS.Continent;
{ 'continents': ['contid', 'continent'], 'countries': ['countryid', 'continent'], 'car_makers': ['id', 'country'] }
Table car_makers ( car_makers.Id (INTEGER), car_makers.Country (TEXT), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.Continent (INTEGER), ) Possible JOINs:
Table car_makers ( car_makers.Id (INTEGER), car_makers.Maker (TEXT), car_makers.FullName (TEXT), car_makers.Country (TEXT), ) Table continents ( continents.ContId (INTEGER), continents.Continent (TEXT), ) Table countries ( countries.CountryId (INTEGER), countries.CountryName (TEXT), countries.Continent (INTEGER), ) Possible JOINs: car_makers.Country = countries.CountryId countries.Continent = continents.ContId
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
33
Edit dataset card