db_id
stringclasses 142
values | schema
stringclasses 142
values | schemaComEx
stringclasses 142
values | question
stringlengths 3
224
| query
stringlengths 18
523
| answer
stringlengths 13
498k
| complexity
stringclasses 4
values | distinct
bool 2
classes | like
bool 2
classes | between
bool 2
classes | order_by
bool 2
classes | limit
bool 2
classes | grouby_by
bool 2
classes | having
bool 2
classes | single_join
bool 2
classes | multiple_join
bool 2
classes | multiple_select
bool 2
classes | intersect
bool 2
classes | except
bool 2
classes | union
bool 2
classes | sql_example_80
stringclasses 658
values | sql_example_85
stringclasses 728
values | sql_example_90
stringclasses 804
values | sql_example_95
stringclasses 875
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
activity_1 |
CREATE TABLE "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
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 "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
/*
2 rows from Activity table:
actid activity_name
770 Mountain Climbing
771 Canoeing
*/
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
/*
2 rows from Faculty table:
FacID Lname Fname Rank Sex Phone Room Building
1082 Giuliano Mark Instructor M 2424 224 NEB
1121 Goodrich Michael Professor M 3593 219 NEB
*/
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Faculty_Participates_in table:
FacID actid
1082 784
1082 785
*/
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Participates_in table:
stuid actid
1001 770
1001 771
*/
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
*/ | Show the ids for all the students who participate in an activity and are under 20. | SELECT StuID FROM Participates_in INTERSECT SELECT StuID FROM Student WHERE age < 20 | [{'stuid': 1001}, {'stuid': 1002}, {'stuid': 1006}, {'stuid': 1007}, {'stuid': 1009}, {'stuid': 1010}, {'stuid': 1014}, {'stuid': 1015}, {'stuid': 1016}, {'stuid': 1019}, {'stuid': 1021}, {'stuid': 1022}, {'stuid': 1024}, {'stuid': 1025}, {'stuid': 1029}, {'stuid': 1033}, {'stuid': 1034}] | Hard | false | false | false | false | false | false | false | false | false | false | true | false | false | [QUESTION]Show the student IDs and numbers of friends corresponding to each.[/QUESTION]
[SQL]SELECT student_id , count(*) FROM Friend GROUP BY student_id[/SQL] | [QUESTION]Show the student IDs and numbers of friends corresponding to each.[/QUESTION]
[SQL]SELECT student_id , count(*) FROM Friend GROUP BY student_id[/SQL] | [QUESTION]Show the student IDs and numbers of friends corresponding to each.[/QUESTION]
[SQL]SELECT student_id , count(*) FROM Friend GROUP BY student_id[/SQL] | [QUESTION]Show the student IDs and numbers of friends corresponding to each.[/QUESTION]
[SQL]SELECT student_id , count(*) FROM Friend GROUP BY student_id[/SQL] |
music_2 |
CREATE TABLE "Albums" (
"AId" INTEGER,
"Title" TEXT,
"Year" INTEGER,
"Label" TEXT,
"Type" TEXT,
PRIMARY KEY ("AId")
)
CREATE TABLE "Band" (
"Id" INTEGER,
"Firstname" TEXT,
"Lastname" TEXT,
PRIMARY KEY ("Id")
)
CREATE TABLE "Instruments" (
"SongId" INTEGER,
"BandmateId" INTEGER,
"Instrument" TEXT,
PRIMARY KEY ("SongId", "BandmateId", "Instrument"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("BandmateId") REFERENCES "Band" ("Id")
)
CREATE TABLE "Performance" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"StagePosition" TEXT,
PRIMARY KEY ("SongId", "Bandmate"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("Bandmate") REFERENCES "Band" ("Id")
)
CREATE TABLE "Songs" (
"SongId" INTEGER,
"Title" TEXT,
PRIMARY KEY ("SongId")
)
CREATE TABLE "Tracklists" (
"AlbumId" INTEGER,
"Position" INTEGER,
"SongId" INTEGER,
PRIMARY KEY ("AlbumId", "Position"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("AlbumId") REFERENCES "Albums" ("AId")
)
CREATE TABLE "Vocals" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"Type" TEXT,
PRIMARY KEY ("SongId", "Bandmate"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("Bandmate") REFERENCES "Band" ("Id")
) |
CREATE TABLE "Albums" (
"AId" INTEGER,
"Title" TEXT,
"Year" INTEGER,
"Label" TEXT,
"Type" TEXT,
PRIMARY KEY ("AId")
)
/*
2 rows from Albums table:
AId Title Year Label Type
*/
CREATE TABLE "Band" (
"Id" INTEGER,
"Firstname" TEXT,
"Lastname" TEXT,
PRIMARY KEY ("Id")
)
/*
2 rows from Band table:
Id Firstname Lastname
*/
CREATE TABLE "Instruments" (
"SongId" INTEGER,
"BandmateId" INTEGER,
"Instrument" TEXT,
PRIMARY KEY ("SongId", "BandmateId", "Instrument"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("BandmateId") REFERENCES "Band" ("Id")
)
/*
2 rows from Instruments table:
SongId BandmateId Instrument
*/
CREATE TABLE "Performance" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"StagePosition" TEXT,
PRIMARY KEY ("SongId", "Bandmate"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("Bandmate") REFERENCES "Band" ("Id")
)
/*
2 rows from Performance table:
SongId Bandmate StagePosition
*/
CREATE TABLE "Songs" (
"SongId" INTEGER,
"Title" TEXT,
PRIMARY KEY ("SongId")
)
/*
2 rows from Songs table:
SongId Title
*/
CREATE TABLE "Tracklists" (
"AlbumId" INTEGER,
"Position" INTEGER,
"SongId" INTEGER,
PRIMARY KEY ("AlbumId", "Position"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("AlbumId") REFERENCES "Albums" ("AId")
)
/*
2 rows from Tracklists table:
AlbumId Position SongId
*/
CREATE TABLE "Vocals" (
"SongId" INTEGER,
"Bandmate" INTEGER,
"Type" TEXT,
PRIMARY KEY ("SongId", "Bandmate"),
FOREIGN KEY("SongId") REFERENCES "Songs" ("SongId"),
FOREIGN KEY("Bandmate") REFERENCES "Band" ("Id")
)
/*
2 rows from Vocals table:
SongId Bandmate Type
*/ | return all columns of the albums created in the year of 2012. | SELECT * FROM Albums WHERE YEAR = 2012 | [{'Nenhum': 'Nenhum resultado encontrado'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]For each file format, return the number of artists who released songs in that format.[/QUESTION]
[SQL]SELECT count(*) , formats FROM files GROUP BY formats[/SQL] |
|||
match_season |
CREATE TABLE country (
"Country_id" INTEGER,
"Country_name" TEXT,
"Capital" TEXT,
"Official_native_language" TEXT,
PRIMARY KEY ("Country_id")
)
CREATE TABLE match_season (
"Season" REAL,
"Player" TEXT,
"Position" TEXT,
"Country" INTEGER,
"Team" INTEGER,
"Draft_Pick_Number" INTEGER,
"Draft_Class" TEXT,
"College" TEXT,
PRIMARY KEY ("Season"),
FOREIGN KEY("Team") REFERENCES team ("Team_id"),
FOREIGN KEY("Country") REFERENCES country ("Country_id")
)
CREATE TABLE player (
"Player_ID" INTEGER,
"Player" TEXT,
"Years_Played" TEXT,
"Total_WL" TEXT,
"Singles_WL" TEXT,
"Doubles_WL" TEXT,
"Team" INTEGER,
PRIMARY KEY ("Player_ID"),
FOREIGN KEY("Team") REFERENCES team ("Team_id")
)
CREATE TABLE team (
"Team_id" INTEGER,
"Name" TEXT,
PRIMARY KEY ("Team_id")
) |
CREATE TABLE country (
"Country_id" INTEGER,
"Country_name" TEXT,
"Capital" TEXT,
"Official_native_language" TEXT,
PRIMARY KEY ("Country_id")
)
/*
2 rows from country table:
Country_id Country_name Capital Official_native_language
1 Indonesia Jakarta Bahasa Indonesia
2 Iran Tehran Persian ( Arabic script )
*/
CREATE TABLE match_season (
"Season" REAL,
"Player" TEXT,
"Position" TEXT,
"Country" INTEGER,
"Team" INTEGER,
"Draft_Pick_Number" INTEGER,
"Draft_Class" TEXT,
"College" TEXT,
PRIMARY KEY ("Season"),
FOREIGN KEY("Team") REFERENCES team ("Team_id"),
FOREIGN KEY("Country") REFERENCES country ("Country_id")
)
/*
2 rows from match_season table:
Season Player Position Country Team Draft_Pick_Number Draft_Class College
1996.0 Steve Ralston Category:Articles with hCards Midfielder 6 1 18 1996 MLS College Draft Florida International
1997.0 Mike Duhaney Category:Articles with hCards Defender 6 2 87 1996 MLS Inaugural Player Draft UNLV
*/
CREATE TABLE player (
"Player_ID" INTEGER,
"Player" TEXT,
"Years_Played" TEXT,
"Total_WL" TEXT,
"Singles_WL" TEXT,
"Doubles_WL" TEXT,
"Team" INTEGER,
PRIMARY KEY ("Player_ID"),
FOREIGN KEY("Team") REFERENCES team ("Team_id")
)
/*
2 rows from player table:
Player_ID Player Years_Played Total_WL Singles_WL Doubles_WL Team
1 Cho Soong-Jae (630) 1 (2011) 2–0 1–0 1–0 1
2 Chung Hong (717) 1 (2011) 0–0 0–0 0–0 1
*/
CREATE TABLE team (
"Team_id" INTEGER,
"Name" TEXT,
PRIMARY KEY ("Team_id")
)
/*
2 rows from team table:
Team_id Name
1 Columbus Crew
2 Evalyn Feil
*/ | Return the official native languages of countries who have players from Maryland or Duke colleges. | SELECT T1.Official_native_language FROM country AS T1 JOIN match_season AS T2 ON T1.Country_id = T2.Country WHERE T2.College = "Maryland" OR T2.College = "Duke" | [{'Official_native_language': 'English Manx'}, {'Official_native_language': 'Irish English'}, {'Official_native_language': 'English'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]Return the country codes for countries that do not speak English.[/QUESTION]
[SQL]SELECT CountryCode FROM countrylanguage EXCEPT SELECT CountryCode FROM countrylanguage WHERE LANGUAGE = "English"[/SQL] | [QUESTION]Return the country codes for countries that do not speak English.[/QUESTION]
[SQL]SELECT CountryCode FROM countrylanguage EXCEPT SELECT CountryCode FROM countrylanguage WHERE LANGUAGE = "English"[/SQL] | [QUESTION]Return the country codes for countries that do not speak English.[/QUESTION]
[SQL]SELECT CountryCode FROM countrylanguage EXCEPT SELECT CountryCode FROM countrylanguage WHERE LANGUAGE = "English"[/SQL] |
|
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | acl papers in 2012 about Parsing | SELECT DISTINCT t3.paperid FROM paperkeyphrase AS t2 JOIN keyphrase AS t1 ON t2.keyphraseid = t1.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid JOIN venue AS t4 ON t4.venueid = t3.venueid WHERE t1.keyphrasename = "Parsing" AND t3.year = 2012 AND t4.venuename = "acl"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
mountain_photos |
CREATE TABLE camera_lens (
id INTEGER,
brand TEXT,
name TEXT,
focal_length_mm REAL,
max_aperture REAL,
PRIMARY KEY (id)
)
CREATE TABLE mountain (
id INTEGER,
name TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY (id)
)
CREATE TABLE photos (
id INTEGER,
camera_lens_id INTEGER,
mountain_id INTEGER,
color TEXT,
name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(mountain_id) REFERENCES mountain (id),
FOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)
) |
CREATE TABLE camera_lens (
id INTEGER,
brand TEXT,
name TEXT,
focal_length_mm REAL,
max_aperture REAL,
PRIMARY KEY (id)
)
/*
2 rows from camera_lens table:
id brand name focal_length_mm max_aperture
1 Olympus Olympus 15mm f/8.0 Body Cap 15.0 8.0
2 Olympus Olympus M.Zuiko Digital ED 45mm f/1.8 45.0 1.8
*/
CREATE TABLE mountain (
id INTEGER,
name TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from mountain table:
id name Height Prominence Range Country
1 Abune Yosef / Guliba Amba 4260.0 1909.0 Lasta Massif Ethiopia
2 Ioll / Yoll 4220.0 350.0 Kollo Massif Ethiopia
*/
CREATE TABLE photos (
id INTEGER,
camera_lens_id INTEGER,
mountain_id INTEGER,
color TEXT,
name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(mountain_id) REFERENCES mountain (id),
FOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)
)
/*
2 rows from photos table:
id camera_lens_id mountain_id color name
1 1 20 RBG monkey
2 10 2 RBG rabbits
*/ | What are the names of the cameras that have taken picture of the most mountains? | SELECT T2.name FROM photos AS T1 JOIN camera_lens AS T2 ON T1.camera_lens_id = T2.id GROUP BY T2.id ORDER BY count(*) DESC LIMIT 1 | [{'name': 'Sigma 19mm f2.8 EX DN'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
hr_1 |
CREATE TABLE countries (
"COUNTRY_ID" VARCHAR(2) NOT NULL,
"COUNTRY_NAME" VARCHAR(40) DEFAULT NULL,
"REGION_ID" DECIMAL(10, 0) DEFAULT NULL,
PRIMARY KEY ("COUNTRY_ID"),
FOREIGN KEY("REGION_ID") REFERENCES regions ("REGION_ID")
)
CREATE TABLE departments (
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT '0' NOT NULL,
"DEPARTMENT_NAME" VARCHAR(30) NOT NULL,
"MANAGER_ID" DECIMAL(6, 0) DEFAULT NULL,
"LOCATION_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("DEPARTMENT_ID")
)
CREATE TABLE employees (
"EMPLOYEE_ID" DECIMAL(6, 0) DEFAULT '0' NOT NULL,
"FIRST_NAME" VARCHAR(20) DEFAULT NULL,
"LAST_NAME" VARCHAR(25) NOT NULL,
"EMAIL" VARCHAR(25) NOT NULL,
"PHONE_NUMBER" VARCHAR(20) DEFAULT NULL,
"HIRE_DATE" DATE NOT NULL,
"JOB_ID" VARCHAR(10) NOT NULL,
"SALARY" DECIMAL(8, 2) DEFAULT NULL,
"COMMISSION_PCT" DECIMAL(2, 2) DEFAULT NULL,
"MANAGER_ID" DECIMAL(6, 0) DEFAULT NULL,
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("EMPLOYEE_ID"),
FOREIGN KEY("JOB_ID") REFERENCES jobs ("JOB_ID"),
FOREIGN KEY("DEPARTMENT_ID") REFERENCES departments ("DEPARTMENT_ID")
)
CREATE TABLE job_history (
"EMPLOYEE_ID" DECIMAL(6, 0) NOT NULL,
"START_DATE" DATE NOT NULL,
"END_DATE" DATE NOT NULL,
"JOB_ID" VARCHAR(10) NOT NULL,
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("EMPLOYEE_ID", "START_DATE"),
FOREIGN KEY("JOB_ID") REFERENCES jobs ("JOB_ID"),
FOREIGN KEY("DEPARTMENT_ID") REFERENCES departments ("DEPARTMENT_ID"),
FOREIGN KEY("EMPLOYEE_ID") REFERENCES employees ("EMPLOYEE_ID")
)
CREATE TABLE jobs (
"JOB_ID" VARCHAR(10) DEFAULT '' NOT NULL,
"JOB_TITLE" VARCHAR(35) NOT NULL,
"MIN_SALARY" DECIMAL(6, 0) DEFAULT NULL,
"MAX_SALARY" DECIMAL(6, 0) DEFAULT NULL,
PRIMARY KEY ("JOB_ID")
)
CREATE TABLE locations (
"LOCATION_ID" DECIMAL(4, 0) DEFAULT '0' NOT NULL,
"STREET_ADDRESS" VARCHAR(40) DEFAULT NULL,
"POSTAL_CODE" VARCHAR(12) DEFAULT NULL,
"CITY" VARCHAR(30) NOT NULL,
"STATE_PROVINCE" VARCHAR(25) DEFAULT NULL,
"COUNTRY_ID" VARCHAR(2) DEFAULT NULL,
PRIMARY KEY ("LOCATION_ID"),
FOREIGN KEY("COUNTRY_ID") REFERENCES countries ("COUNTRY_ID")
)
CREATE TABLE regions (
"REGION_ID" DECIMAL(5, 0) NOT NULL,
"REGION_NAME" VARCHAR(25) DEFAULT NULL,
PRIMARY KEY ("REGION_ID")
) |
CREATE TABLE countries (
"COUNTRY_ID" VARCHAR(2) NOT NULL,
"COUNTRY_NAME" VARCHAR(40) DEFAULT NULL,
"REGION_ID" DECIMAL(10, 0) DEFAULT NULL,
PRIMARY KEY ("COUNTRY_ID"),
FOREIGN KEY("REGION_ID") REFERENCES regions ("REGION_ID")
)
/*
2 rows from countries table:
COUNTRY_ID COUNTRY_NAME REGION_ID
AR Argentina 2
AU Australia 3
*/
CREATE TABLE departments (
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT '0' NOT NULL,
"DEPARTMENT_NAME" VARCHAR(30) NOT NULL,
"MANAGER_ID" DECIMAL(6, 0) DEFAULT NULL,
"LOCATION_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("DEPARTMENT_ID")
)
/*
2 rows from departments table:
DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
10 Administration 200 1700
20 Marketing 201 1800
*/
CREATE TABLE employees (
"EMPLOYEE_ID" DECIMAL(6, 0) DEFAULT '0' NOT NULL,
"FIRST_NAME" VARCHAR(20) DEFAULT NULL,
"LAST_NAME" VARCHAR(25) NOT NULL,
"EMAIL" VARCHAR(25) NOT NULL,
"PHONE_NUMBER" VARCHAR(20) DEFAULT NULL,
"HIRE_DATE" DATE NOT NULL,
"JOB_ID" VARCHAR(10) NOT NULL,
"SALARY" DECIMAL(8, 2) DEFAULT NULL,
"COMMISSION_PCT" DECIMAL(2, 2) DEFAULT NULL,
"MANAGER_ID" DECIMAL(6, 0) DEFAULT NULL,
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("EMPLOYEE_ID"),
FOREIGN KEY("JOB_ID") REFERENCES jobs ("JOB_ID"),
FOREIGN KEY("DEPARTMENT_ID") REFERENCES departments ("DEPARTMENT_ID")
)
/*
2 rows from employees table:
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
100 Steven King SKING 515.123.4567 1987-06-17 AD_PRES 24000.00 0.00 0 90
101 Neena Kochhar NKOCHHAR 515.123.4568 1987-06-18 AD_VP 17000.00 0.00 100 90
*/
CREATE TABLE job_history (
"EMPLOYEE_ID" DECIMAL(6, 0) NOT NULL,
"START_DATE" DATE NOT NULL,
"END_DATE" DATE NOT NULL,
"JOB_ID" VARCHAR(10) NOT NULL,
"DEPARTMENT_ID" DECIMAL(4, 0) DEFAULT NULL,
PRIMARY KEY ("EMPLOYEE_ID", "START_DATE"),
FOREIGN KEY("JOB_ID") REFERENCES jobs ("JOB_ID"),
FOREIGN KEY("DEPARTMENT_ID") REFERENCES departments ("DEPARTMENT_ID"),
FOREIGN KEY("EMPLOYEE_ID") REFERENCES employees ("EMPLOYEE_ID")
)
/*
2 rows from job_history table:
EMPLOYEE_ID START_DATE END_DATE JOB_ID DEPARTMENT_ID
102 1993-01-13 1998-07-24 IT_PROG 60
101 1989-09-21 1993-10-27 AC_ACCOUNT 110
*/
CREATE TABLE jobs (
"JOB_ID" VARCHAR(10) DEFAULT '' NOT NULL,
"JOB_TITLE" VARCHAR(35) NOT NULL,
"MIN_SALARY" DECIMAL(6, 0) DEFAULT NULL,
"MAX_SALARY" DECIMAL(6, 0) DEFAULT NULL,
PRIMARY KEY ("JOB_ID")
)
/*
2 rows from jobs table:
JOB_ID JOB_TITLE MIN_SALARY MAX_SALARY
AD_PRES President 20000 40000
AD_VP Administration Vice President 15000 30000
*/
CREATE TABLE locations (
"LOCATION_ID" DECIMAL(4, 0) DEFAULT '0' NOT NULL,
"STREET_ADDRESS" VARCHAR(40) DEFAULT NULL,
"POSTAL_CODE" VARCHAR(12) DEFAULT NULL,
"CITY" VARCHAR(30) NOT NULL,
"STATE_PROVINCE" VARCHAR(25) DEFAULT NULL,
"COUNTRY_ID" VARCHAR(2) DEFAULT NULL,
PRIMARY KEY ("LOCATION_ID"),
FOREIGN KEY("COUNTRY_ID") REFERENCES countries ("COUNTRY_ID")
)
/*
2 rows from locations table:
LOCATION_ID STREET_ADDRESS POSTAL_CODE CITY STATE_PROVINCE COUNTRY_ID
1000 1297 Via Cola di Rie 989 Roma IT
1100 93091 Calle della Testa 10934 Venice IT
*/
CREATE TABLE regions (
"REGION_ID" DECIMAL(5, 0) NOT NULL,
"REGION_NAME" VARCHAR(25) DEFAULT NULL,
PRIMARY KEY ("REGION_ID")
)
/*
2 rows from regions table:
REGION_ID REGION_NAME
1 Europe\r
2 Americas\r
*/ | What are the ids and full names for employees who work in a department that has someone with a first name that contains the letter T? | SELECT employee_id , first_name , last_name FROM employees WHERE department_id IN ( SELECT department_id FROM employees WHERE first_name LIKE '%T%' ) | [{'EMPLOYEE_ID': 100, 'FIRST_NAME': 'Steven', 'LAST_NAME': 'King'}, {'EMPLOYEE_ID': 101, 'FIRST_NAME': 'Neena', 'LAST_NAME': 'Kochhar'}, {'EMPLOYEE_ID': 102, 'FIRST_NAME': 'Lex', 'LAST_NAME': 'De Haan'}, {'EMPLOYEE_ID': 120, 'FIRST_NAME': 'Matthew', 'LAST_NAME': 'Weiss'}, {'EMPLOYEE_ID': 121, 'FIRST_NAME': 'Adam', 'LAST_NAME': 'Fripp'}, {'EMPLOYEE_ID': 122, 'FIRST_NAME': 'Payam', 'LAST_NAME': 'Kaufling'}, {'EMPLOYEE_ID': 123, 'FIRST_NAME': 'Shanta', 'LAST_NAME': 'Vollman'}, {'EMPLOYEE_ID': 124, 'FIRST_NAME': 'Kevin', 'LAST_NAME': 'Mourgos'}, {'EMPLOYEE_ID': 125, 'FIRST_NAME': 'Julia', 'LAST_NAME': 'Nayer'}, {'EMPLOYEE_ID': 126, 'FIRST_NAME': 'Irene', 'LAST_NAME': 'Mikkilineni'}, {'EMPLOYEE_ID': 127, 'FIRST_NAME': 'James', 'LAST_NAME': 'Landry'}, {'EMPLOYEE_ID': 128, 'FIRST_NAME': 'Steven', 'LAST_NAME': 'Markle'}, {'EMPLOYEE_ID': 129, 'FIRST_NAME': 'Laura', 'LAST_NAME': 'Bissot'}, {'EMPLOYEE_ID': 130, 'FIRST_NAME': 'Mozhe', 'LAST_NAME': 'Atkinson'}, {'EMPLOYEE_ID': 131, 'FIRST_NAME': 'James', 'LAST_NAME': 'Marlow'}, {'EMPLOYEE_ID': 132, 'FIRST_NAME': 'TJ', 'LAST_NAME': 'Olson'}, {'EMPLOYEE_ID': 133, 'FIRST_NAME': 'Jason', 'LAST_NAME': 'Mallin'}, {'EMPLOYEE_ID': 134, 'FIRST_NAME': 'Michael', 'LAST_NAME': 'Rogers'}, {'EMPLOYEE_ID': 135, 'FIRST_NAME': 'Ki', 'LAST_NAME': 'Gee'}, {'EMPLOYEE_ID': 136, 'FIRST_NAME': 'Hazel', 'LAST_NAME': 'Philtanker'}, {'EMPLOYEE_ID': 137, 'FIRST_NAME': 'Renske', 'LAST_NAME': 'Ladwig'}, {'EMPLOYEE_ID': 138, 'FIRST_NAME': 'Stephen', 'LAST_NAME': 'Stiles'}, {'EMPLOYEE_ID': 139, 'FIRST_NAME': 'John', 'LAST_NAME': 'Seo'}, {'EMPLOYEE_ID': 140, 'FIRST_NAME': 'Joshua', 'LAST_NAME': 'Patel'}, {'EMPLOYEE_ID': 141, 'FIRST_NAME': 'Trenna', 'LAST_NAME': 'Rajs'}, {'EMPLOYEE_ID': 142, 'FIRST_NAME': 'Curtis', 'LAST_NAME': 'Davies'}, {'EMPLOYEE_ID': 143, 'FIRST_NAME': 'Randall', 'LAST_NAME': 'Matos'}, {'EMPLOYEE_ID': 144, 'FIRST_NAME': 'Peter', 'LAST_NAME': 'Vargas'}, {'EMPLOYEE_ID': 145, 'FIRST_NAME': 'John', 'LAST_NAME': 'Russell'}, {'EMPLOYEE_ID': 146, 'FIRST_NAME': 'Karen', 'LAST_NAME': 'Partners'}, {'EMPLOYEE_ID': 147, 'FIRST_NAME': 'Alberto', 'LAST_NAME': 'Errazuriz'}, {'EMPLOYEE_ID': 148, 'FIRST_NAME': 'Gerald', 'LAST_NAME': 'Cambrault'}, {'EMPLOYEE_ID': 149, 'FIRST_NAME': 'Eleni', 'LAST_NAME': 'Zlotkey'}, {'EMPLOYEE_ID': 150, 'FIRST_NAME': 'Peter', 'LAST_NAME': 'Tucker'}, {'EMPLOYEE_ID': 151, 'FIRST_NAME': 'David', 'LAST_NAME': 'Bernstein'}, {'EMPLOYEE_ID': 152, 'FIRST_NAME': 'Peter', 'LAST_NAME': 'Hall'}, {'EMPLOYEE_ID': 153, 'FIRST_NAME': 'Christopher', 'LAST_NAME': 'Olsen'}, {'EMPLOYEE_ID': 154, 'FIRST_NAME': 'Nanette', 'LAST_NAME': 'Cambrault'}, {'EMPLOYEE_ID': 155, 'FIRST_NAME': 'Oliver', 'LAST_NAME': 'Tuvault'}, {'EMPLOYEE_ID': 156, 'FIRST_NAME': 'Janette', 'LAST_NAME': 'King'}, {'EMPLOYEE_ID': 157, 'FIRST_NAME': 'Patrick', 'LAST_NAME': 'Sully'}, {'EMPLOYEE_ID': 158, 'FIRST_NAME': 'Allan', 'LAST_NAME': 'McEwen'}, {'EMPLOYEE_ID': 159, 'FIRST_NAME': 'Lindsey', 'LAST_NAME': 'Smith'}, {'EMPLOYEE_ID': 160, 'FIRST_NAME': 'Louise', 'LAST_NAME': 'Doran'}, {'EMPLOYEE_ID': 161, 'FIRST_NAME': 'Sarath', 'LAST_NAME': 'Sewall'}, {'EMPLOYEE_ID': 162, 'FIRST_NAME': 'Clara', 'LAST_NAME': 'Vishney'}, {'EMPLOYEE_ID': 163, 'FIRST_NAME': 'Danielle', 'LAST_NAME': 'Greene'}, {'EMPLOYEE_ID': 164, 'FIRST_NAME': 'Mattea', 'LAST_NAME': 'Marvins'}, {'EMPLOYEE_ID': 165, 'FIRST_NAME': 'David', 'LAST_NAME': 'Lee'}, {'EMPLOYEE_ID': 166, 'FIRST_NAME': 'Sundar', 'LAST_NAME': 'Ande'}, {'EMPLOYEE_ID': 167, 'FIRST_NAME': 'Amit', 'LAST_NAME': 'Banda'}, {'EMPLOYEE_ID': 168, 'FIRST_NAME': 'Lisa', 'LAST_NAME': 'Ozer'}, {'EMPLOYEE_ID': 169, 'FIRST_NAME': 'Harrison', 'LAST_NAME': 'Bloom'}, {'EMPLOYEE_ID': 170, 'FIRST_NAME': 'Tayler', 'LAST_NAME': 'Fox'}, {'EMPLOYEE_ID': 171, 'FIRST_NAME': 'William', 'LAST_NAME': 'Smith'}, {'EMPLOYEE_ID': 172, 'FIRST_NAME': 'Elizabeth', 'LAST_NAME': 'Bates'}, {'EMPLOYEE_ID': 173, 'FIRST_NAME': 'Sundita', 'LAST_NAME': 'Kumar'}, {'EMPLOYEE_ID': 174, 'FIRST_NAME': 'Ellen', 'LAST_NAME': 'Abel'}, {'EMPLOYEE_ID': 175, 'FIRST_NAME': 'Alyssa', 'LAST_NAME': 'Hutton'}, {'EMPLOYEE_ID': 176, 'FIRST_NAME': 'Jonathon', 'LAST_NAME': 'Taylor'}, {'EMPLOYEE_ID': 177, 'FIRST_NAME': 'Jack', 'LAST_NAME': 'Livingston'}, {'EMPLOYEE_ID': 179, 'FIRST_NAME': 'Charles', 'LAST_NAME': 'Johnson'}, {'EMPLOYEE_ID': 180, 'FIRST_NAME': 'Winston', 'LAST_NAME': 'Taylor'}, {'EMPLOYEE_ID': 181, 'FIRST_NAME': 'Jean', 'LAST_NAME': 'Fleaur'}, {'EMPLOYEE_ID': 182, 'FIRST_NAME': 'Martha', 'LAST_NAME': 'Sullivan'}, {'EMPLOYEE_ID': 183, 'FIRST_NAME': 'Girard', 'LAST_NAME': 'Geoni'}, {'EMPLOYEE_ID': 184, 'FIRST_NAME': 'Nandita', 'LAST_NAME': 'Sarchand'}, {'EMPLOYEE_ID': 185, 'FIRST_NAME': 'Alexis', 'LAST_NAME': 'Bull'}, {'EMPLOYEE_ID': 186, 'FIRST_NAME': 'Julia', 'LAST_NAME': 'Dellinger'}, {'EMPLOYEE_ID': 187, 'FIRST_NAME': 'Anthony', 'LAST_NAME': 'Cabrio'}, {'EMPLOYEE_ID': 188, 'FIRST_NAME': 'Kelly', 'LAST_NAME': 'Chung'}, {'EMPLOYEE_ID': 189, 'FIRST_NAME': 'Jennifer', 'LAST_NAME': 'Dilly'}, {'EMPLOYEE_ID': 190, 'FIRST_NAME': 'Timothy', 'LAST_NAME': 'Gates'}, {'EMPLOYEE_ID': 191, 'FIRST_NAME': 'Randall', 'LAST_NAME': 'Perkins'}, {'EMPLOYEE_ID': 192, 'FIRST_NAME': 'Sarah', 'LAST_NAME': 'Bell'}, {'EMPLOYEE_ID': 193, 'FIRST_NAME': 'Britney', 'LAST_NAME': 'Everett'}, {'EMPLOYEE_ID': 194, 'FIRST_NAME': 'Samuel', 'LAST_NAME': 'McCain'}, {'EMPLOYEE_ID': 195, 'FIRST_NAME': 'Vance', 'LAST_NAME': 'Jones'}, {'EMPLOYEE_ID': 196, 'FIRST_NAME': 'Alana', 'LAST_NAME': 'Walsh'}, {'EMPLOYEE_ID': 197, 'FIRST_NAME': 'Kevin', 'LAST_NAME': 'Feeney'}, {'EMPLOYEE_ID': 198, 'FIRST_NAME': 'Donald', 'LAST_NAME': 'OConnell'}, {'EMPLOYEE_ID': 199, 'FIRST_NAME': 'Douglas', 'LAST_NAME': 'Grant'}, {'EMPLOYEE_ID': 201, 'FIRST_NAME': 'Michael', 'LAST_NAME': 'Hartstein'}, {'EMPLOYEE_ID': 202, 'FIRST_NAME': 'Pat', 'LAST_NAME': 'Fay'}] | Extra Hard | false | true | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]What are the first and last names of the employee with the earliest date of birth?[/QUESTION]
[SQL]SELECT emp_fname , emp_lname FROM employee ORDER BY emp_dob LIMIT 1[/SQL] | [QUESTION]What are the first and last names of the employee with the earliest date of birth?[/QUESTION]
[SQL]SELECT emp_fname , emp_lname FROM employee ORDER BY emp_dob LIMIT 1[/SQL] | [QUESTION]What are the first and last names of the employee with the earliest date of birth?[/QUESTION]
[SQL]SELECT emp_fname , emp_lname FROM employee ORDER BY emp_dob LIMIT 1[/SQL] | [QUESTION]What are the first and last names of the employee with the earliest date of birth?[/QUESTION]
[SQL]SELECT emp_fname , emp_lname FROM employee ORDER BY emp_dob LIMIT 1[/SQL] |
geo |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
) |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from border_info table:
state_name border
*/
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from city table:
city_name population country_name state_name
*/
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from highlow table:
state_name highest_elevation lowest_point highest_point lowest_elevation
*/
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
/*
2 rows from lake table:
lake_name area country_name state_name
*/
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from mountain table:
mountain_name mountain_altitude country_name state_name
*/
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
/*
2 rows from river table:
river_name length country_name traverse
*/
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
)
/*
2 rows from state table:
state_name population area country_name capital density
*/ | what is the capital of the largest state | SELECT capital FROM state WHERE area = ( SELECT MAX ( area ) FROM state ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]what is the capital of the state with the highest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow );[/SQL] | [QUESTION]what is the capital of the state with the highest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow );[/SQL] | [QUESTION]what is the capital of the state with the highest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow );[/SQL] | [QUESTION]what is the capital of the state with the highest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow );[/SQL] |
csu_1 |
CREATE TABLE "Campuses" (
"Id" INTEGER,
"Campus" TEXT,
"Location" TEXT,
"County" TEXT,
"Year" INTEGER,
PRIMARY KEY ("Id")
)
CREATE TABLE csu_fees (
"Campus" INTEGER,
"Year" INTEGER,
"CampusFee" INTEGER,
PRIMARY KEY ("Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE degrees (
"Year" INTEGER,
"Campus" INTEGER,
"Degrees" INTEGER,
PRIMARY KEY ("Year", "Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE discipline_enrollments (
"Campus" INTEGER,
"Discipline" INTEGER,
"Year" INTEGER,
"Undergraduate" INTEGER,
"Graduate" INTEGER,
PRIMARY KEY ("Campus", "Discipline"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE enrollments (
"Campus" INTEGER,
"Year" INTEGER,
"TotalEnrollment_AY" INTEGER,
"FTE_AY" INTEGER,
PRIMARY KEY ("Campus", "Year"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE faculty (
"Campus" INTEGER,
"Year" INTEGER,
"Faculty" REAL,
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
) |
CREATE TABLE "Campuses" (
"Id" INTEGER,
"Campus" TEXT,
"Location" TEXT,
"County" TEXT,
"Year" INTEGER,
PRIMARY KEY ("Id")
)
/*
2 rows from Campuses table:
Id Campus Location County Year
1 California State University-Bakersfield Bakersfield Kern 1965
2 California State University-Channel Islands Camarillo Ventura 2002
*/
CREATE TABLE csu_fees (
"Campus" INTEGER,
"Year" INTEGER,
"CampusFee" INTEGER,
PRIMARY KEY ("Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from csu_fees table:
Campus Year CampusFee
1 1996 1951
2 2003 1868
*/
CREATE TABLE degrees (
"Year" INTEGER,
"Campus" INTEGER,
"Degrees" INTEGER,
PRIMARY KEY ("Year", "Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from degrees table:
Year Campus Degrees
1990 1 701
1991 1 681
*/
CREATE TABLE discipline_enrollments (
"Campus" INTEGER,
"Discipline" INTEGER,
"Year" INTEGER,
"Undergraduate" INTEGER,
"Graduate" INTEGER,
PRIMARY KEY ("Campus", "Discipline"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from discipline_enrollments table:
Campus Discipline Year Undergraduate Graduate
1 4 2004 248 0
1 5 2004 811 73
*/
CREATE TABLE enrollments (
"Campus" INTEGER,
"Year" INTEGER,
"TotalEnrollment_AY" INTEGER,
"FTE_AY" INTEGER,
PRIMARY KEY ("Campus", "Year"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from enrollments table:
Campus Year TotalEnrollment_AY FTE_AY
1 1956 384 123
1 1957 432 151
*/
CREATE TABLE faculty (
"Campus" INTEGER,
"Year" INTEGER,
"Faculty" REAL,
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from faculty table:
Campus Year Faculty
1 2002 357.1
2 2002 48.4
*/ | What is the campus fee for San Francisco State University in 1996? | SELECT campusfee FROM campuses AS T1 JOIN csu_fees AS T2 ON T1.id = t2.campus WHERE t1.campus = "San Francisco State University" AND T2.year = 1996 | [{'CampusFee': 1978}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
student_assessment |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id line_1 line_2 city zip_postcode state_province_county country
5 0900 Roderick Oval
New Albina, WA 19200-7914 Suite 096 Linnealand 862 Montana USA
9 966 Dach Ports Apt. 322
Lake Harmonyhaven, VA 65235 Apt. 163 South Minnie 716 Texas USA
*/
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
/*
2 rows from Candidate_Assessments table:
candidate_id qualification assessment_date asessment_outcome_code
111 A 2010-04-07 11:44:34 Pass
121 B 2010-04-17 11:44:34 Pass
*/
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
/*
2 rows from Candidates table:
candidate_id candidate_details
111 Jane
121 Robert
*/
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
/*
2 rows from Courses table:
course_id course_name course_description other_details
301 statistics statistics None
302 English English None
*/
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
/*
2 rows from People table:
person_id first_name middle_name last_name cell_mobile_number email_address login_name password
111 Shannon Elissa Senger 01955267735 [email protected] pgub 5e4ff49a61b3544da3ad7dc7e2cf28847564c64c
121 Virginie Jasmin Hartmann (508)319-2970x043 [email protected] bkkv b063331ea8116befaa7b84c59c6a22200f5f8caa
*/
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from People_Addresses table:
person_address_id person_id address_id date_from date_to
122 111 9 2012-09-26 13:21:00 2018-03-21 09:46:30
257 121 5 2008-07-31 02:17:25 2018-03-09 02:11:12
*/
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
/*
2 rows from Student_Course_Attendance table:
student_id course_id date_of_attendance
111 301 2008-11-04 10:35:13
121 301 2012-04-09 11:44:34
*/
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
/*
2 rows from Student_Course_Registrations table:
student_id course_id registration_date
111 301 2008-11-04 10:35:13
121 301 2008-10-04 10:35:13
*/
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
)
/*
2 rows from Students table:
student_id student_details
111 Marry
121 Martin
*/ | List the first names of people in alphabetical order? | SELECT first_name FROM people ORDER BY first_name | [{'first_name': 'Dariana'}, {'first_name': 'Hoyt'}, {'first_name': 'Lizeth'}, {'first_name': 'Mayra'}, {'first_name': 'Nova'}, {'first_name': 'Shannon'}, {'first_name': 'Verna'}, {'first_name': 'Virginie'}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names and birth dates of people, ordered by their names in alphabetical order?[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]What are the names and birth dates of people, ordered by their names in alphabetical order?[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]What are the names and birth dates of people, ordered by their names in alphabetical order?[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]What are the names and birth dates of people, ordered by their names in alphabetical order?[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] |
student_assessment |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id line_1 line_2 city zip_postcode state_province_county country
5 0900 Roderick Oval
New Albina, WA 19200-7914 Suite 096 Linnealand 862 Montana USA
9 966 Dach Ports Apt. 322
Lake Harmonyhaven, VA 65235 Apt. 163 South Minnie 716 Texas USA
*/
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
/*
2 rows from Candidate_Assessments table:
candidate_id qualification assessment_date asessment_outcome_code
111 A 2010-04-07 11:44:34 Pass
121 B 2010-04-17 11:44:34 Pass
*/
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
/*
2 rows from Candidates table:
candidate_id candidate_details
111 Jane
121 Robert
*/
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
/*
2 rows from Courses table:
course_id course_name course_description other_details
301 statistics statistics None
302 English English None
*/
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
/*
2 rows from People table:
person_id first_name middle_name last_name cell_mobile_number email_address login_name password
111 Shannon Elissa Senger 01955267735 [email protected] pgub 5e4ff49a61b3544da3ad7dc7e2cf28847564c64c
121 Virginie Jasmin Hartmann (508)319-2970x043 [email protected] bkkv b063331ea8116befaa7b84c59c6a22200f5f8caa
*/
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from People_Addresses table:
person_address_id person_id address_id date_from date_to
122 111 9 2012-09-26 13:21:00 2018-03-21 09:46:30
257 121 5 2008-07-31 02:17:25 2018-03-09 02:11:12
*/
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
/*
2 rows from Student_Course_Attendance table:
student_id course_id date_of_attendance
111 301 2008-11-04 10:35:13
121 301 2012-04-09 11:44:34
*/
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
/*
2 rows from Student_Course_Registrations table:
student_id course_id registration_date
111 301 2008-11-04 10:35:13
121 301 2008-10-04 10:35:13
*/
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
)
/*
2 rows from Students table:
student_id student_details
111 Marry
121 Martin
*/ | What is the id of the candidate who most recently accessed the course? | SELECT candidate_id FROM candidate_assessments ORDER BY assessment_date DESC LIMIT 1 | [{'candidate_id': 121}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | [QUESTION]What is the semester which most student registered in? Show both the name and the id.[/QUESTION]
[SQL]SELECT T1.semester_name , T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the semester which most student registered in? Show both the name and the id.[/QUESTION]
[SQL]SELECT T1.semester_name , T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the semester which most student registered in? Show both the name and the id.[/QUESTION]
[SQL]SELECT T1.semester_name , T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the semester which most student registered in? Show both the name and the id.[/QUESTION]
[SQL]SELECT T1.semester_name , T1.semester_id FROM Semesters AS T1 JOIN Student_Enrolment AS T2 ON T1.semester_id = T2.semester_id GROUP BY T1.semester_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
geo |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
) |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from border_info table:
state_name border
*/
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from city table:
city_name population country_name state_name
*/
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from highlow table:
state_name highest_elevation lowest_point highest_point lowest_elevation
*/
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
/*
2 rows from lake table:
lake_name area country_name state_name
*/
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from mountain table:
mountain_name mountain_altitude country_name state_name
*/
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
/*
2 rows from river table:
river_name length country_name traverse
*/
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
)
/*
2 rows from state table:
state_name population area country_name capital density
*/ | what is the capital of states that have cities named durham | SELECT t2.capital FROM state AS t2 JOIN city AS t1 ON t2.state_name = t1.state_name WHERE t1.city_name = "durham"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
college_2 |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
) |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
/*
2 rows from advisor table:
s_ID i_ID
24746 19368
79352 95030
*/
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
/*
2 rows from classroom table:
building room_number capacity
Lamberton 134 10
Chandler 375 10
*/
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
/*
2 rows from course table:
course_id title dept_name credits
787 C Programming Mech. Eng. 4
238 The Music of Donovan Mech. Eng. 3
*/
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
/*
2 rows from department table:
dept_name building budget
Civil Eng. Chandler 255041.46
Biology Candlestick 647610.55
*/
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
/*
2 rows from instructor table:
ID name dept_name salary
63395 McKinnon Cybernetics 94333.99
78699 Pingr Statistics 59303.62
*/
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
/*
2 rows from prereq table:
course_id prereq_id
376 130
760 169
*/
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
/*
2 rows from section table:
course_id sec_id semester year building room_number time_slot_id
313 1 Fall 2010 Chandler 804 N
747 1 Spring 2004 Gates 314 K
*/
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
/*
2 rows from student table:
ID name dept_name tot_cred
24746 Schrefl History 4
79352 Rumat Finance 100
*/
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
/*
2 rows from takes table:
ID course_id sec_id semester year grade
65901 401 1 Fall 2003 C-
24932 802 1 Spring 2003 B-
*/
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
/*
2 rows from teaches table:
ID course_id sec_id semester year
34175 747 1 Spring 2004
3199 169 1 Spring 2007
*/
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
)
/*
2 rows from time_slot table:
time_slot_id day start_hr start_min end_hr end_min
A M 8.0000000000 0E-10 8.0000000000 50.0000000000
A W 8.0000000000 0E-10 8.0000000000 50.0000000000
*/ | What are the ids of instructors who didnt' teach? | SELECT id FROM instructor EXCEPT SELECT id FROM teaches | [{'ID': '16807'}, {'ID': '31955'}, {'ID': '35579'}, {'ID': '37687'}, {'ID': '4034'}, {'ID': '50885'}, {'ID': '52647'}, {'ID': '57180'}, {'ID': '58558'}, {'ID': '59795'}, {'ID': '63395'}, {'ID': '64871'}, {'ID': '72553'}, {'ID': '74426'}, {'ID': '78699'}, {'ID': '79653'}, {'ID': '95030'}, {'ID': '96895'}, {'ID': '97302'}] | Hard | false | false | false | false | false | false | false | false | false | false | false | true | false | [QUESTION]Find the first names of all instructors who have taught some course and the course description.[/QUESTION]
[SQL]SELECT T2.emp_fname , T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code[/SQL] | [QUESTION]Find the first names of all instructors who have taught some course and the course description.[/QUESTION]
[SQL]SELECT T2.emp_fname , T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code[/SQL] | [QUESTION]Find the first names of all instructors who have taught some course and the course description.[/QUESTION]
[SQL]SELECT T2.emp_fname , T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code[/SQL] | [QUESTION]Find the first names of all instructors who have taught some course and the course description.[/QUESTION]
[SQL]SELECT T2.emp_fname , T3.crs_description FROM CLASS AS T1 JOIN employee AS T2 ON T1.prof_num = T2.emp_num JOIN course AS T3 ON T1.crs_code = T3.crs_code[/SQL] |
bike_1 |
CREATE TABLE station (
id INTEGER,
name TEXT,
lat NUMERIC,
long NUMERIC,
dock_count INTEGER,
city TEXT,
installation_date TEXT,
PRIMARY KEY (id)
)
CREATE TABLE status (
station_id INTEGER,
bikes_available INTEGER,
docks_available INTEGER,
time TEXT,
FOREIGN KEY(station_id) REFERENCES station (id)
)
CREATE TABLE trip (
id INTEGER,
duration INTEGER,
start_date TEXT,
start_station_name TEXT,
start_station_id INTEGER,
end_date TEXT,
end_station_name TEXT,
end_station_id INTEGER,
bike_id INTEGER,
subscription_type TEXT,
zip_code INTEGER,
PRIMARY KEY (id)
)
CREATE TABLE weather (
date TEXT,
max_temperature_f INTEGER,
mean_temperature_f INTEGER,
min_temperature_f INTEGER,
max_dew_point_f INTEGER,
mean_dew_point_f INTEGER,
min_dew_point_f INTEGER,
max_humidity INTEGER,
mean_humidity INTEGER,
min_humidity INTEGER,
max_sea_level_pressure_inches NUMERIC,
mean_sea_level_pressure_inches NUMERIC,
min_sea_level_pressure_inches NUMERIC,
max_visibility_miles INTEGER,
mean_visibility_miles INTEGER,
min_visibility_miles INTEGER,
"max_wind_Speed_mph" INTEGER,
mean_wind_speed_mph INTEGER,
max_gust_speed_mph INTEGER,
precipitation_inches INTEGER,
cloud_cover INTEGER,
events TEXT,
wind_dir_degrees INTEGER,
zip_code INTEGER
) |
CREATE TABLE station (
id INTEGER,
name TEXT,
lat NUMERIC,
long NUMERIC,
dock_count INTEGER,
city TEXT,
installation_date TEXT,
PRIMARY KEY (id)
)
/*
2 rows from station table:
id name lat long dock_count city installation_date
2 San Jose Diridon Caltrain Station 37.3297320000 -121.9017820000 27 San Jose 8/6/2013
3 San Jose Civic Center 37.3306980000 -121.8889790000 15 San Jose 8/5/2013
*/
CREATE TABLE status (
station_id INTEGER,
bikes_available INTEGER,
docks_available INTEGER,
time TEXT,
FOREIGN KEY(station_id) REFERENCES station (id)
)
/*
2 rows from status table:
station_id bikes_available docks_available time
3 12 3 2015-06-02 12:46:02
3 12 3 2015-06-02 12:47:02
*/
CREATE TABLE trip (
id INTEGER,
duration INTEGER,
start_date TEXT,
start_station_name TEXT,
start_station_id INTEGER,
end_date TEXT,
end_station_name TEXT,
end_station_id INTEGER,
bike_id INTEGER,
subscription_type TEXT,
zip_code INTEGER,
PRIMARY KEY (id)
)
/*
2 rows from trip table:
id duration start_date start_station_name start_station_id end_date end_station_name end_station_id bike_id subscription_type zip_code
900504 384 8/21/2015 17:03 Howard at 2nd 63 8/21/2015 17:10 San Francisco Caltrain 2 (330 Townsend) 69 454 Subscriber 94041
900505 588 8/21/2015 17:03 South Van Ness at Market 66 8/21/2015 17:13 San Francisco Caltrain 2 (330 Townsend) 69 574 Subscriber 95119
*/
CREATE TABLE weather (
date TEXT,
max_temperature_f INTEGER,
mean_temperature_f INTEGER,
min_temperature_f INTEGER,
max_dew_point_f INTEGER,
mean_dew_point_f INTEGER,
min_dew_point_f INTEGER,
max_humidity INTEGER,
mean_humidity INTEGER,
min_humidity INTEGER,
max_sea_level_pressure_inches NUMERIC,
mean_sea_level_pressure_inches NUMERIC,
min_sea_level_pressure_inches NUMERIC,
max_visibility_miles INTEGER,
mean_visibility_miles INTEGER,
min_visibility_miles INTEGER,
"max_wind_Speed_mph" INTEGER,
mean_wind_speed_mph INTEGER,
max_gust_speed_mph INTEGER,
precipitation_inches INTEGER,
cloud_cover INTEGER,
events TEXT,
wind_dir_degrees INTEGER,
zip_code INTEGER
)
/*
2 rows from weather table:
date max_temperature_f mean_temperature_f min_temperature_f max_dew_point_f mean_dew_point_f min_dew_point_f max_humidity mean_humidity min_humidity max_sea_level_pressure_inches mean_sea_level_pressure_inches min_sea_level_pressure_inches max_visibility_miles mean_visibility_miles min_visibility_miles max_wind_Speed_mph mean_wind_speed_mph max_gust_speed_mph precipitation_inches cloud_cover events wind_dir_degrees zip_code
8/29/2013 74 68 61 61 58 56 93 75 57 30.0700000000 30.0200000000 29.9700000000 10 10 10 23 11 28 0 4 286 94107
8/30/2013 78 69 60 61 58 56 90 70 50 30.0500000000 30.0000000000 29.9300000000 10 10 7 29 13 35 0 2 291 94107
*/ | Find the day in which the difference between the max temperature and min temperature was the smallest. Also report the difference. | SELECT date , max_temperature_f - min_temperature_f FROM weather ORDER BY max_temperature_f - min_temperature_f LIMIT 1 | [{'date': '4/16/2015', 'max_temperature_f - min_temperature_f': 0}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | ||||
driving_school |
CREATE TABLE "Addresses" (
address_id INTEGER,
line_1_number_building VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
CREATE TABLE "Customer_Payments" (
customer_id INTEGER NOT NULL,
datetime_payment DATETIME NOT NULL,
payment_method_code VARCHAR(10) NOT NULL,
amount_payment DOUBLE,
PRIMARY KEY (customer_id, datetime_payment),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_address_id INTEGER NOT NULL,
customer_status_code VARCHAR(15) NOT NULL,
date_became_customer DATETIME,
date_of_birth DATETIME,
first_name VARCHAR(80),
last_name VARCHAR(80),
amount_outstanding DOUBLE,
email_address VARCHAR(250),
phone_number VARCHAR(255),
cell_mobile_phone_number VARCHAR(255),
PRIMARY KEY (customer_id),
FOREIGN KEY(customer_address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Lessons" (
lesson_id INTEGER,
customer_id INTEGER NOT NULL,
lesson_status_code VARCHAR(15) NOT NULL,
staff_id INTEGER,
vehicle_id INTEGER NOT NULL,
lesson_date DATETIME,
lesson_time VARCHAR(10),
price DOUBLE,
PRIMARY KEY (lesson_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(vehicle_id) REFERENCES "Vehicles" (vehicle_id)
)
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_address_id INTEGER NOT NULL,
nickname VARCHAR(80),
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
date_of_birth DATETIME,
date_joined_staff DATETIME,
date_left_staff DATETIME,
PRIMARY KEY (staff_id),
FOREIGN KEY(staff_address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Vehicles" (
vehicle_id INTEGER,
vehicle_details VARCHAR(255),
PRIMARY KEY (vehicle_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER,
line_1_number_building VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id line_1_number_building city zip_postcode state_province_county country
1 3904 Stroman Passage Port Melyssa 14445 Georgia USA
2 053 Quigley Island Hagenesfurt 22194 Kentucky USA
*/
CREATE TABLE "Customer_Payments" (
customer_id INTEGER NOT NULL,
datetime_payment DATETIME NOT NULL,
payment_method_code VARCHAR(10) NOT NULL,
amount_payment DOUBLE,
PRIMARY KEY (customer_id, datetime_payment),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Payments table:
customer_id datetime_payment payment_method_code amount_payment
11 2018-02-05 18:44:46 Direct Debit 9570.93
2 2018-02-24 10:07:05 Direct Debit 8180.26
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_address_id INTEGER NOT NULL,
customer_status_code VARCHAR(15) NOT NULL,
date_became_customer DATETIME,
date_of_birth DATETIME,
first_name VARCHAR(80),
last_name VARCHAR(80),
amount_outstanding DOUBLE,
email_address VARCHAR(250),
phone_number VARCHAR(255),
cell_mobile_phone_number VARCHAR(255),
PRIMARY KEY (customer_id),
FOREIGN KEY(customer_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Customers table:
customer_id customer_address_id customer_status_code date_became_customer date_of_birth first_name last_name amount_outstanding email_address phone_number cell_mobile_phone_number
1 13 Bad Customer 2016-05-11 17:03:48 1998-12-15 13:24:40 Carole Bernhard 255.0 [email protected] 07278206718 861-638-9797
2 10 Bad Customer 2015-11-16 22:52:14 1995-07-17 12:13:16 Genevieve Terry 7256.0 [email protected] +14(5)2351480248 578-518-4785x612
*/
CREATE TABLE "Lessons" (
lesson_id INTEGER,
customer_id INTEGER NOT NULL,
lesson_status_code VARCHAR(15) NOT NULL,
staff_id INTEGER,
vehicle_id INTEGER NOT NULL,
lesson_date DATETIME,
lesson_time VARCHAR(10),
price DOUBLE,
PRIMARY KEY (lesson_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(vehicle_id) REFERENCES "Vehicles" (vehicle_id)
)
/*
2 rows from Lessons table:
lesson_id customer_id lesson_status_code staff_id vehicle_id lesson_date lesson_time price
1 6 Cancelled 8 3 2018-02-28 10:55:36 5 199.0
2 8 Cancelled 14 3 2018-03-07 16:12:36 6 167.0
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_address_id INTEGER NOT NULL,
nickname VARCHAR(80),
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
date_of_birth DATETIME,
date_joined_staff DATETIME,
date_left_staff DATETIME,
PRIMARY KEY (staff_id),
FOREIGN KEY(staff_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Staff table:
staff_id staff_address_id nickname first_name middle_name last_name date_of_birth date_joined_staff date_left_staff
1 14 thompson.constantin Janessa Amara Sawayn 2010-12-08 16:55:14 2017-04-27 03:21:26 2018-03-23 22:53:12
2 3 santos45 Camylle Icie Weissnat 2015-08-01 13:22:43 2016-06-06 08:54:28 2018-03-10 15:25:00
*/
CREATE TABLE "Vehicles" (
vehicle_id INTEGER,
vehicle_details VARCHAR(255),
PRIMARY KEY (vehicle_id)
)
/*
2 rows from Vehicles table:
vehicle_id vehicle_details
1 Van
2 Truck
*/ | What is the total time for all lessons taught by Janessa Sawayn? | SELECT sum(lesson_time) FROM Lessons AS T1 JOIN Staff AS T2 ON T1.staff_id = T2.staff_id WHERE T2.first_name = "Janessa" AND T2.last_name = "Sawayn"; | [{'sum(lesson_time)': 9}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | papers using WebKB | SELECT DISTINCT t3.paperid FROM paperdataset AS t2 JOIN dataset AS t1 ON t2.datasetid = t1.datasetid JOIN paper AS t3 ON t3.paperid = t2.paperid WHERE t1.datasetname = "WebKB"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
products_for_hire |
CREATE TABLE "Bookings" (
booking_id INTEGER,
customer_id INTEGER NOT NULL,
booking_status_code VARCHAR(10) NOT NULL,
returned_damaged_yn VARCHAR(40),
booking_start_date DATETIME,
booking_end_date DATETIME,
count_hired VARCHAR(40),
amount_payable DECIMAL(19, 4),
amount_of_discount DECIMAL(19, 4),
amount_outstanding DECIMAL(19, 4),
amount_of_refund DECIMAL(19, 4),
PRIMARY KEY (booking_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
coupon_id INTEGER NOT NULL,
good_or_bad_customer VARCHAR(4),
first_name VARCHAR(80),
last_name VARCHAR(80),
gender_mf VARCHAR(1),
date_became_customer DATETIME,
date_last_hire DATETIME,
PRIMARY KEY (customer_id),
FOREIGN KEY(coupon_id) REFERENCES "Discount_Coupons" (coupon_id)
)
CREATE TABLE "Discount_Coupons" (
coupon_id INTEGER,
date_issued DATETIME,
coupon_amount DECIMAL(19, 4),
PRIMARY KEY (coupon_id)
)
CREATE TABLE "Payments" (
payment_id INTEGER,
booking_id INTEGER,
customer_id INTEGER NOT NULL,
payment_type_code VARCHAR(15) NOT NULL,
amount_paid_in_full_yn VARCHAR(1),
payment_date DATETIME,
amount_due DECIMAL(19, 4),
amount_paid DECIMAL(19, 4),
PRIMARY KEY (payment_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
)
CREATE TABLE "Products_Booked" (
booking_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
returned_yn VARCHAR(1),
returned_late_yn VARCHAR(1),
booked_count INTEGER,
booked_amount FLOAT,
PRIMARY KEY (booking_id, product_id),
FOREIGN KEY(product_id) REFERENCES "Products_for_Hire" (product_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
)
CREATE TABLE "Products_for_Hire" (
product_id INTEGER,
product_type_code VARCHAR(15) NOT NULL,
daily_hire_cost DECIMAL(19, 4),
product_name VARCHAR(80),
product_description VARCHAR(255),
PRIMARY KEY (product_id)
)
CREATE TABLE "View_Product_Availability" (
product_id INTEGER NOT NULL,
booking_id INTEGER NOT NULL,
status_date DATETIME,
available_yn VARCHAR(1),
PRIMARY KEY (status_date),
FOREIGN KEY(product_id) REFERENCES "Products_for_Hire" (product_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
) |
CREATE TABLE "Bookings" (
booking_id INTEGER,
customer_id INTEGER NOT NULL,
booking_status_code VARCHAR(10) NOT NULL,
returned_damaged_yn VARCHAR(40),
booking_start_date DATETIME,
booking_end_date DATETIME,
count_hired VARCHAR(40),
amount_payable DECIMAL(19, 4),
amount_of_discount DECIMAL(19, 4),
amount_outstanding DECIMAL(19, 4),
amount_of_refund DECIMAL(19, 4),
PRIMARY KEY (booking_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Bookings table:
booking_id customer_id booking_status_code returned_damaged_yn booking_start_date booking_end_date count_hired amount_payable amount_of_discount amount_outstanding amount_of_refund
1 7 Provisional 1 2016-12-07 23:39:17 2018-02-01 16:39:13 298 214.3900 71.4500 28.2200 179.1400
2 15 Confirmed 1 2017-06-16 11:42:31 2018-02-19 21:53:31 331 386.9200 83.8200 57.6200 183.6800
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
coupon_id INTEGER NOT NULL,
good_or_bad_customer VARCHAR(4),
first_name VARCHAR(80),
last_name VARCHAR(80),
gender_mf VARCHAR(1),
date_became_customer DATETIME,
date_last_hire DATETIME,
PRIMARY KEY (customer_id),
FOREIGN KEY(coupon_id) REFERENCES "Discount_Coupons" (coupon_id)
)
/*
2 rows from Customers table:
customer_id coupon_id good_or_bad_customer first_name last_name gender_mf date_became_customer date_last_hire
1 12 good Geovany Homenick 0 2017-10-20 12:13:17 2018-02-27 18:55:26
2 14 good Jailyn Gerlach 0 2015-04-06 21:18:37 2018-01-30 04:47:13
*/
CREATE TABLE "Discount_Coupons" (
coupon_id INTEGER,
date_issued DATETIME,
coupon_amount DECIMAL(19, 4),
PRIMARY KEY (coupon_id)
)
/*
2 rows from Discount_Coupons table:
coupon_id date_issued coupon_amount
1 2017-09-06 01:33:27 500.0000
2 2018-02-20 09:40:56 686.2500
*/
CREATE TABLE "Payments" (
payment_id INTEGER,
booking_id INTEGER,
customer_id INTEGER NOT NULL,
payment_type_code VARCHAR(15) NOT NULL,
amount_paid_in_full_yn VARCHAR(1),
payment_date DATETIME,
amount_due DECIMAL(19, 4),
amount_paid DECIMAL(19, 4),
PRIMARY KEY (payment_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
)
/*
2 rows from Payments table:
payment_id booking_id customer_id payment_type_code amount_paid_in_full_yn payment_date amount_due amount_paid
1 6 15 Check 1 2018-03-09 16:28:00 369.5200 206.2700
2 9 12 Cash 1 2018-03-03 13:39:44 278.6000 666.4500
*/
CREATE TABLE "Products_Booked" (
booking_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
returned_yn VARCHAR(1),
returned_late_yn VARCHAR(1),
booked_count INTEGER,
booked_amount FLOAT,
PRIMARY KEY (booking_id, product_id),
FOREIGN KEY(product_id) REFERENCES "Products_for_Hire" (product_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
)
/*
2 rows from Products_Booked table:
booking_id product_id returned_yn returned_late_yn booked_count booked_amount
4 1 1 1 5 309.73
14 1 1 0 3 102.76
*/
CREATE TABLE "Products_for_Hire" (
product_id INTEGER,
product_type_code VARCHAR(15) NOT NULL,
daily_hire_cost DECIMAL(19, 4),
product_name VARCHAR(80),
product_description VARCHAR(255),
PRIMARY KEY (product_id)
)
/*
2 rows from Products_for_Hire table:
product_id product_type_code daily_hire_cost product_name product_description
1 Cutlery 26.1500 Book collection C Anna Karenina
2 Cutlery 15.6200 Book collection B War and Peace
*/
CREATE TABLE "View_Product_Availability" (
product_id INTEGER NOT NULL,
booking_id INTEGER NOT NULL,
status_date DATETIME,
available_yn VARCHAR(1),
PRIMARY KEY (status_date),
FOREIGN KEY(product_id) REFERENCES "Products_for_Hire" (product_id),
FOREIGN KEY(booking_id) REFERENCES "Bookings" (booking_id)
)
/*
2 rows from View_Product_Availability table:
product_id booking_id status_date available_yn
1 5 2018-03-18 05:25:55 1
2 5 2018-03-21 15:20:32 0
*/ | What are the first name, last name, and gender of all the good customers? Order by their last name. | SELECT first_name , last_name , gender_mf FROM customers WHERE good_or_bad_customer = 'good' ORDER BY last_name | [{'first_name': 'Tyler', 'last_name': 'Breitenberg', 'gender_mf': '1'}, {'first_name': 'Elinore', 'last_name': 'Crona', 'gender_mf': '0'}, {'first_name': 'Jailyn', 'last_name': 'Gerlach', 'gender_mf': '0'}, {'first_name': 'Ericka', 'last_name': 'Greenholt', 'gender_mf': '0'}, {'first_name': 'Geovany', 'last_name': 'Homenick', 'gender_mf': '0'}, {'first_name': 'Rosalee', 'last_name': 'Kessler', 'gender_mf': '0'}, {'first_name': 'Laury', 'last_name': 'Lemke', 'gender_mf': '1'}, {'first_name': 'German', 'last_name': 'Little', 'gender_mf': '1'}, {'first_name': 'Maximilian', 'last_name': 'Murphy', 'gender_mf': '0'}, {'first_name': 'Vergie', 'last_name': 'Nicolas', 'gender_mf': '0'}, {'first_name': 'Marilou', 'last_name': 'Strosin', 'gender_mf': '1'}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] |
manufactory_1 |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
) |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
/*
2 rows from Manufacturers table:
Code Name Headquarter Founder Revenue
1 Sony Tokyo Andy 120.0
2 Creative Labs Austin Owen 100.0
*/
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
)
/*
2 rows from Products table:
Code Name Price Manufacturer
1 Hard drive 240.0000000000 5
2 Memory 120.0000000000 6
*/ | Select the names and the prices of all the products in the store. | SELECT name , price FROM products | [{'Name': 'Hard drive', 'Price': 240}, {'Name': 'Memory', 'Price': 120}, {'Name': 'ZIP drive', 'Price': 150}, {'Name': 'Floppy disk', 'Price': 5}, {'Name': 'Monitor', 'Price': 240}, {'Name': 'DVD drive', 'Price': 180}, {'Name': 'CD drive', 'Price': 90}, {'Name': 'Printer', 'Price': 270}, {'Name': 'Toner cartridge', 'Price': 66}, {'Name': 'DVD burner', 'Price': 180}, {'Name': 'DVD drive', 'Price': 150}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Find the names of all stores in Khanewal District.[/QUESTION]
[SQL]SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District"[/SQL] | [QUESTION]Find the names of all stores in Khanewal District.[/QUESTION]
[SQL]SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District"[/SQL] | [QUESTION]Find the names of all stores in Khanewal District.[/QUESTION]
[SQL]SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District"[/SQL] | [QUESTION]Find the names of all stores in Khanewal District.[/QUESTION]
[SQL]SELECT t1.store_name FROM store AS t1 JOIN store_district AS t2 ON t1.store_id = t2.store_id JOIN district AS t3 ON t2.district_id = t3.district_id WHERE t3.district_name = "Khanewal District"[/SQL] |
concert_singer |
CREATE TABLE concert (
"concert_ID" INTEGER,
"concert_Name" TEXT,
"Theme" TEXT,
"Stadium_ID" TEXT,
"Year" TEXT,
PRIMARY KEY ("concert_ID"),
FOREIGN KEY("Stadium_ID") REFERENCES stadium ("Stadium_ID")
)
CREATE TABLE singer (
"Singer_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Song_Name" TEXT,
"Song_release_year" TEXT,
"Age" INTEGER,
"Is_male" BOOLEAN,
PRIMARY KEY ("Singer_ID")
)
CREATE TABLE singer_in_concert (
"concert_ID" INTEGER,
"Singer_ID" TEXT,
PRIMARY KEY ("concert_ID", "Singer_ID"),
FOREIGN KEY("concert_ID") REFERENCES concert ("concert_ID"),
FOREIGN KEY("Singer_ID") REFERENCES singer ("Singer_ID")
)
CREATE TABLE stadium (
"Stadium_ID" INTEGER,
"Location" TEXT,
"Name" TEXT,
"Capacity" INTEGER,
"Highest" INTEGER,
"Lowest" INTEGER,
"Average" INTEGER,
PRIMARY KEY ("Stadium_ID")
) |
CREATE TABLE concert (
"concert_ID" INTEGER,
"concert_Name" TEXT,
"Theme" TEXT,
"Stadium_ID" TEXT,
"Year" TEXT,
PRIMARY KEY ("concert_ID"),
FOREIGN KEY("Stadium_ID") REFERENCES stadium ("Stadium_ID")
)
/*
2 rows from concert table:
concert_ID concert_Name Theme Stadium_ID Year
1 Auditions Free choice 1 2014
2 Super bootcamp Free choice 2 2 2014
*/
CREATE TABLE singer (
"Singer_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Song_Name" TEXT,
"Song_release_year" TEXT,
"Age" INTEGER,
"Is_male" BOOLEAN,
PRIMARY KEY ("Singer_ID")
)
/*
2 rows from singer table:
Singer_ID Name Country Song_Name Song_release_year Age Is_male
1 Joe Sharp Netherlands You 1992 52 True
2 Timbaland United States Dangerous 2008 32 True
*/
CREATE TABLE singer_in_concert (
"concert_ID" INTEGER,
"Singer_ID" TEXT,
PRIMARY KEY ("concert_ID", "Singer_ID"),
FOREIGN KEY("concert_ID") REFERENCES concert ("concert_ID"),
FOREIGN KEY("Singer_ID") REFERENCES singer ("Singer_ID")
)
/*
2 rows from singer_in_concert table:
concert_ID Singer_ID
1 2
1 3
*/
CREATE TABLE stadium (
"Stadium_ID" INTEGER,
"Location" TEXT,
"Name" TEXT,
"Capacity" INTEGER,
"Highest" INTEGER,
"Lowest" INTEGER,
"Average" INTEGER,
PRIMARY KEY ("Stadium_ID")
)
/*
2 rows from stadium table:
Stadium_ID Location Name Capacity Highest Lowest Average
1 Raith Rovers Stark's Park 10104 4812 1294 2106
2 Ayr United Somerset Park 11998 2363 1057 1477
*/ | What are the number of concerts that occurred in the stadium with the largest capacity ? | SELECT count(*) FROM concert WHERE stadium_id = (SELECT stadium_id FROM stadium ORDER BY capacity DESC LIMIT 1) | [{'count(*)': 0}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] |
geo |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
) |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from border_info table:
state_name border
*/
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from city table:
city_name population country_name state_name
*/
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from highlow table:
state_name highest_elevation lowest_point highest_point lowest_elevation
*/
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
/*
2 rows from lake table:
lake_name area country_name state_name
*/
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from mountain table:
mountain_name mountain_altitude country_name state_name
*/
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
/*
2 rows from river table:
river_name length country_name traverse
*/
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
)
/*
2 rows from state table:
state_name population area country_name capital density
*/ | what states surround kentucky | SELECT border FROM border_info WHERE state_name = "kentucky"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
hospital_1 |
CREATE TABLE "Affiliated_With" (
"Physician" INTEGER NOT NULL,
"Department" INTEGER NOT NULL,
"PrimaryAffiliation" BOOLEAN NOT NULL,
PRIMARY KEY ("Physician", "Department"),
CONSTRAINT "fk_Affiliated_With_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Affiliated_With_Department_DepartmentID" FOREIGN KEY("Department") REFERENCES "Department" ("DepartmentID")
)
CREATE TABLE "Appointment" (
"AppointmentID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"PrepNurse" INTEGER,
"Physician" INTEGER NOT NULL,
"Start" DATETIME NOT NULL,
"End" DATETIME NOT NULL,
"ExaminationRoom" TEXT NOT NULL,
PRIMARY KEY ("AppointmentID"),
CONSTRAINT "fk_Appointment_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Appointment_Nurse_EmployeeID" FOREIGN KEY("PrepNurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_Appointment_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Block" (
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
PRIMARY KEY ("BlockFloor", "BlockCode")
)
CREATE TABLE "Department" (
"DepartmentID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Head" INTEGER NOT NULL,
CONSTRAINT "pk_Department" PRIMARY KEY ("DepartmentID"),
CONSTRAINT "fk_Department_Physician_EmployeeID" FOREIGN KEY("Head") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Medication" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Brand" VARCHAR(30) NOT NULL,
"Description" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Nurse" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"Registered" BOOLEAN NOT NULL,
"SSN" INTEGER NOT NULL,
PRIMARY KEY ("EmployeeID")
)
CREATE TABLE "On_Call" (
"Nurse" INTEGER NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"OnCallStart" DATETIME NOT NULL,
"OnCallEnd" DATETIME NOT NULL,
PRIMARY KEY ("Nurse", "BlockFloor", "BlockCode", "OnCallStart", "OnCallEnd"),
CONSTRAINT "fk_OnCall_Nurse_EmployeeID" FOREIGN KEY("Nurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_OnCall_Block_Floor" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
CREATE TABLE "Patient" (
"SSN" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Address" VARCHAR(30) NOT NULL,
"Phone" VARCHAR(30) NOT NULL,
"InsuranceID" INTEGER NOT NULL,
"PCP" INTEGER NOT NULL,
PRIMARY KEY ("SSN"),
CONSTRAINT "fk_Patient_Physician_EmployeeID" FOREIGN KEY("PCP") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Physician" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"SSN" INTEGER NOT NULL,
CONSTRAINT pk_physician PRIMARY KEY ("EmployeeID")
)
CREATE TABLE "Prescribes" (
"Physician" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Medication" INTEGER NOT NULL,
"Date" DATETIME NOT NULL,
"Appointment" INTEGER,
"Dose" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Physician", "Patient", "Medication", "Date"),
CONSTRAINT "fk_Prescribes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Prescribes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Prescribes_Medication_Code" FOREIGN KEY("Medication") REFERENCES "Medication" ("Code"),
CONSTRAINT "fk_Prescribes_Appointment_AppointmentID" FOREIGN KEY("Appointment") REFERENCES "Appointment" ("AppointmentID")
)
CREATE TABLE "Procedures" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Cost" REAL NOT NULL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Room" (
"RoomNumber" INTEGER NOT NULL,
"RoomType" VARCHAR(30) NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"Unavailable" BOOLEAN NOT NULL,
PRIMARY KEY ("RoomNumber"),
CONSTRAINT "fk_Room_Block_PK" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
CREATE TABLE "Stay" (
"StayID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Room" INTEGER NOT NULL,
"StayStart" DATETIME NOT NULL,
"StayEnd" DATETIME NOT NULL,
PRIMARY KEY ("StayID"),
CONSTRAINT "fk_Stay_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Stay_Room_Number" FOREIGN KEY("Room") REFERENCES "Room" ("RoomNumber")
)
CREATE TABLE "Trained_In" (
"Physician" INTEGER NOT NULL,
"Treatment" INTEGER NOT NULL,
"CertificationDate" DATETIME NOT NULL,
"CertificationExpires" DATETIME NOT NULL,
PRIMARY KEY ("Physician", "Treatment"),
CONSTRAINT "fk_Trained_In_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Trained_In_Procedures_Code" FOREIGN KEY("Treatment") REFERENCES "Procedures" ("Code")
)
CREATE TABLE "Undergoes" (
"Patient" INTEGER NOT NULL,
"Procedures" INTEGER NOT NULL,
"Stay" INTEGER NOT NULL,
"DateUndergoes" DATETIME NOT NULL,
"Physician" INTEGER NOT NULL,
"AssistingNurse" INTEGER,
PRIMARY KEY ("Patient", "Procedures", "Stay", "DateUndergoes"),
CONSTRAINT "fk_Undergoes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Undergoes_Procedures_Code" FOREIGN KEY("Procedures") REFERENCES "Procedures" ("Code"),
CONSTRAINT "fk_Undergoes_Stay_StayID" FOREIGN KEY("Stay") REFERENCES "Stay" ("StayID"),
CONSTRAINT "fk_Undergoes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Undergoes_Nurse_EmployeeID" FOREIGN KEY("AssistingNurse") REFERENCES "Nurse" ("EmployeeID")
) |
CREATE TABLE "Affiliated_With" (
"Physician" INTEGER NOT NULL,
"Department" INTEGER NOT NULL,
"PrimaryAffiliation" BOOLEAN NOT NULL,
PRIMARY KEY ("Physician", "Department"),
CONSTRAINT "fk_Affiliated_With_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Affiliated_With_Department_DepartmentID" FOREIGN KEY("Department") REFERENCES "Department" ("DepartmentID")
)
/*
2 rows from Affiliated_With table:
Physician Department PrimaryAffiliation
1 1 True
2 1 True
*/
CREATE TABLE "Appointment" (
"AppointmentID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"PrepNurse" INTEGER,
"Physician" INTEGER NOT NULL,
"Start" DATETIME NOT NULL,
"End" DATETIME NOT NULL,
"ExaminationRoom" TEXT NOT NULL,
PRIMARY KEY ("AppointmentID"),
CONSTRAINT "fk_Appointment_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Appointment_Nurse_EmployeeID" FOREIGN KEY("PrepNurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_Appointment_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Appointment table:
AppointmentID Patient PrepNurse Physician Start End ExaminationRoom
13216584 100000001 101 1 2008-04-24 10:00:00 2008-04-24 11:00:00 A
26548913 100000002 101 2 2008-04-24 10:00:00 2008-04-24 11:00:00 B
*/
CREATE TABLE "Block" (
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
PRIMARY KEY ("BlockFloor", "BlockCode")
)
/*
2 rows from Block table:
BlockFloor BlockCode
1 1
1 2
*/
CREATE TABLE "Department" (
"DepartmentID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Head" INTEGER NOT NULL,
CONSTRAINT "pk_Department" PRIMARY KEY ("DepartmentID"),
CONSTRAINT "fk_Department_Physician_EmployeeID" FOREIGN KEY("Head") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Department table:
DepartmentID Name Head
1 General Medicine 4
2 Surgery 7
*/
CREATE TABLE "Medication" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Brand" VARCHAR(30) NOT NULL,
"Description" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Code")
)
/*
2 rows from Medication table:
Code Name Brand Description
1 Procrastin-X X N/A
2 Thesisin Foo Labs N/A
*/
CREATE TABLE "Nurse" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"Registered" BOOLEAN NOT NULL,
"SSN" INTEGER NOT NULL,
PRIMARY KEY ("EmployeeID")
)
/*
2 rows from Nurse table:
EmployeeID Name Position Registered SSN
101 Carla Espinosa Head Nurse True 111111110
102 Laverne Roberts Nurse True 222222220
*/
CREATE TABLE "On_Call" (
"Nurse" INTEGER NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"OnCallStart" DATETIME NOT NULL,
"OnCallEnd" DATETIME NOT NULL,
PRIMARY KEY ("Nurse", "BlockFloor", "BlockCode", "OnCallStart", "OnCallEnd"),
CONSTRAINT "fk_OnCall_Nurse_EmployeeID" FOREIGN KEY("Nurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_OnCall_Block_Floor" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
/*
2 rows from On_Call table:
Nurse BlockFloor BlockCode OnCallStart OnCallEnd
101 1 1 2008-11-04 11:00:00 2008-11-04 19:00:00
101 1 2 2008-11-04 11:00:00 2008-11-04 19:00:00
*/
CREATE TABLE "Patient" (
"SSN" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Address" VARCHAR(30) NOT NULL,
"Phone" VARCHAR(30) NOT NULL,
"InsuranceID" INTEGER NOT NULL,
"PCP" INTEGER NOT NULL,
PRIMARY KEY ("SSN"),
CONSTRAINT "fk_Patient_Physician_EmployeeID" FOREIGN KEY("PCP") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Patient table:
SSN Name Address Phone InsuranceID PCP
100000001 John Smith 42 Foobar Lane 555-0256 68476213 1
100000002 Grace Ritchie 37 Snafu Drive 555-0512 36546321 2
*/
CREATE TABLE "Physician" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"SSN" INTEGER NOT NULL,
CONSTRAINT pk_physician PRIMARY KEY ("EmployeeID")
)
/*
2 rows from Physician table:
EmployeeID Name Position SSN
1 John Dorian Staff Internist 111111111
2 Elliot Reid Attending Physician 222222222
*/
CREATE TABLE "Prescribes" (
"Physician" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Medication" INTEGER NOT NULL,
"Date" DATETIME NOT NULL,
"Appointment" INTEGER,
"Dose" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Physician", "Patient", "Medication", "Date"),
CONSTRAINT "fk_Prescribes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Prescribes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Prescribes_Medication_Code" FOREIGN KEY("Medication") REFERENCES "Medication" ("Code"),
CONSTRAINT "fk_Prescribes_Appointment_AppointmentID" FOREIGN KEY("Appointment") REFERENCES "Appointment" ("AppointmentID")
)
/*
2 rows from Prescribes table:
Physician Patient Medication Date Appointment Dose
1 100000001 1 2008-04-24 10:47:00 13216584 5
9 100000004 2 2008-04-27 10:53:00 86213939 10
*/
CREATE TABLE "Procedures" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Cost" REAL NOT NULL,
PRIMARY KEY ("Code")
)
/*
2 rows from Procedures table:
Code Name Cost
1 Reverse Rhinopodoplasty 1500.0
2 Obtuse Pyloric Recombobulation 3750.0
*/
CREATE TABLE "Room" (
"RoomNumber" INTEGER NOT NULL,
"RoomType" VARCHAR(30) NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"Unavailable" BOOLEAN NOT NULL,
PRIMARY KEY ("RoomNumber"),
CONSTRAINT "fk_Room_Block_PK" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
/*
2 rows from Room table:
RoomNumber RoomType BlockFloor BlockCode Unavailable
101 Single 1 1 False
102 Single 1 1 False
*/
CREATE TABLE "Stay" (
"StayID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Room" INTEGER NOT NULL,
"StayStart" DATETIME NOT NULL,
"StayEnd" DATETIME NOT NULL,
PRIMARY KEY ("StayID"),
CONSTRAINT "fk_Stay_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Stay_Room_Number" FOREIGN KEY("Room") REFERENCES "Room" ("RoomNumber")
)
/*
2 rows from Stay table:
StayID Patient Room StayStart StayEnd
3215 100000001 111 2008-05-01 00:00:00 2008-05-04 00:00:00
3216 100000003 123 2008-05-03 00:00:00 2008-05-14 00:00:00
*/
CREATE TABLE "Trained_In" (
"Physician" INTEGER NOT NULL,
"Treatment" INTEGER NOT NULL,
"CertificationDate" DATETIME NOT NULL,
"CertificationExpires" DATETIME NOT NULL,
PRIMARY KEY ("Physician", "Treatment"),
CONSTRAINT "fk_Trained_In_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Trained_In_Procedures_Code" FOREIGN KEY("Treatment") REFERENCES "Procedures" ("Code")
)
/*
2 rows from Trained_In table:
Physician Treatment CertificationDate CertificationExpires
3 1 2008-01-01 00:00:00 2008-12-31 00:00:00
3 2 2008-01-01 00:00:00 2008-12-31 00:00:00
*/
CREATE TABLE "Undergoes" (
"Patient" INTEGER NOT NULL,
"Procedures" INTEGER NOT NULL,
"Stay" INTEGER NOT NULL,
"DateUndergoes" DATETIME NOT NULL,
"Physician" INTEGER NOT NULL,
"AssistingNurse" INTEGER,
PRIMARY KEY ("Patient", "Procedures", "Stay", "DateUndergoes"),
CONSTRAINT "fk_Undergoes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Undergoes_Procedures_Code" FOREIGN KEY("Procedures") REFERENCES "Procedures" ("Code"),
CONSTRAINT "fk_Undergoes_Stay_StayID" FOREIGN KEY("Stay") REFERENCES "Stay" ("StayID"),
CONSTRAINT "fk_Undergoes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Undergoes_Nurse_EmployeeID" FOREIGN KEY("AssistingNurse") REFERENCES "Nurse" ("EmployeeID")
)
/*
2 rows from Undergoes table:
Patient Procedures Stay DateUndergoes Physician AssistingNurse
100000001 6 3215 2008-05-02 00:00:00 3 101
100000001 2 3215 2008-05-03 00:00:00 7 101
*/ | Find the number of rooms located on each block floor. | SELECT count(*) , T1.blockfloor FROM BLOCK AS T1 JOIN room AS T2 ON T1.blockfloor = T2.blockfloor AND T1.blockcode = T2.blockcode GROUP BY T1.blockfloor | [{'count(*)': 9, 'BlockFloor': 1}, {'count(*)': 9, 'BlockFloor': 2}, {'count(*)': 9, 'BlockFloor': 3}, {'count(*)': 9, 'BlockFloor': 4}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]Find the number of classes offered for all class rooms that held at least 2 classes.[/QUESTION]
[SQL]SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2[/SQL] | [QUESTION]Find the number of classes offered for all class rooms that held at least 2 classes.[/QUESTION]
[SQL]SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2[/SQL] | [QUESTION]Find the number of classes offered for all class rooms that held at least 2 classes.[/QUESTION]
[SQL]SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2[/SQL] |
|
customers_and_invoices |
CREATE TABLE "Accounts" (
account_id INTEGER,
customer_id INTEGER NOT NULL,
date_account_opened DATETIME,
account_name VARCHAR(50),
other_account_details VARCHAR(255),
PRIMARY KEY (account_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_first_name VARCHAR(50),
customer_middle_initial VARCHAR(1),
customer_last_name VARCHAR(50),
gender VARCHAR(1),
email_address VARCHAR(255),
login_name VARCHAR(80),
login_password VARCHAR(20),
phone_number VARCHAR(255),
town_city VARCHAR(50),
state_county_province VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Financial_Transactions" (
transaction_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
invoice_number INTEGER,
transaction_type VARCHAR(15) NOT NULL,
transaction_date DATETIME,
transaction_amount DECIMAL(19, 4),
transaction_comment VARCHAR(255),
other_transaction_details VARCHAR(255),
FOREIGN KEY(account_id) REFERENCES "Accounts" (account_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number)
)
CREATE TABLE "Invoice_Line_Items" (
order_item_id INTEGER NOT NULL,
invoice_number INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_title VARCHAR(80),
product_quantity VARCHAR(50),
product_price DECIMAL(19, 4),
derived_product_cost DECIMAL(19, 4),
derived_vat_payable DECIMAL(19, 4),
derived_total_cost DECIMAL(19, 4),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number),
FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)
CREATE TABLE "Invoices" (
invoice_number INTEGER,
order_id INTEGER NOT NULL,
invoice_date DATETIME,
PRIMARY KEY (invoice_number),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_quantity VARCHAR(50),
other_order_item_details VARCHAR(255),
PRIMARY KEY (order_item_id),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
date_order_placed DATETIME NOT NULL,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Product_Categories" (
production_type_code VARCHAR(15),
product_type_description VARCHAR(80),
vat_rating DECIMAL(19, 4),
PRIMARY KEY (production_type_code)
)
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
production_type_code VARCHAR(15) NOT NULL,
unit_price DECIMAL(19, 4),
product_name VARCHAR(80),
product_color VARCHAR(20),
product_size VARCHAR(20),
PRIMARY KEY (product_id),
FOREIGN KEY(production_type_code) REFERENCES "Product_Categories" (production_type_code)
) |
CREATE TABLE "Accounts" (
account_id INTEGER,
customer_id INTEGER NOT NULL,
date_account_opened DATETIME,
account_name VARCHAR(50),
other_account_details VARCHAR(255),
PRIMARY KEY (account_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Accounts table:
account_id customer_id date_account_opened account_name other_account_details
1 8 2016-07-30 22:22:24 900 Regular
2 3 2017-05-29 16:45:17 520 VIP
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_first_name VARCHAR(50),
customer_middle_initial VARCHAR(1),
customer_last_name VARCHAR(50),
gender VARCHAR(1),
email_address VARCHAR(255),
login_name VARCHAR(80),
login_password VARCHAR(20),
phone_number VARCHAR(255),
town_city VARCHAR(50),
state_county_province VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id customer_first_name customer_middle_initial customer_last_name gender email_address login_name login_password phone_number town_city state_county_province country
1 Dee A Larkin 1 [email protected] xhartmann 77789d292604ea04406f 241.796.1219x37862 North Nellie WestVirginia USA
2 Brennon H Weimann 0 [email protected] shayne.lesch ce97a3e4539347daab96 (943)219-4234x415 South Isabell Oklahoma USA
*/
CREATE TABLE "Financial_Transactions" (
transaction_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
invoice_number INTEGER,
transaction_type VARCHAR(15) NOT NULL,
transaction_date DATETIME,
transaction_amount DECIMAL(19, 4),
transaction_comment VARCHAR(255),
other_transaction_details VARCHAR(255),
FOREIGN KEY(account_id) REFERENCES "Accounts" (account_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number)
)
/*
2 rows from Financial_Transactions table:
transaction_id account_id invoice_number transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 13 12 Payment 2018-03-15 21:13:57 613.9600 None None
2 9 1 Payment 2018-03-13 13:27:46 368.4600 None None
*/
CREATE TABLE "Invoice_Line_Items" (
order_item_id INTEGER NOT NULL,
invoice_number INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_title VARCHAR(80),
product_quantity VARCHAR(50),
product_price DECIMAL(19, 4),
derived_product_cost DECIMAL(19, 4),
derived_vat_payable DECIMAL(19, 4),
derived_total_cost DECIMAL(19, 4),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number),
FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)
/*
2 rows from Invoice_Line_Items table:
order_item_id invoice_number product_id product_title product_quantity product_price derived_product_cost derived_vat_payable derived_total_cost
14 9 5 prod_name 4 742.3700 191.1100 None 69.8200
3 9 15 prod_name 1 814.8700 176.2900 None 59.5600
*/
CREATE TABLE "Invoices" (
invoice_number INTEGER,
order_id INTEGER NOT NULL,
invoice_date DATETIME,
PRIMARY KEY (invoice_number),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)
/*
2 rows from Invoices table:
invoice_number order_id invoice_date
1 9 2018-03-01 16:40:48
2 9 2018-03-20 00:21:41
*/
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_quantity VARCHAR(50),
other_order_item_details VARCHAR(255),
PRIMARY KEY (order_item_id),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
order_item_id order_id product_id product_quantity other_order_item_details
1 4 4 6 None
2 4 10 7 None
*/
CREATE TABLE "Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
date_order_placed DATETIME NOT NULL,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Orders table:
order_id customer_id date_order_placed order_details
1 12 2012-06-27 20:49:56 None
2 12 2012-08-25 07:51:54 None
*/
CREATE TABLE "Product_Categories" (
production_type_code VARCHAR(15),
product_type_description VARCHAR(80),
vat_rating DECIMAL(19, 4),
PRIMARY KEY (production_type_code)
)
/*
2 rows from Product_Categories table:
production_type_code product_type_description vat_rating
Food Food 15.8400
DVDs Dvd products 11.4000
*/
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
production_type_code VARCHAR(15) NOT NULL,
unit_price DECIMAL(19, 4),
product_name VARCHAR(80),
product_color VARCHAR(20),
product_size VARCHAR(20),
PRIMARY KEY (product_id),
FOREIGN KEY(production_type_code) REFERENCES "Product_Categories" (production_type_code)
)
/*
2 rows from Products table:
product_id parent_product_id production_type_code unit_price product_name product_color product_size
1 4 Food 617.9500 Coffee Bean Red Medium
2 4 Books 558.4900 Learning French Yellow Medium
*/ | Show the product ids and the number of unique orders containing each product. | SELECT product_id , count(DISTINCT order_id) FROM Order_items GROUP BY product_id | [{'product_id': 3, 'count(DISTINCT order_id)': 1}, {'product_id': 4, 'count(DISTINCT order_id)': 2}, {'product_id': 5, 'count(DISTINCT order_id)': 2}, {'product_id': 7, 'count(DISTINCT order_id)': 1}, {'product_id': 9, 'count(DISTINCT order_id)': 1}, {'product_id': 10, 'count(DISTINCT order_id)': 1}, {'product_id': 12, 'count(DISTINCT order_id)': 1}, {'product_id': 13, 'count(DISTINCT order_id)': 1}, {'product_id': 14, 'count(DISTINCT order_id)': 3}, {'product_id': 15, 'count(DISTINCT order_id)': 1}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | ||||
dorm_1 |
CREATE TABLE "Dorm" (
dormid INTEGER,
dorm_name VARCHAR(20),
student_capacity INTEGER,
gender VARCHAR(1)
)
CREATE TABLE "Dorm_amenity" (
amenid INTEGER,
amenity_name VARCHAR(25)
)
CREATE TABLE "Has_amenity" (
dormid INTEGER,
amenid INTEGER,
FOREIGN KEY(amenid) REFERENCES "Dorm_amenity" (amenid),
FOREIGN KEY(dormid) REFERENCES "Dorm" (dormid)
)
CREATE TABLE "Lives_in" (
stuid INTEGER,
dormid INTEGER,
room_number INTEGER,
FOREIGN KEY(dormid) REFERENCES "Dorm" (dormid),
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID")
)
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 "Dorm" (
dormid INTEGER,
dorm_name VARCHAR(20),
student_capacity INTEGER,
gender VARCHAR(1)
)
/*
2 rows from Dorm table:
dormid dorm_name student_capacity gender
100 Smith Hall 85 X
110 Bud Jones Hall 116 M
*/
CREATE TABLE "Dorm_amenity" (
amenid INTEGER,
amenity_name VARCHAR(25)
)
/*
2 rows from Dorm_amenity table:
amenid amenity_name
900 TV Lounge
901 Study Room
*/
CREATE TABLE "Has_amenity" (
dormid INTEGER,
amenid INTEGER,
FOREIGN KEY(amenid) REFERENCES "Dorm_amenity" (amenid),
FOREIGN KEY(dormid) REFERENCES "Dorm" (dormid)
)
/*
2 rows from Has_amenity table:
dormid amenid
109 900
109 901
*/
CREATE TABLE "Lives_in" (
stuid INTEGER,
dormid INTEGER,
room_number INTEGER,
FOREIGN KEY(dormid) REFERENCES "Dorm" (dormid),
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID")
)
/*
2 rows from Lives_in table:
stuid dormid room_number
1001 109 105
1002 100 112
*/
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 first name of students living in city PHL whose age is between 20 and 25. | SELECT fname FROM student WHERE city_code = 'PHL' AND age BETWEEN 20 AND 25 | [{'Fname': 'David'}, {'Fname': 'Sarah'}] | Easy | false | false | true | false | false | false | false | false | false | false | false | false | false | [QUESTION]Show the name of teachers aged either 32 or 33?[/QUESTION]
[SQL]SELECT Name FROM teacher WHERE Age = 32 OR Age = 33[/SQL] | [QUESTION]Show the name of teachers aged either 32 or 33?[/QUESTION]
[SQL]SELECT Name FROM teacher WHERE Age = 32 OR Age = 33[/SQL] | [QUESTION]Show the name of teachers aged either 32 or 33?[/QUESTION]
[SQL]SELECT Name FROM teacher WHERE Age = 32 OR Age = 33[/SQL] |
|
customers_and_invoices |
CREATE TABLE "Accounts" (
account_id INTEGER,
customer_id INTEGER NOT NULL,
date_account_opened DATETIME,
account_name VARCHAR(50),
other_account_details VARCHAR(255),
PRIMARY KEY (account_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_first_name VARCHAR(50),
customer_middle_initial VARCHAR(1),
customer_last_name VARCHAR(50),
gender VARCHAR(1),
email_address VARCHAR(255),
login_name VARCHAR(80),
login_password VARCHAR(20),
phone_number VARCHAR(255),
town_city VARCHAR(50),
state_county_province VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Financial_Transactions" (
transaction_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
invoice_number INTEGER,
transaction_type VARCHAR(15) NOT NULL,
transaction_date DATETIME,
transaction_amount DECIMAL(19, 4),
transaction_comment VARCHAR(255),
other_transaction_details VARCHAR(255),
FOREIGN KEY(account_id) REFERENCES "Accounts" (account_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number)
)
CREATE TABLE "Invoice_Line_Items" (
order_item_id INTEGER NOT NULL,
invoice_number INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_title VARCHAR(80),
product_quantity VARCHAR(50),
product_price DECIMAL(19, 4),
derived_product_cost DECIMAL(19, 4),
derived_vat_payable DECIMAL(19, 4),
derived_total_cost DECIMAL(19, 4),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number),
FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)
CREATE TABLE "Invoices" (
invoice_number INTEGER,
order_id INTEGER NOT NULL,
invoice_date DATETIME,
PRIMARY KEY (invoice_number),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_quantity VARCHAR(50),
other_order_item_details VARCHAR(255),
PRIMARY KEY (order_item_id),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
date_order_placed DATETIME NOT NULL,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Product_Categories" (
production_type_code VARCHAR(15),
product_type_description VARCHAR(80),
vat_rating DECIMAL(19, 4),
PRIMARY KEY (production_type_code)
)
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
production_type_code VARCHAR(15) NOT NULL,
unit_price DECIMAL(19, 4),
product_name VARCHAR(80),
product_color VARCHAR(20),
product_size VARCHAR(20),
PRIMARY KEY (product_id),
FOREIGN KEY(production_type_code) REFERENCES "Product_Categories" (production_type_code)
) |
CREATE TABLE "Accounts" (
account_id INTEGER,
customer_id INTEGER NOT NULL,
date_account_opened DATETIME,
account_name VARCHAR(50),
other_account_details VARCHAR(255),
PRIMARY KEY (account_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Accounts table:
account_id customer_id date_account_opened account_name other_account_details
1 8 2016-07-30 22:22:24 900 Regular
2 3 2017-05-29 16:45:17 520 VIP
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_first_name VARCHAR(50),
customer_middle_initial VARCHAR(1),
customer_last_name VARCHAR(50),
gender VARCHAR(1),
email_address VARCHAR(255),
login_name VARCHAR(80),
login_password VARCHAR(20),
phone_number VARCHAR(255),
town_city VARCHAR(50),
state_county_province VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id customer_first_name customer_middle_initial customer_last_name gender email_address login_name login_password phone_number town_city state_county_province country
1 Dee A Larkin 1 [email protected] xhartmann 77789d292604ea04406f 241.796.1219x37862 North Nellie WestVirginia USA
2 Brennon H Weimann 0 [email protected] shayne.lesch ce97a3e4539347daab96 (943)219-4234x415 South Isabell Oklahoma USA
*/
CREATE TABLE "Financial_Transactions" (
transaction_id INTEGER NOT NULL,
account_id INTEGER NOT NULL,
invoice_number INTEGER,
transaction_type VARCHAR(15) NOT NULL,
transaction_date DATETIME,
transaction_amount DECIMAL(19, 4),
transaction_comment VARCHAR(255),
other_transaction_details VARCHAR(255),
FOREIGN KEY(account_id) REFERENCES "Accounts" (account_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number)
)
/*
2 rows from Financial_Transactions table:
transaction_id account_id invoice_number transaction_type transaction_date transaction_amount transaction_comment other_transaction_details
1 13 12 Payment 2018-03-15 21:13:57 613.9600 None None
2 9 1 Payment 2018-03-13 13:27:46 368.4600 None None
*/
CREATE TABLE "Invoice_Line_Items" (
order_item_id INTEGER NOT NULL,
invoice_number INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_title VARCHAR(80),
product_quantity VARCHAR(50),
product_price DECIMAL(19, 4),
derived_product_cost DECIMAL(19, 4),
derived_vat_payable DECIMAL(19, 4),
derived_total_cost DECIMAL(19, 4),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(invoice_number) REFERENCES "Invoices" (invoice_number),
FOREIGN KEY(order_item_id) REFERENCES "Order_Items" (order_item_id)
)
/*
2 rows from Invoice_Line_Items table:
order_item_id invoice_number product_id product_title product_quantity product_price derived_product_cost derived_vat_payable derived_total_cost
14 9 5 prod_name 4 742.3700 191.1100 None 69.8200
3 9 15 prod_name 1 814.8700 176.2900 None 59.5600
*/
CREATE TABLE "Invoices" (
invoice_number INTEGER,
order_id INTEGER NOT NULL,
invoice_date DATETIME,
PRIMARY KEY (invoice_number),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id)
)
/*
2 rows from Invoices table:
invoice_number order_id invoice_date
1 9 2018-03-01 16:40:48
2 9 2018-03-20 00:21:41
*/
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
product_quantity VARCHAR(50),
other_order_item_details VARCHAR(255),
PRIMARY KEY (order_item_id),
FOREIGN KEY(order_id) REFERENCES "Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
order_item_id order_id product_id product_quantity other_order_item_details
1 4 4 6 None
2 4 10 7 None
*/
CREATE TABLE "Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
date_order_placed DATETIME NOT NULL,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Orders table:
order_id customer_id date_order_placed order_details
1 12 2012-06-27 20:49:56 None
2 12 2012-08-25 07:51:54 None
*/
CREATE TABLE "Product_Categories" (
production_type_code VARCHAR(15),
product_type_description VARCHAR(80),
vat_rating DECIMAL(19, 4),
PRIMARY KEY (production_type_code)
)
/*
2 rows from Product_Categories table:
production_type_code product_type_description vat_rating
Food Food 15.8400
DVDs Dvd products 11.4000
*/
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
production_type_code VARCHAR(15) NOT NULL,
unit_price DECIMAL(19, 4),
product_name VARCHAR(80),
product_color VARCHAR(20),
product_size VARCHAR(20),
PRIMARY KEY (product_id),
FOREIGN KEY(production_type_code) REFERENCES "Product_Categories" (production_type_code)
)
/*
2 rows from Products table:
product_id parent_product_id production_type_code unit_price product_name product_color product_size
1 4 Food 617.9500 Coffee Bean Red Medium
2 4 Books 558.4900 Learning French Yellow Medium
*/ | How many customers don't have an account? | SELECT count(*) FROM Customers WHERE customer_id NOT IN (SELECT customer_id FROM Accounts) | [{'count(*)': 8}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of customers who do not have saving accounts?[/QUESTION]
[SQL]SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'[/SQL] | [QUESTION]What are the names of customers who do not have saving accounts?[/QUESTION]
[SQL]SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'[/SQL] | [QUESTION]What are the names of customers who do not have saving accounts?[/QUESTION]
[SQL]SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'[/SQL] | [QUESTION]What are the names of customers who do not have saving accounts?[/QUESTION]
[SQL]SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'[/SQL] |
restaurant_1 |
CREATE TABLE "Restaurant" (
"ResID" INTEGER,
"ResName" VARCHAR(100),
"Address" VARCHAR(100),
"Rating" INTEGER,
PRIMARY KEY ("ResID")
)
CREATE TABLE "Restaurant_Type" (
"ResTypeID" INTEGER,
"ResTypeName" VARCHAR(40),
"ResTypeDescription" VARCHAR(100),
PRIMARY KEY ("ResTypeID")
)
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 "Type_Of_Restaurant" (
"ResID" INTEGER,
"ResTypeID" INTEGER,
FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID"),
FOREIGN KEY("ResTypeID") REFERENCES "Restaurant_Type" ("ResTypeID")
)
CREATE TABLE "Visits_Restaurant" (
"StuID" INTEGER,
"ResID" INTEGER,
"Time" TIMESTAMP,
"Spent" FLOAT,
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID")
) |
CREATE TABLE "Restaurant" (
"ResID" INTEGER,
"ResName" VARCHAR(100),
"Address" VARCHAR(100),
"Rating" INTEGER,
PRIMARY KEY ("ResID")
)
/*
2 rows from Restaurant table:
ResID ResName Address Rating
1 Subway 3233 St Paul St, Baltimore, MD 21218 3
2 Honeygrow 3212 St Paul St, Baltimore, MD 21218 4
*/
CREATE TABLE "Restaurant_Type" (
"ResTypeID" INTEGER,
"ResTypeName" VARCHAR(40),
"ResTypeDescription" VARCHAR(100),
PRIMARY KEY ("ResTypeID")
)
/*
2 rows from Restaurant_Type table:
ResTypeID ResTypeName ResTypeDescription
1 Sandwich Simplest there is.
2 Stir-fry Classic Chinese cooking.
*/
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
*/
CREATE TABLE "Type_Of_Restaurant" (
"ResID" INTEGER,
"ResTypeID" INTEGER,
FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID"),
FOREIGN KEY("ResTypeID") REFERENCES "Restaurant_Type" ("ResTypeID")
)
/*
2 rows from Type_Of_Restaurant table:
ResID ResTypeID
1 1
2 2
*/
CREATE TABLE "Visits_Restaurant" (
"StuID" INTEGER,
"ResID" INTEGER,
"Time" TIMESTAMP,
"Spent" FLOAT,
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("ResID") REFERENCES "Restaurant" ("ResID")
)
/*
2 rows from Visits_Restaurant table:
StuID ResID Time Spent
1001 1 2017-10-09 18:15:00 6.53
1032 2 2017-10-08 13:00:30 13.2
*/ | Which student visited restaurant most often? List student's first name and last name. | SELECT Student.Fname , Student.Lname FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID GROUP BY Student.StuID ORDER BY count(*) DESC LIMIT 1; | [{'Fname': 'Eric', 'LName': 'Brown'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | [QUESTION]Give the name of the student with the most likes.[/QUESTION]
[SQL]SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Give the name of the student with the most likes.[/QUESTION]
[SQL]SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Give the name of the student with the most likes.[/QUESTION]
[SQL]SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Give the name of the student with the most likes.[/QUESTION]
[SQL]SELECT T2.name FROM Likes AS T1 JOIN Highschooler AS T2 ON T1.student_id = T2.id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
scientist_1 |
CREATE TABLE "AssignedTo" (
"Scientist" INTEGER NOT NULL,
"Project" CHAR(4) NOT NULL,
PRIMARY KEY ("Scientist", "Project"),
FOREIGN KEY("Scientist") REFERENCES "Scientists" ("SSN"),
FOREIGN KEY("Project") REFERENCES "Projects" ("Code")
)
CREATE TABLE "Projects" (
"Code" CHAR(4),
"Name" CHAR(50) NOT NULL,
"Hours" INTEGER,
PRIMARY KEY ("Code")
)
CREATE TABLE "Scientists" (
"SSN" INTEGER,
"Name" CHAR(30) NOT NULL,
PRIMARY KEY ("SSN")
) |
CREATE TABLE "AssignedTo" (
"Scientist" INTEGER NOT NULL,
"Project" CHAR(4) NOT NULL,
PRIMARY KEY ("Scientist", "Project"),
FOREIGN KEY("Scientist") REFERENCES "Scientists" ("SSN"),
FOREIGN KEY("Project") REFERENCES "Projects" ("Code")
)
/*
2 rows from AssignedTo table:
Scientist Project
123234877 AeH1
152934485 AeH3
*/
CREATE TABLE "Projects" (
"Code" CHAR(4),
"Name" CHAR(50) NOT NULL,
"Hours" INTEGER,
PRIMARY KEY ("Code")
)
/*
2 rows from Projects table:
Code Name Hours
AeH1 Winds: Studying Bernoullis Principle 156
AeH2 Aerodynamics and Bridge Design 189
*/
CREATE TABLE "Scientists" (
"SSN" INTEGER,
"Name" CHAR(30) NOT NULL,
PRIMARY KEY ("SSN")
)
/*
2 rows from Scientists table:
SSN Name
123234877 Michael Rogers
152934485 Anand Manikutty
*/ | Find the average hours of all projects. | SELECT avg(hours) FROM projects | [{'avg(hours)': 1441.642857142857}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Find the total number of hours have done for all students in each department.[/QUESTION]
[SQL]SELECT sum(stu_hrs) , dept_code FROM student GROUP BY dept_code[/SQL] | [QUESTION]Find the total number of hours have done for all students in each department.[/QUESTION]
[SQL]SELECT sum(stu_hrs) , dept_code FROM student GROUP BY dept_code[/SQL] | [QUESTION]Find the total number of hours have done for all students in each department.[/QUESTION]
[SQL]SELECT sum(stu_hrs) , dept_code FROM student GROUP BY dept_code[/SQL] | [QUESTION]Find the total number of hours have done for all students in each department.[/QUESTION]
[SQL]SELECT sum(stu_hrs) , dept_code FROM student GROUP BY dept_code[/SQL] |
e_learning |
CREATE TABLE "Course_Authors_and_Tutors" (
author_id INTEGER,
"author_tutor_ATB" VARCHAR(3),
login_name VARCHAR(40),
password VARCHAR(40),
personal_name VARCHAR(80),
middle_name VARCHAR(80),
family_name VARCHAR(80),
gender_mf VARCHAR(1),
address_line_1 VARCHAR(80),
PRIMARY KEY (author_id)
)
CREATE TABLE "Courses" (
course_id INTEGER,
author_id INTEGER NOT NULL,
subject_id INTEGER NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
PRIMARY KEY (course_id),
FOREIGN KEY(subject_id) REFERENCES "Subjects" (subject_id),
FOREIGN KEY(author_id) REFERENCES "Course_Authors_and_Tutors" (author_id)
)
CREATE TABLE "Student_Course_Enrolment" (
registration_id INTEGER,
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_enrolment DATETIME NOT NULL,
date_of_completion DATETIME NOT NULL,
PRIMARY KEY (registration_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
CREATE TABLE "Student_Tests_Taken" (
registration_id INTEGER NOT NULL,
date_test_taken DATETIME NOT NULL,
test_result VARCHAR(255),
FOREIGN KEY(registration_id) REFERENCES "Student_Course_Enrolment" (registration_id)
)
CREATE TABLE "Students" (
student_id INTEGER,
date_of_registration DATETIME,
date_of_latest_logon DATETIME,
login_name VARCHAR(40),
password VARCHAR(10),
personal_name VARCHAR(40),
middle_name VARCHAR(40),
family_name VARCHAR(40),
PRIMARY KEY (student_id)
)
CREATE TABLE "Subjects" (
subject_id INTEGER,
subject_name VARCHAR(120),
PRIMARY KEY (subject_id)
) |
CREATE TABLE "Course_Authors_and_Tutors" (
author_id INTEGER,
"author_tutor_ATB" VARCHAR(3),
login_name VARCHAR(40),
password VARCHAR(40),
personal_name VARCHAR(80),
middle_name VARCHAR(80),
family_name VARCHAR(80),
gender_mf VARCHAR(1),
address_line_1 VARCHAR(80),
PRIMARY KEY (author_id)
)
/*
2 rows from Course_Authors_and_Tutors table:
author_id author_tutor_ATB login_name password personal_name middle_name family_name gender_mf address_line_1
1 331 jmckenzie c40fa148bdd0d2d45cd6e9ec1e685750fe07f81b Cathrine Ruthie Grant 0 756 Monahan Mews
Spinkashire, NJ 64230-5098
2 975 heidenreich.ara 24b0ee84063c3b017ab1839e01b7280f47f7c7c2 Retha Corene Armstrong 0 98623 Huels Manor
Jasttown, DE 31611
*/
CREATE TABLE "Courses" (
course_id INTEGER,
author_id INTEGER NOT NULL,
subject_id INTEGER NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
PRIMARY KEY (course_id),
FOREIGN KEY(subject_id) REFERENCES "Subjects" (subject_id),
FOREIGN KEY(author_id) REFERENCES "Course_Authors_and_Tutors" (author_id)
)
/*
2 rows from Courses table:
course_id author_id subject_id course_name course_description
1 8 1 database database
2 6 1 advanced database advanced database
*/
CREATE TABLE "Student_Course_Enrolment" (
registration_id INTEGER,
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_enrolment DATETIME NOT NULL,
date_of_completion DATETIME NOT NULL,
PRIMARY KEY (registration_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
/*
2 rows from Student_Course_Enrolment table:
registration_id student_id course_id date_of_enrolment date_of_completion
1 11 2 2017-10-09 07:09:02 2018-02-26 07:48:52
2 15 4 2017-11-13 12:49:33 2018-03-04 01:24:56
*/
CREATE TABLE "Student_Tests_Taken" (
registration_id INTEGER NOT NULL,
date_test_taken DATETIME NOT NULL,
test_result VARCHAR(255),
FOREIGN KEY(registration_id) REFERENCES "Student_Course_Enrolment" (registration_id)
)
/*
2 rows from Student_Tests_Taken table:
registration_id date_test_taken test_result
12 2018-03-25 03:27:16 Fail
10 2018-03-25 21:50:22 Pass
*/
CREATE TABLE "Students" (
student_id INTEGER,
date_of_registration DATETIME,
date_of_latest_logon DATETIME,
login_name VARCHAR(40),
password VARCHAR(10),
personal_name VARCHAR(40),
middle_name VARCHAR(40),
family_name VARCHAR(40),
PRIMARY KEY (student_id)
)
/*
2 rows from Students table:
student_id date_of_registration date_of_latest_logon login_name password personal_name middle_name family_name
1 2015-07-22 13:32:35 2017-10-17 22:52:26 annamae.hoppe db8765bb6f Wilson Aubrey Ward
2 2015-07-02 00:21:42 2017-06-24 22:16:27 wmiller 35faf8182a Karson Luella Jaskolski
*/
CREATE TABLE "Subjects" (
subject_id INTEGER,
subject_name VARCHAR(120),
PRIMARY KEY (subject_id)
)
/*
2 rows from Subjects table:
subject_id subject_name
1 Computer Science
2 Arts
*/ | List the dates of enrollment and completion of the student with personal name "Karson". | SELECT T1.date_of_enrolment , T1.date_of_completion FROM Student_Course_Enrolment AS T1 JOIN Students AS T2 ON T1.student_id = T2.student_id WHERE T2.personal_name = "Karson" | [{'date_of_enrolment': '2017-11-22 18:29:18', 'date_of_completion': '2018-03-09 17:56:18'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]What is the first, middle, and last name, along with the id and number of enrollments, for the student who enrolled the most in any program?[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the first, middle, and last name, along with the id and number of enrollments, for the student who enrolled the most in any program?[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the first, middle, and last name, along with the id and number of enrollments, for the student who enrolled the most in any program?[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the first, middle, and last name, along with the id and number of enrollments, for the student who enrolled the most in any program?[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
local_govt_in_alabama |
CREATE TABLE "Events" (
"Event_ID" INTEGER NOT NULL,
"Service_ID" INTEGER NOT NULL,
"Event_Details" VARCHAR(255),
PRIMARY KEY ("Event_ID"),
FOREIGN KEY("Service_ID") REFERENCES "Services" ("Service_ID")
)
CREATE TABLE "Participants" (
"Participant_ID" INTEGER NOT NULL,
"Participant_Type_Code" CHAR(15) NOT NULL,
"Participant_Details" VARCHAR(255),
PRIMARY KEY ("Participant_ID")
)
CREATE TABLE "Participants_in_Events" (
"Event_ID" INTEGER NOT NULL,
"Participant_ID" INTEGER NOT NULL,
PRIMARY KEY ("Event_ID", "Participant_ID"),
FOREIGN KEY("Participant_ID") REFERENCES "Participants" ("Participant_ID"),
FOREIGN KEY("Event_ID") REFERENCES "Events" ("Event_ID")
)
CREATE TABLE "Services" (
"Service_ID" INTEGER NOT NULL,
"Service_Type_Code" CHAR(15) NOT NULL,
PRIMARY KEY ("Service_ID")
) |
CREATE TABLE "Events" (
"Event_ID" INTEGER NOT NULL,
"Service_ID" INTEGER NOT NULL,
"Event_Details" VARCHAR(255),
PRIMARY KEY ("Event_ID"),
FOREIGN KEY("Service_ID") REFERENCES "Services" ("Service_ID")
)
/*
2 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
*/
CREATE TABLE "Participants" (
"Participant_ID" INTEGER NOT NULL,
"Participant_Type_Code" CHAR(15) NOT NULL,
"Participant_Details" VARCHAR(255),
PRIMARY KEY ("Participant_ID")
)
/*
2 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
*/
CREATE TABLE "Participants_in_Events" (
"Event_ID" INTEGER NOT NULL,
"Participant_ID" INTEGER NOT NULL,
PRIMARY KEY ("Event_ID", "Participant_ID"),
FOREIGN KEY("Participant_ID") REFERENCES "Participants" ("Participant_ID"),
FOREIGN KEY("Event_ID") REFERENCES "Events" ("Event_ID")
)
/*
2 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
*/
CREATE TABLE "Services" (
"Service_ID" INTEGER NOT NULL,
"Service_Type_Code" CHAR(15) NOT NULL,
PRIMARY KEY ("Service_ID")
)
/*
2 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
*/ | List the service id and details for the events. | SELECT service_id , event_details FROM EVENTS | [{'Service_ID': 5, 'Event_Details': 'Success'}, {'Service_ID': 8, 'Event_Details': 'Success'}, {'Service_ID': 8, 'Event_Details': 'Fail'}, {'Service_ID': 2, 'Event_Details': 'Fail'}, {'Service_ID': 5, 'Event_Details': 'Fail'}, {'Service_ID': 6, 'Event_Details': 'Fail'}, {'Service_ID': 6, 'Event_Details': 'Fail'}, {'Service_ID': 8, 'Event_Details': 'Fail'}, {'Service_ID': 8, 'Event_Details': 'Fail'}, {'Service_ID': 5, 'Event_Details': 'Success'}, {'Service_ID': 2, 'Event_Details': 'Fail'}, {'Service_ID': 2, 'Event_Details': 'Success'}, {'Service_ID': 5, 'Event_Details': 'Success'}, {'Service_ID': 2, 'Event_Details': 'Fail'}, {'Service_ID': 2, 'Event_Details': 'Success'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
yelp |
CREATE TABLE business (
bid INTEGER,
business_id TEXT,
name TEXT,
full_address TEXT,
city TEXT,
latitude TEXT,
longitude TEXT,
review_count INTEGER,
is_open INTEGER,
rating REAL,
state TEXT,
PRIMARY KEY (bid)
)
CREATE TABLE category (
id INTEGER,
business_id TEXT,
category_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE checkin (
cid INTEGER,
business_id TEXT,
count INTEGER,
day TEXT,
PRIMARY KEY (cid),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE neighbourhood (
id INTEGER,
business_id TEXT,
neighbourhood_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE review (
rid INTEGER,
business_id TEXT,
user_id TEXT,
rating REAL,
text TEXT,
year INTEGER,
month TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE tip (
tip_id INTEGER,
business_id TEXT,
text TEXT,
user_id TEXT,
likes INTEGER,
year INTEGER,
month TEXT,
PRIMARY KEY (tip_id),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE user (
uid INTEGER,
user_id TEXT,
name TEXT,
PRIMARY KEY (uid)
) |
CREATE TABLE business (
bid INTEGER,
business_id TEXT,
name TEXT,
full_address TEXT,
city TEXT,
latitude TEXT,
longitude TEXT,
review_count INTEGER,
is_open INTEGER,
rating REAL,
state TEXT,
PRIMARY KEY (bid)
)
/*
2 rows from business table:
bid business_id name full_address city latitude longitude review_count is_open rating state
*/
CREATE TABLE category (
id INTEGER,
business_id TEXT,
category_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from category table:
id business_id category_name
*/
CREATE TABLE checkin (
cid INTEGER,
business_id TEXT,
count INTEGER,
day TEXT,
PRIMARY KEY (cid),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from checkin table:
cid business_id count day
*/
CREATE TABLE neighbourhood (
id INTEGER,
business_id TEXT,
neighbourhood_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from neighbourhood table:
id business_id neighbourhood_name
*/
CREATE TABLE review (
rid INTEGER,
business_id TEXT,
user_id TEXT,
rating REAL,
text TEXT,
year INTEGER,
month TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from review table:
rid business_id user_id rating text year month
*/
CREATE TABLE tip (
tip_id INTEGER,
business_id TEXT,
text TEXT,
user_id TEXT,
likes INTEGER,
year INTEGER,
month TEXT,
PRIMARY KEY (tip_id),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from tip table:
tip_id business_id text user_id likes year month
*/
CREATE TABLE user (
uid INTEGER,
user_id TEXT,
name TEXT,
PRIMARY KEY (uid)
)
/*
2 rows from user table:
uid user_id name
*/ | How many tips have been written in 2015 | SELECT COUNT ( DISTINCT text ) FROM tip WHERE YEAR = 2015; | [{'COUNT ( DISTINCT text )': 0}] | Easy | true | false | false | false | false | false | false | false | false | false | false | false | false | ||||
music_4 |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
) |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
/*
2 rows from artist table:
Artist_ID Artist Age Famous_Title Famous_Release_date
1 Gorgoroth 34 Bergen 1996 November 2007
2 Ophiolatry 35 Transmutation January 21, 2008
*/
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
/*
2 rows from music_festival table:
ID Music_Festival Date_of_ceremony Category Volume Result
1 34th England Academy Prize 18 February 2011 Best Song 1 Nominated
2 34th Japan Academy Prize 18 February 2011 Best Lyrics 2 Nominated
*/
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
)
/*
2 rows from volume table:
Volume_ID Volume_Issue Issue_Date Weeks_on_Top Song Artist_ID
1 45:14 § 27 December 1986 - 10 January 3.0 The Way 1
2 45:15 17 January 1.0 Everybody Have Fun Tonight 2
*/ | How many distinct artists do the volumes associate to? | SELECT COUNT(DISTINCT Artist_ID) FROM volume | [{'COUNT(DISTINCT Artist_ID)': 5}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the number of artists for each gender?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]What is the number of artists for each gender?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]What is the number of artists for each gender?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]What is the number of artists for each gender?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] |
medicine_enzyme_interaction |
CREATE TABLE enzyme (
id INTEGER,
name TEXT,
"Location" TEXT,
"Product" TEXT,
"Chromosome" TEXT,
"OMIM" INTEGER,
"Porphyria" TEXT,
PRIMARY KEY (id)
)
CREATE TABLE medicine (
id INTEGER,
name TEXT,
"Trade_Name" TEXT,
"FDA_approved" TEXT,
PRIMARY KEY (id)
)
CREATE TABLE medicine_enzyme_interaction (
enzyme_id INTEGER,
medicine_id INTEGER,
interaction_type TEXT,
PRIMARY KEY (enzyme_id, medicine_id),
FOREIGN KEY(medicine_id) REFERENCES medicine (id),
FOREIGN KEY(enzyme_id) REFERENCES enzyme (id)
) |
CREATE TABLE enzyme (
id INTEGER,
name TEXT,
"Location" TEXT,
"Product" TEXT,
"Chromosome" TEXT,
"OMIM" INTEGER,
"Porphyria" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from enzyme table:
id name Location Product Chromosome OMIM Porphyria
1 ALA synthase Mitochondrion δ-Aminolevulinic acid 3p21.1 125290 none
2 ALA dehydratase Cytosol Porphobilinogen 9q34 125270 ALA-Dehydratase deficiency
*/
CREATE TABLE medicine (
id INTEGER,
name TEXT,
"Trade_Name" TEXT,
"FDA_approved" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from medicine table:
id name Trade_Name FDA_approved
1 Amisulpride Solian No
2 Aripiprazole Abilify Yes
*/
CREATE TABLE medicine_enzyme_interaction (
enzyme_id INTEGER,
medicine_id INTEGER,
interaction_type TEXT,
PRIMARY KEY (enzyme_id, medicine_id),
FOREIGN KEY(medicine_id) REFERENCES medicine (id),
FOREIGN KEY(enzyme_id) REFERENCES enzyme (id)
)
/*
2 rows from medicine_enzyme_interaction table:
enzyme_id medicine_id interaction_type
1 1 inhibitor
1 2 inhibitor
*/ | What is the id and name of the enzyme that can interact with the most medicines as an activator? | SELECT T1.id , T1.name FROM enzyme AS T1 JOIN medicine_enzyme_interaction AS T2 ON T1.id = T2.enzyme_id WHERE T2.interaction_type = 'activitor' GROUP BY T1.id ORDER BY count(*) DESC LIMIT 1 | [{'id': 4, 'name': 'Uroporphyrinogen III synthase'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | Question Answering papers | SELECT DISTINCT t3.paperid FROM paperkeyphrase AS t2 JOIN keyphrase AS t1 ON t2.keyphraseid = t1.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid WHERE t1.keyphrasename = "Question Answering"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
epinions_1 |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
) |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
/*
2 rows from item table:
i_id title
0 pear
1 orange
*/
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
/*
2 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
*/
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
/*
2 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
*/
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
)
/*
2 rows from useracct table:
u_id name
1 Helen
2 Mark
*/ | Find the number of items that did not receive any review. | SELECT count(*) FROM item WHERE i_id NOT IN (SELECT i_id FROM review) | [{'count(*)': 3}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
local_govt_mdm |
CREATE TABLE "Benefits_Overpayments" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
CREATE TABLE "Business_Rates" (
business_rates_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (business_rates_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
CREATE TABLE "CMI_Cross_References" (
cmi_cross_ref_id INTEGER NOT NULL,
master_customer_id INTEGER NOT NULL,
source_system_code CHAR(15) NOT NULL,
PRIMARY KEY (cmi_cross_ref_id),
FOREIGN KEY(master_customer_id) REFERENCES "Customer_Master_Index" (master_customer_id)
)
CREATE TABLE "Council_Tax" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
CREATE TABLE "Customer_Master_Index" (
master_customer_id INTEGER NOT NULL,
cmi_details VARCHAR(255),
PRIMARY KEY (master_customer_id)
)
CREATE TABLE "Electoral_Register" (
electoral_register_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (electoral_register_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
CREATE TABLE "Parking_Fines" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
CREATE TABLE "Rent_Arrears" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
) |
CREATE TABLE "Benefits_Overpayments" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Benefits_Overpayments table:
council_tax_id cmi_cross_ref_id
3 65
6 41
*/
CREATE TABLE "Business_Rates" (
business_rates_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (business_rates_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Business_Rates table:
business_rates_id cmi_cross_ref_id
2 99
5 49
*/
CREATE TABLE "CMI_Cross_References" (
cmi_cross_ref_id INTEGER NOT NULL,
master_customer_id INTEGER NOT NULL,
source_system_code CHAR(15) NOT NULL,
PRIMARY KEY (cmi_cross_ref_id),
FOREIGN KEY(master_customer_id) REFERENCES "Customer_Master_Index" (master_customer_id)
)
/*
2 rows from CMI_Cross_References table:
cmi_cross_ref_id master_customer_id source_system_code
2 4 Rent
4 5 Parking
*/
CREATE TABLE "Council_Tax" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Council_Tax table:
council_tax_id cmi_cross_ref_id
1 101
2 103
*/
CREATE TABLE "Customer_Master_Index" (
master_customer_id INTEGER NOT NULL,
cmi_details VARCHAR(255),
PRIMARY KEY (master_customer_id)
)
/*
2 rows from Customer_Master_Index table:
master_customer_id cmi_details
1 Schmitt-Lang
2 Volkman, Mills and Ferry
*/
CREATE TABLE "Electoral_Register" (
electoral_register_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (electoral_register_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Electoral_Register table:
electoral_register_id cmi_cross_ref_id
2 83
3 65
*/
CREATE TABLE "Parking_Fines" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Parking_Fines table:
council_tax_id cmi_cross_ref_id
9 4
10 81
*/
CREATE TABLE "Rent_Arrears" (
council_tax_id INTEGER NOT NULL,
cmi_cross_ref_id INTEGER NOT NULL,
PRIMARY KEY (council_tax_id),
FOREIGN KEY(cmi_cross_ref_id) REFERENCES "CMI_Cross_References" (cmi_cross_ref_id)
)
/*
2 rows from Rent_Arrears table:
council_tax_id cmi_cross_ref_id
1 100
2 8
*/ | How many business rates are related to each cmi cross reference? List cross reference id, master customer id and the n | SELECT T2.cmi_cross_ref_id , T2.master_customer_id , count(*) FROM Business_Rates AS T1 JOIN CMI_Cross_References AS T2 ON T1.cmi_cross_ref_id = T2.cmi_cross_ref_id GROUP BY T2.cmi_cross_ref_id | [{'cmi_cross_ref_id': 49, 'master_customer_id': 1, 'count(*)': 1}, {'cmi_cross_ref_id': 95, 'master_customer_id': 2, 'count(*)': 1}, {'cmi_cross_ref_id': 99, 'master_customer_id': 9, 'count(*)': 1}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]What is the total number of customers across banks?[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank[/SQL] | [QUESTION]What is the total number of customers across banks?[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank[/SQL] |
||
college_2 |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
) |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
/*
2 rows from advisor table:
s_ID i_ID
24746 19368
79352 95030
*/
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
/*
2 rows from classroom table:
building room_number capacity
Lamberton 134 10
Chandler 375 10
*/
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
/*
2 rows from course table:
course_id title dept_name credits
787 C Programming Mech. Eng. 4
238 The Music of Donovan Mech. Eng. 3
*/
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
/*
2 rows from department table:
dept_name building budget
Civil Eng. Chandler 255041.46
Biology Candlestick 647610.55
*/
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
/*
2 rows from instructor table:
ID name dept_name salary
63395 McKinnon Cybernetics 94333.99
78699 Pingr Statistics 59303.62
*/
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
/*
2 rows from prereq table:
course_id prereq_id
376 130
760 169
*/
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
/*
2 rows from section table:
course_id sec_id semester year building room_number time_slot_id
313 1 Fall 2010 Chandler 804 N
747 1 Spring 2004 Gates 314 K
*/
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
/*
2 rows from student table:
ID name dept_name tot_cred
24746 Schrefl History 4
79352 Rumat Finance 100
*/
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
/*
2 rows from takes table:
ID course_id sec_id semester year grade
65901 401 1 Fall 2003 C-
24932 802 1 Spring 2003 B-
*/
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
/*
2 rows from teaches table:
ID course_id sec_id semester year
34175 747 1 Spring 2004
3199 169 1 Spring 2007
*/
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
)
/*
2 rows from time_slot table:
time_slot_id day start_hr start_min end_hr end_min
A M 8.0000000000 0E-10 8.0000000000 50.0000000000
A W 8.0000000000 0E-10 8.0000000000 50.0000000000
*/ | Count the number of courses in the Physics department. | SELECT count(DISTINCT course_id) FROM course WHERE dept_name = 'Physics' | [{'count(DISTINCT course_id)': 10}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] |
academic |
CREATE TABLE author (
aid INTEGER,
homepage TEXT,
name TEXT,
oid INTEGER,
PRIMARY KEY (aid)
)
CREATE TABLE cite (
cited INTEGER,
citing INTEGER,
FOREIGN KEY(cited) REFERENCES publication (pid),
FOREIGN KEY(citing) REFERENCES publication (pid)
)
CREATE TABLE conference (
cid INTEGER,
homepage TEXT,
name TEXT,
PRIMARY KEY (cid)
)
CREATE TABLE domain (
did INTEGER,
name TEXT,
PRIMARY KEY (did)
)
CREATE TABLE domain_author (
aid INTEGER,
did INTEGER,
PRIMARY KEY (did, aid),
FOREIGN KEY(did) REFERENCES domain (did),
FOREIGN KEY(aid) REFERENCES author (aid)
)
CREATE TABLE domain_conference (
cid INTEGER,
did INTEGER,
PRIMARY KEY (did, cid),
FOREIGN KEY(did) REFERENCES domain (did),
FOREIGN KEY(cid) REFERENCES conference (cid)
)
CREATE TABLE domain_journal (
did INTEGER,
jid INTEGER,
PRIMARY KEY (did, jid),
FOREIGN KEY(jid) REFERENCES journal (jid),
FOREIGN KEY(did) REFERENCES domain (did)
)
CREATE TABLE domain_keyword (
did INTEGER,
kid INTEGER,
PRIMARY KEY (did, kid),
FOREIGN KEY(kid) REFERENCES keyword (kid),
FOREIGN KEY(did) REFERENCES domain (did)
)
CREATE TABLE domain_publication (
did INTEGER,
pid INTEGER,
PRIMARY KEY (did, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(did) REFERENCES domain (did)
)
CREATE TABLE journal (
homepage TEXT,
jid INTEGER,
name TEXT,
PRIMARY KEY (jid)
)
CREATE TABLE keyword (
keyword TEXT,
kid INTEGER,
PRIMARY KEY (kid)
)
CREATE TABLE organization (
continent TEXT,
homepage TEXT,
name TEXT,
oid INTEGER,
PRIMARY KEY (oid)
)
CREATE TABLE publication (
abstract TEXT,
cid TEXT,
citation_num INTEGER,
jid INTEGER,
pid INTEGER,
reference_num INTEGER,
title TEXT,
year INTEGER,
PRIMARY KEY (pid),
FOREIGN KEY(jid) REFERENCES journal (jid),
FOREIGN KEY(cid) REFERENCES conference (cid)
)
CREATE TABLE publication_keyword (
pid INTEGER,
kid INTEGER,
PRIMARY KEY (kid, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(kid) REFERENCES keyword (kid)
)
CREATE TABLE writes (
aid INTEGER,
pid INTEGER,
PRIMARY KEY (aid, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(aid) REFERENCES author (aid)
) |
CREATE TABLE author (
aid INTEGER,
homepage TEXT,
name TEXT,
oid INTEGER,
PRIMARY KEY (aid)
)
/*
2 rows from author table:
aid homepage name oid
*/
CREATE TABLE cite (
cited INTEGER,
citing INTEGER,
FOREIGN KEY(cited) REFERENCES publication (pid),
FOREIGN KEY(citing) REFERENCES publication (pid)
)
/*
2 rows from cite table:
cited citing
*/
CREATE TABLE conference (
cid INTEGER,
homepage TEXT,
name TEXT,
PRIMARY KEY (cid)
)
/*
2 rows from conference table:
cid homepage name
*/
CREATE TABLE domain (
did INTEGER,
name TEXT,
PRIMARY KEY (did)
)
/*
2 rows from domain table:
did name
*/
CREATE TABLE domain_author (
aid INTEGER,
did INTEGER,
PRIMARY KEY (did, aid),
FOREIGN KEY(did) REFERENCES domain (did),
FOREIGN KEY(aid) REFERENCES author (aid)
)
/*
2 rows from domain_author table:
aid did
*/
CREATE TABLE domain_conference (
cid INTEGER,
did INTEGER,
PRIMARY KEY (did, cid),
FOREIGN KEY(did) REFERENCES domain (did),
FOREIGN KEY(cid) REFERENCES conference (cid)
)
/*
2 rows from domain_conference table:
cid did
*/
CREATE TABLE domain_journal (
did INTEGER,
jid INTEGER,
PRIMARY KEY (did, jid),
FOREIGN KEY(jid) REFERENCES journal (jid),
FOREIGN KEY(did) REFERENCES domain (did)
)
/*
2 rows from domain_journal table:
did jid
*/
CREATE TABLE domain_keyword (
did INTEGER,
kid INTEGER,
PRIMARY KEY (did, kid),
FOREIGN KEY(kid) REFERENCES keyword (kid),
FOREIGN KEY(did) REFERENCES domain (did)
)
/*
2 rows from domain_keyword table:
did kid
*/
CREATE TABLE domain_publication (
did INTEGER,
pid INTEGER,
PRIMARY KEY (did, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(did) REFERENCES domain (did)
)
/*
2 rows from domain_publication table:
did pid
*/
CREATE TABLE journal (
homepage TEXT,
jid INTEGER,
name TEXT,
PRIMARY KEY (jid)
)
/*
2 rows from journal table:
homepage jid name
*/
CREATE TABLE keyword (
keyword TEXT,
kid INTEGER,
PRIMARY KEY (kid)
)
/*
2 rows from keyword table:
keyword kid
*/
CREATE TABLE organization (
continent TEXT,
homepage TEXT,
name TEXT,
oid INTEGER,
PRIMARY KEY (oid)
)
/*
2 rows from organization table:
continent homepage name oid
*/
CREATE TABLE publication (
abstract TEXT,
cid TEXT,
citation_num INTEGER,
jid INTEGER,
pid INTEGER,
reference_num INTEGER,
title TEXT,
year INTEGER,
PRIMARY KEY (pid),
FOREIGN KEY(jid) REFERENCES journal (jid),
FOREIGN KEY(cid) REFERENCES conference (cid)
)
/*
2 rows from publication table:
abstract cid citation_num jid pid reference_num title year
*/
CREATE TABLE publication_keyword (
pid INTEGER,
kid INTEGER,
PRIMARY KEY (kid, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(kid) REFERENCES keyword (kid)
)
/*
2 rows from publication_keyword table:
pid kid
*/
CREATE TABLE writes (
aid INTEGER,
pid INTEGER,
PRIMARY KEY (aid, pid),
FOREIGN KEY(pid) REFERENCES publication (pid),
FOREIGN KEY(aid) REFERENCES author (aid)
)
/*
2 rows from writes table:
aid pid
*/ | return me the number of papers by " H. V. Jagadish " . | SELECT COUNT ( DISTINCT t3.title ) FROM writes AS t2 JOIN author AS t1 ON t2.aid = t1.aid JOIN publication AS t3 ON t2.pid = t3.pid WHERE t1.name = "H. V. Jagadish"; | [{'COUNT ( DISTINCT t3.title )': 0}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | [QUESTION]return me the number of papers written by " H. V. Jagadish " and " Divesh Srivastava " .[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t5.title ) FROM writes AS t3 JOIN author AS t2 ON t3.aid = t2.aid JOIN publication AS t5 ON t3.pid = t5.pid JOIN writes AS t4 ON t4.pid = t5.pid JOIN author AS t1 ON t4.aid = t1.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Divesh Srivastava";[/SQL] | [QUESTION]return me the number of papers written by " H. V. Jagadish " and " Divesh Srivastava " .[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t5.title ) FROM writes AS t3 JOIN author AS t2 ON t3.aid = t2.aid JOIN publication AS t5 ON t3.pid = t5.pid JOIN writes AS t4 ON t4.pid = t5.pid JOIN author AS t1 ON t4.aid = t1.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Divesh Srivastava";[/SQL] | [QUESTION]return me the number of papers written by " H. V. Jagadish " and " Divesh Srivastava " .[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t5.title ) FROM writes AS t3 JOIN author AS t2 ON t3.aid = t2.aid JOIN publication AS t5 ON t3.pid = t5.pid JOIN writes AS t4 ON t4.pid = t5.pid JOIN author AS t1 ON t4.aid = t1.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Divesh Srivastava";[/SQL] | [QUESTION]return me the number of papers written by " H. V. Jagadish " and " Divesh Srivastava " .[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t5.title ) FROM writes AS t3 JOIN author AS t2 ON t3.aid = t2.aid JOIN publication AS t5 ON t3.pid = t5.pid JOIN writes AS t4 ON t4.pid = t5.pid JOIN author AS t1 ON t4.aid = t1.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Divesh Srivastava";[/SQL] |
geo |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
) |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from border_info table:
state_name border
*/
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from city table:
city_name population country_name state_name
*/
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from highlow table:
state_name highest_elevation lowest_point highest_point lowest_elevation
*/
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
/*
2 rows from lake table:
lake_name area country_name state_name
*/
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from mountain table:
mountain_name mountain_altitude country_name state_name
*/
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
/*
2 rows from river table:
river_name length country_name traverse
*/
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
)
/*
2 rows from state table:
state_name population area country_name capital density
*/ | which state capital has the smallest population | SELECT city_name FROM city WHERE population = ( SELECT MIN ( t1.population ) FROM state AS t2 JOIN city AS t1 ON t2.capital = t1.city_name ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | true | false | true | false | false | false | [QUESTION]what is capital of the state with the lowest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.lowest_elevation = ( SELECT MIN ( lowest_elevation ) FROM highlow ) ;[/SQL] | [QUESTION]what is capital of the state with the lowest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.lowest_elevation = ( SELECT MIN ( lowest_elevation ) FROM highlow ) ;[/SQL] | [QUESTION]what is capital of the state with the lowest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.lowest_elevation = ( SELECT MIN ( lowest_elevation ) FROM highlow ) ;[/SQL] | [QUESTION]what is capital of the state with the lowest point[/QUESTION]
[SQL]SELECT t1.capital FROM highlow AS t2 JOIN state AS t1 ON t1.state_name = t2.state_name WHERE t2.lowest_elevation = ( SELECT MIN ( lowest_elevation ) FROM highlow ) ;[/SQL] |
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | authors with at least 5 papers | SELECT DISTINCT COUNT ( t2.paperid ) , t1.authorid FROM writes AS t1 JOIN paper AS t2 ON t1.paperid = t2.paperid GROUP BY t1.authorid HAVING COUNT ( t2.paperid ) >= 5; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Medium | true | false | false | false | false | true | true | true | false | false | false | false | false | [QUESTION]return me the authors who have more than 10 papers in PVLDB .[/QUESTION]
[SQL]SELECT t1.name FROM publication AS t4 JOIN journal AS t2 ON t4.jid = t2.jid JOIN writes AS t3 ON t3.pid = t4.pid JOIN author AS t1 ON t3.aid = t1.aid WHERE t2.name = "PVLDB" GROUP BY t1.name HAVING COUNT ( DISTINCT t4.title ) > 10;[/SQL] | [QUESTION]return me the authors who have more than 10 papers in PVLDB .[/QUESTION]
[SQL]SELECT t1.name FROM publication AS t4 JOIN journal AS t2 ON t4.jid = t2.jid JOIN writes AS t3 ON t3.pid = t4.pid JOIN author AS t1 ON t3.aid = t1.aid WHERE t2.name = "PVLDB" GROUP BY t1.name HAVING COUNT ( DISTINCT t4.title ) > 10;[/SQL] | [QUESTION]return me the authors who have more than 10 papers in PVLDB .[/QUESTION]
[SQL]SELECT t1.name FROM publication AS t4 JOIN journal AS t2 ON t4.jid = t2.jid JOIN writes AS t3 ON t3.pid = t4.pid JOIN author AS t1 ON t3.aid = t1.aid WHERE t2.name = "PVLDB" GROUP BY t1.name HAVING COUNT ( DISTINCT t4.title ) > 10;[/SQL] | [QUESTION]return me the authors who have more than 10 papers in PVLDB .[/QUESTION]
[SQL]SELECT t1.name FROM publication AS t4 JOIN journal AS t2 ON t4.jid = t2.jid JOIN writes AS t3 ON t3.pid = t4.pid JOIN author AS t1 ON t3.aid = t1.aid WHERE t2.name = "PVLDB" GROUP BY t1.name HAVING COUNT ( DISTINCT t4.title ) > 10;[/SQL] |
cre_Doc_Tracking_DB |
CREATE TABLE "All_Documents" (
"Document_ID" INTEGER NOT NULL,
"Date_Stored" DATETIME,
"Document_Type_Code" CHAR(15) NOT NULL,
"Document_Name" CHAR(255),
"Document_Description" CHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Date_Stored") REFERENCES "Ref_Calendar" ("Calendar_Date")
)
CREATE TABLE "Document_Locations" (
"Document_ID" INTEGER NOT NULL,
"Location_Code" CHAR(15) NOT NULL,
"Date_in_Location_From" DATETIME NOT NULL,
"Date_in_Locaton_To" DATETIME,
PRIMARY KEY ("Document_ID", "Location_Code", "Date_in_Location_From"),
FOREIGN KEY("Location_Code") REFERENCES "Ref_Locations" ("Location_Code"),
FOREIGN KEY("Date_in_Location_From") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Date_in_Locaton_To") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Document_ID") REFERENCES "All_Documents" ("Document_ID")
)
CREATE TABLE "Documents_to_be_Destroyed" (
"Document_ID" INTEGER NOT NULL,
"Destruction_Authorised_by_Employee_ID" INTEGER,
"Destroyed_by_Employee_ID" INTEGER,
"Planned_Destruction_Date" DATETIME,
"Actual_Destruction_Date" DATETIME,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Destroyed_by_Employee_ID") REFERENCES "Employees" ("Employee_ID"),
FOREIGN KEY("Destruction_Authorised_by_Employee_ID") REFERENCES "Employees" ("Employee_ID"),
FOREIGN KEY("Planned_Destruction_Date") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Actual_Destruction_Date") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Document_ID") REFERENCES "All_Documents" ("Document_ID")
)
CREATE TABLE "Employees" (
"Employee_ID" INTEGER NOT NULL,
"Role_Code" CHAR(15) NOT NULL,
"Employee_Name" VARCHAR(255),
"Gender_MFU" CHAR(1) NOT NULL,
"Date_of_Birth" DATETIME NOT NULL,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Employee_ID"),
FOREIGN KEY("Role_Code") REFERENCES "Roles" ("Role_Code")
)
CREATE TABLE "Ref_Calendar" (
"Calendar_Date" DATETIME NOT NULL,
"Day_Number" INTEGER,
PRIMARY KEY ("Calendar_Date")
)
CREATE TABLE "Ref_Document_Types" (
"Document_Type_Code" CHAR(15) NOT NULL,
"Document_Type_Name" VARCHAR(255) NOT NULL,
"Document_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Document_Type_Code")
)
CREATE TABLE "Ref_Locations" (
"Location_Code" CHAR(15) NOT NULL,
"Location_Name" VARCHAR(255) NOT NULL,
"Location_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Location_Code")
)
CREATE TABLE "Roles" (
"Role_Code" CHAR(15) NOT NULL,
"Role_Name" VARCHAR(255),
"Role_Description" VARCHAR(255),
PRIMARY KEY ("Role_Code")
) |
CREATE TABLE "All_Documents" (
"Document_ID" INTEGER NOT NULL,
"Date_Stored" DATETIME,
"Document_Type_Code" CHAR(15) NOT NULL,
"Document_Name" CHAR(255),
"Document_Description" CHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Date_Stored") REFERENCES "Ref_Calendar" ("Calendar_Date")
)
/*
2 rows from All_Documents table:
Document_ID Date_Stored Document_Type_Code Document_Name Document_Description Other_Details
7 1976-06-15 03:40:06 CV Robin CV None None
11 1986-10-14 17:53:39 CV Marry CV None None
*/
CREATE TABLE "Document_Locations" (
"Document_ID" INTEGER NOT NULL,
"Location_Code" CHAR(15) NOT NULL,
"Date_in_Location_From" DATETIME NOT NULL,
"Date_in_Locaton_To" DATETIME,
PRIMARY KEY ("Document_ID", "Location_Code", "Date_in_Location_From"),
FOREIGN KEY("Location_Code") REFERENCES "Ref_Locations" ("Location_Code"),
FOREIGN KEY("Date_in_Location_From") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Date_in_Locaton_To") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Document_ID") REFERENCES "All_Documents" ("Document_ID")
)
/*
2 rows from Document_Locations table:
Document_ID Location_Code Date_in_Location_From Date_in_Locaton_To
7 e 2017-01-06 23:17:22 2008-06-08 12:45:38
11 x 2017-01-06 23:17:22 2012-07-03 09:48:46
*/
CREATE TABLE "Documents_to_be_Destroyed" (
"Document_ID" INTEGER NOT NULL,
"Destruction_Authorised_by_Employee_ID" INTEGER,
"Destroyed_by_Employee_ID" INTEGER,
"Planned_Destruction_Date" DATETIME,
"Actual_Destruction_Date" DATETIME,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Destroyed_by_Employee_ID") REFERENCES "Employees" ("Employee_ID"),
FOREIGN KEY("Destruction_Authorised_by_Employee_ID") REFERENCES "Employees" ("Employee_ID"),
FOREIGN KEY("Planned_Destruction_Date") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Actual_Destruction_Date") REFERENCES "Ref_Calendar" ("Calendar_Date"),
FOREIGN KEY("Document_ID") REFERENCES "All_Documents" ("Document_ID")
)
/*
2 rows from Documents_to_be_Destroyed table:
Document_ID Destruction_Authorised_by_Employee_ID Destroyed_by_Employee_ID Planned_Destruction_Date Actual_Destruction_Date Other_Details
7 156 138 1988-02-01 14:41:52 2017-01-06 23:17:22 None
11 55 173 2010-11-26 19:22:50 1986-10-14 17:53:39 None
*/
CREATE TABLE "Employees" (
"Employee_ID" INTEGER NOT NULL,
"Role_Code" CHAR(15) NOT NULL,
"Employee_Name" VARCHAR(255),
"Gender_MFU" CHAR(1) NOT NULL,
"Date_of_Birth" DATETIME NOT NULL,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Employee_ID"),
FOREIGN KEY("Role_Code") REFERENCES "Roles" ("Role_Code")
)
/*
2 rows from Employees table:
Employee_ID Role_Code Employee_Name Gender_MFU Date_of_Birth Other_Details
25 HR Leo 1973-02-15 17:16:00 None
30 MG Ebba 1979-09-20 12:50:15 None
*/
CREATE TABLE "Ref_Calendar" (
"Calendar_Date" DATETIME NOT NULL,
"Day_Number" INTEGER,
PRIMARY KEY ("Calendar_Date")
)
/*
2 rows from Ref_Calendar table:
Calendar_Date Day_Number
1972-03-31 09:47:22 5
1976-06-15 03:40:06 7
*/
CREATE TABLE "Ref_Document_Types" (
"Document_Type_Code" CHAR(15) NOT NULL,
"Document_Type_Name" VARCHAR(255) NOT NULL,
"Document_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Document_Type_Code")
)
/*
2 rows from Ref_Document_Types table:
Document_Type_Code Document_Type_Name Document_Type_Description
CV CV
BK Book
*/
CREATE TABLE "Ref_Locations" (
"Location_Code" CHAR(15) NOT NULL,
"Location_Name" VARCHAR(255) NOT NULL,
"Location_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Location_Code")
)
/*
2 rows from Ref_Locations table:
Location_Code Location_Name Location_Description
b Brazil
c Canada
*/
CREATE TABLE "Roles" (
"Role_Code" CHAR(15) NOT NULL,
"Role_Name" VARCHAR(255),
"Role_Description" VARCHAR(255),
PRIMARY KEY ("Role_Code")
)
/*
2 rows from Roles table:
Role_Code Role_Name Role_Description
MG Manager Vero harum corrupti odit ipsa vero et odio. Iste et recusandae temporibus maxime. Magni aspernatur f
ED Editor Itaque dolor ut nemo rerum vitae provident. Vel laborum ipsum velit sint. Et est omnis dignissimos.
*/ | What are the roles with three or more employees? Give me the role codes. | SELECT role_code FROM Employees GROUP BY role_code HAVING count(*) >= 3 | [{'Role_Code': 'ED'}, {'Role_Code': 'PR'}] | Easy | false | false | false | false | false | true | true | false | false | false | false | false | false | [QUESTION]What is the count and code of the job with the most employee?[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the count and code of the job with the most employee?[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the count and code of the job with the most employee?[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the count and code of the job with the most employee?[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] |
yelp |
CREATE TABLE business (
bid INTEGER,
business_id TEXT,
name TEXT,
full_address TEXT,
city TEXT,
latitude TEXT,
longitude TEXT,
review_count INTEGER,
is_open INTEGER,
rating REAL,
state TEXT,
PRIMARY KEY (bid)
)
CREATE TABLE category (
id INTEGER,
business_id TEXT,
category_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE checkin (
cid INTEGER,
business_id TEXT,
count INTEGER,
day TEXT,
PRIMARY KEY (cid),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE neighbourhood (
id INTEGER,
business_id TEXT,
neighbourhood_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE review (
rid INTEGER,
business_id TEXT,
user_id TEXT,
rating REAL,
text TEXT,
year INTEGER,
month TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE tip (
tip_id INTEGER,
business_id TEXT,
text TEXT,
user_id TEXT,
likes INTEGER,
year INTEGER,
month TEXT,
PRIMARY KEY (tip_id),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
CREATE TABLE user (
uid INTEGER,
user_id TEXT,
name TEXT,
PRIMARY KEY (uid)
) |
CREATE TABLE business (
bid INTEGER,
business_id TEXT,
name TEXT,
full_address TEXT,
city TEXT,
latitude TEXT,
longitude TEXT,
review_count INTEGER,
is_open INTEGER,
rating REAL,
state TEXT,
PRIMARY KEY (bid)
)
/*
2 rows from business table:
bid business_id name full_address city latitude longitude review_count is_open rating state
*/
CREATE TABLE category (
id INTEGER,
business_id TEXT,
category_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from category table:
id business_id category_name
*/
CREATE TABLE checkin (
cid INTEGER,
business_id TEXT,
count INTEGER,
day TEXT,
PRIMARY KEY (cid),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from checkin table:
cid business_id count day
*/
CREATE TABLE neighbourhood (
id INTEGER,
business_id TEXT,
neighbourhood_name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from neighbourhood table:
id business_id neighbourhood_name
*/
CREATE TABLE review (
rid INTEGER,
business_id TEXT,
user_id TEXT,
rating REAL,
text TEXT,
year INTEGER,
month TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from review table:
rid business_id user_id rating text year month
*/
CREATE TABLE tip (
tip_id INTEGER,
business_id TEXT,
text TEXT,
user_id TEXT,
likes INTEGER,
year INTEGER,
month TEXT,
PRIMARY KEY (tip_id),
FOREIGN KEY(user_id) REFERENCES user (user_id),
FOREIGN KEY(business_id) REFERENCES business (business_id)
)
/*
2 rows from tip table:
tip_id business_id text user_id likes year month
*/
CREATE TABLE user (
uid INTEGER,
user_id TEXT,
name TEXT,
PRIMARY KEY (uid)
)
/*
2 rows from user table:
uid user_id name
*/ | Find all Bars reviewed by Patrick | SELECT t1.name FROM category AS t2 JOIN business AS t1 ON t2.business_id = t1.business_id JOIN review AS t3 ON t3.business_id = t1.business_id JOIN USER AS t4 ON t4.user_id = t3.user_id WHERE t2.category_name = "Bars" AND t4.name = "Patrick"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | false | false | false | false | false | false | false | false | true | false | false | false | false | ||||
university_basketball |
CREATE TABLE basketball_match (
"Team_ID" INTEGER,
"School_ID" INTEGER,
"Team_Name" TEXT,
"ACC_Regular_Season" TEXT,
"ACC_Percent" TEXT,
"ACC_Home" TEXT,
"ACC_Road" TEXT,
"All_Games" TEXT,
"All_Games_Percent" INTEGER,
"All_Home" TEXT,
"All_Road" TEXT,
"All_Neutral" TEXT,
PRIMARY KEY ("Team_ID"),
FOREIGN KEY("School_ID") REFERENCES university ("School_ID")
)
CREATE TABLE university (
"School_ID" INTEGER,
"School" TEXT,
"Location" TEXT,
"Founded" REAL,
"Affiliation" TEXT,
"Enrollment" REAL,
"Nickname" TEXT,
"Primary_conference" TEXT,
PRIMARY KEY ("School_ID")
) |
CREATE TABLE basketball_match (
"Team_ID" INTEGER,
"School_ID" INTEGER,
"Team_Name" TEXT,
"ACC_Regular_Season" TEXT,
"ACC_Percent" TEXT,
"ACC_Home" TEXT,
"ACC_Road" TEXT,
"All_Games" TEXT,
"All_Games_Percent" INTEGER,
"All_Home" TEXT,
"All_Road" TEXT,
"All_Neutral" TEXT,
PRIMARY KEY ("Team_ID"),
FOREIGN KEY("School_ID") REFERENCES university ("School_ID")
)
/*
2 rows from basketball_match table:
Team_ID School_ID Team_Name ACC_Regular_Season ACC_Percent ACC_Home ACC_Road All_Games All_Games_Percent All_Home All_Road All_Neutral
1 1 North Carolina 14–2 .875 6–2 8–0 35–2 0.946 14–2 13–0 9–1
2 2 Duke 13–3 .813 7–1 6–2 28–6 0.824 15–1 8–2 5–3
*/
CREATE TABLE university (
"School_ID" INTEGER,
"School" TEXT,
"Location" TEXT,
"Founded" REAL,
"Affiliation" TEXT,
"Enrollment" REAL,
"Nickname" TEXT,
"Primary_conference" TEXT,
PRIMARY KEY ("School_ID")
)
/*
2 rows from university table:
School_ID School Location Founded Affiliation Enrollment Nickname Primary_conference
1 University of Delaware Newark, DE 1743.0 Public 19067.0 Fightin' Blue Hens Colonial Athletic Association ( D-I )
2 Lebanon Valley College Annville, PA 1866.0 Private/Methodist 2100.0 Flying Dutchmen MAC Commonwealth Conference ( D-III )
*/ | What are the average enrollment size of the universities that are founded before 1850? | SELECT avg(enrollment) FROM university WHERE founded < 1850 | [{'avg(enrollment)': 37967.5}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the name of the department that has the largest number of students enrolled?[/QUESTION]
[SQL]SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the name of the department that has the largest number of students enrolled?[/QUESTION]
[SQL]SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the name of the department that has the largest number of students enrolled?[/QUESTION]
[SQL]SELECT T4.dept_name FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN course AS T3 ON T1.crs_code = T3.crs_code JOIN department AS T4 ON T3.dept_code = T4.dept_code GROUP BY T3.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] |
|
storm_record |
CREATE TABLE affected_region (
"Region_id" INTEGER,
"Storm_ID" INTEGER,
"Number_city_affected" REAL,
PRIMARY KEY ("Region_id", "Storm_ID"),
FOREIGN KEY("Storm_ID") REFERENCES storm ("Storm_ID"),
FOREIGN KEY("Region_id") REFERENCES region ("Region_id")
)
CREATE TABLE region (
"Region_id" INTEGER,
"Region_code" TEXT,
"Region_name" TEXT,
PRIMARY KEY ("Region_id")
)
CREATE TABLE storm (
"Storm_ID" INTEGER,
"Name" TEXT,
"Dates_active" TEXT,
"Max_speed" INTEGER,
"Damage_millions_USD" REAL,
"Number_Deaths" INTEGER,
PRIMARY KEY ("Storm_ID")
) |
CREATE TABLE affected_region (
"Region_id" INTEGER,
"Storm_ID" INTEGER,
"Number_city_affected" REAL,
PRIMARY KEY ("Region_id", "Storm_ID"),
FOREIGN KEY("Storm_ID") REFERENCES storm ("Storm_ID"),
FOREIGN KEY("Region_id") REFERENCES region ("Region_id")
)
/*
2 rows from affected_region table:
Region_id Storm_ID Number_city_affected
1 1 10.0
2 1 15.0
*/
CREATE TABLE region (
"Region_id" INTEGER,
"Region_code" TEXT,
"Region_name" TEXT,
PRIMARY KEY ("Region_id")
)
/*
2 rows from region table:
Region_id Region_code Region_name
1 AF Afghanistan
2 AL Albania
*/
CREATE TABLE storm (
"Storm_ID" INTEGER,
"Name" TEXT,
"Dates_active" TEXT,
"Max_speed" INTEGER,
"Damage_millions_USD" REAL,
"Number_Deaths" INTEGER,
PRIMARY KEY ("Storm_ID")
)
/*
2 rows from storm table:
Storm_ID Name Dates_active Max_speed Damage_millions_USD Number_Deaths
1 One May19–May25 995 13.0 0
2 Two August3–August10 972 10.75 7
*/ | What are the names of the regions in alphabetical order? | SELECT region_name FROM region ORDER BY region_name | [{'Region_name': 'Afghanistan'}, {'Region_name': 'Albania'}, {'Region_name': 'Algeria'}, {'Region_name': 'American Samoa'}, {'Region_name': 'Andorra'}, {'Region_name': 'Angola'}, {'Region_name': 'Anguilla'}, {'Region_name': 'Antarctica'}, {'Region_name': 'Antigua and Barbuda'}, {'Region_name': 'Cyprus'}, {'Region_name': 'Czech Republic'}, {'Region_name': 'Denmark'}, {'Region_name': 'Djibouti'}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of the sections in reverse alphabetical order?[/QUESTION]
[SQL]SELECT section_name FROM Sections ORDER BY section_name DESC[/SQL] | [QUESTION]What are the names of the sections in reverse alphabetical order?[/QUESTION]
[SQL]SELECT section_name FROM Sections ORDER BY section_name DESC[/SQL] | [QUESTION]What are the names of the sections in reverse alphabetical order?[/QUESTION]
[SQL]SELECT section_name FROM Sections ORDER BY section_name DESC[/SQL] | [QUESTION]What are the names of the sections in reverse alphabetical order?[/QUESTION]
[SQL]SELECT section_name FROM Sections ORDER BY section_name DESC[/SQL] |
ship_1 |
CREATE TABLE "Ship" (
"Ship_ID" INTEGER,
"Name" TEXT,
"Type" TEXT,
"Built_Year" REAL,
"Class" TEXT,
"Flag" TEXT,
PRIMARY KEY ("Ship_ID")
)
CREATE TABLE captain (
"Captain_ID" INTEGER,
"Name" TEXT,
"Ship_ID" INTEGER,
age TEXT,
"Class" TEXT,
"Rank" TEXT,
PRIMARY KEY ("Captain_ID"),
FOREIGN KEY("Ship_ID") REFERENCES "Ship" ("Ship_ID")
) |
CREATE TABLE "Ship" (
"Ship_ID" INTEGER,
"Name" TEXT,
"Type" TEXT,
"Built_Year" REAL,
"Class" TEXT,
"Flag" TEXT,
PRIMARY KEY ("Ship_ID")
)
/*
2 rows from Ship table:
Ship_ID Name Type Built_Year Class Flag
1 HMS Manxman Panamax 1997.0 KR Panama
2 HMS Gorgon Panamax 1998.0 KR Panama
*/
CREATE TABLE captain (
"Captain_ID" INTEGER,
"Name" TEXT,
"Ship_ID" INTEGER,
age TEXT,
"Class" TEXT,
"Rank" TEXT,
PRIMARY KEY ("Captain_ID"),
FOREIGN KEY("Ship_ID") REFERENCES "Ship" ("Ship_ID")
)
/*
2 rows from captain table:
Captain_ID Name Ship_ID age Class Rank
1 Captain Sir Henry Langford 1 40 Third-rate ship of the line Midshipman
2 Captain Beves Conway 2 54 Third-rate ship of the line Midshipman
*/ | Which classes have more than two captains? | SELECT CLASS FROM captain GROUP BY CLASS HAVING count(*) > 2 | [{'Class': 'Third-rate ship of the line'}] | Easy | false | false | false | false | false | true | true | false | false | false | false | false | false | [QUESTION]How many different classes are there?[/QUESTION]
[SQL]SELECT count(DISTINCT class_code) FROM CLASS[/SQL] | [QUESTION]How many different classes are there?[/QUESTION]
[SQL]SELECT count(DISTINCT class_code) FROM CLASS[/SQL] | [QUESTION]How many different classes are there?[/QUESTION]
[SQL]SELECT count(DISTINCT class_code) FROM CLASS[/SQL] | [QUESTION]How many different classes are there?[/QUESTION]
[SQL]SELECT count(DISTINCT class_code) FROM CLASS[/SQL] |
soccer_2 |
CREATE TABLE "College" (
"cName" VARCHAR(20) NOT NULL,
state VARCHAR(2),
enr NUMERIC(5, 0),
PRIMARY KEY ("cName")
)
CREATE TABLE "Player" (
"pID" NUMERIC(5, 0) NOT NULL,
"pName" VARCHAR(20),
"yCard" VARCHAR(3),
"HS" NUMERIC(5, 0),
PRIMARY KEY ("pID")
)
CREATE TABLE "Tryout" (
"pID" NUMERIC(5, 0),
"cName" VARCHAR(20),
"pPos" VARCHAR(8),
decision VARCHAR(3),
PRIMARY KEY ("pID", "cName"),
FOREIGN KEY("pID") REFERENCES "Player" ("pID"),
FOREIGN KEY("cName") REFERENCES "College" ("cName")
) |
CREATE TABLE "College" (
"cName" VARCHAR(20) NOT NULL,
state VARCHAR(2),
enr NUMERIC(5, 0),
PRIMARY KEY ("cName")
)
/*
2 rows from College table:
cName state enr
LSU LA 18000
ASU AZ 12000
*/
CREATE TABLE "Player" (
"pID" NUMERIC(5, 0) NOT NULL,
"pName" VARCHAR(20),
"yCard" VARCHAR(3),
"HS" NUMERIC(5, 0),
PRIMARY KEY ("pID")
)
/*
2 rows from Player table:
pID pName yCard HS
10001 Andrew no 1200
20002 Blake no 1600
*/
CREATE TABLE "Tryout" (
"pID" NUMERIC(5, 0),
"cName" VARCHAR(20),
"pPos" VARCHAR(8),
decision VARCHAR(3),
PRIMARY KEY ("pID", "cName"),
FOREIGN KEY("pID") REFERENCES "Player" ("pID"),
FOREIGN KEY("cName") REFERENCES "College" ("cName")
)
/*
2 rows from Tryout table:
pID cName pPos decision
10001 LSU goalie no
10001 ASU goalie yes
*/ | What is the count of states with college students playing in the mid position but not as goalies? | SELECT COUNT(*) FROM (SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'mid' EXCEPT SELECT T1.state FROM college AS T1 JOIN tryout AS T2 ON T1.cName = T2.cName WHERE T2.pPos = 'goalie') | [{'COUNT(*)': 1}] | Hard | false | false | false | false | false | false | false | false | true | false | false | true | false | ||||
entertainment_awards |
CREATE TABLE artwork (
"Artwork_ID" INTEGER,
"Type" TEXT,
"Name" TEXT,
PRIMARY KEY ("Artwork_ID")
)
CREATE TABLE festival_detail (
"Festival_ID" INTEGER,
"Festival_Name" TEXT,
"Chair_Name" TEXT,
"Location" TEXT,
"Year" INTEGER,
"Num_of_Audience" INTEGER,
PRIMARY KEY ("Festival_ID")
)
CREATE TABLE nomination (
"Artwork_ID" INTEGER,
"Festival_ID" INTEGER,
"Result" TEXT,
PRIMARY KEY ("Artwork_ID", "Festival_ID"),
FOREIGN KEY("Festival_ID") REFERENCES festival_detail ("Festival_ID"),
FOREIGN KEY("Artwork_ID") REFERENCES artwork ("Artwork_ID")
) |
CREATE TABLE artwork (
"Artwork_ID" INTEGER,
"Type" TEXT,
"Name" TEXT,
PRIMARY KEY ("Artwork_ID")
)
/*
2 rows from artwork table:
Artwork_ID Type Name
1 Program Music/Variety Show Indonesian Idol
2 Program Music/Variety Show I Know
*/
CREATE TABLE festival_detail (
"Festival_ID" INTEGER,
"Festival_Name" TEXT,
"Chair_Name" TEXT,
"Location" TEXT,
"Year" INTEGER,
"Num_of_Audience" INTEGER,
PRIMARY KEY ("Festival_ID")
)
/*
2 rows from festival_detail table:
Festival_ID Festival_Name Chair_Name Location Year Num_of_Audience
1 Panasonic Awards Raymond Floyd United States 2006 152
2 Flower Awards Charles Coody United States 2007 155
*/
CREATE TABLE nomination (
"Artwork_ID" INTEGER,
"Festival_ID" INTEGER,
"Result" TEXT,
PRIMARY KEY ("Artwork_ID", "Festival_ID"),
FOREIGN KEY("Festival_ID") REFERENCES festival_detail ("Festival_ID"),
FOREIGN KEY("Artwork_ID") REFERENCES artwork ("Artwork_ID")
)
/*
2 rows from nomination table:
Artwork_ID Festival_ID Result
1 2 Nominated
2 2 Won
*/ | What is the location of the festival with the largest number of audience? | SELECT LOCATION FROM festival_detail ORDER BY Num_of_Audience DESC LIMIT 1 | [{'Location': 'United States'}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] | [QUESTION]What are the names and locations of the stadiums that had concerts that occurred in both 2014 and 2015?[/QUESTION]
[SQL]SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2014 INTERSECT SELECT T2.name , T2.location FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.Year = 2015[/SQL] |
||
climbing |
CREATE TABLE climber (
"Climber_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Time" TEXT,
"Points" REAL,
"Mountain_ID" INTEGER,
PRIMARY KEY ("Climber_ID"),
FOREIGN KEY("Mountain_ID") REFERENCES mountain ("Mountain_ID")
)
CREATE TABLE mountain (
"Mountain_ID" INTEGER,
"Name" TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY ("Mountain_ID")
) |
CREATE TABLE climber (
"Climber_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Time" TEXT,
"Points" REAL,
"Mountain_ID" INTEGER,
PRIMARY KEY ("Climber_ID"),
FOREIGN KEY("Mountain_ID") REFERENCES mountain ("Mountain_ID")
)
/*
2 rows from climber table:
Climber_ID Name Country Time Points Mountain_ID
1 Klaus Enders West Germany 1:13.05.6 15.0 1
2 Siegfried Schauzu West Germany 1:14.56.4 12.0 1
*/
CREATE TABLE mountain (
"Mountain_ID" INTEGER,
"Name" TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY ("Mountain_ID")
)
/*
2 rows from mountain table:
Mountain_ID Name Height Prominence Range Country
1 Kibo (Uhuru Pk) 5895.0 5885.0 Kilimanjaro Tanzania
2 Mount Kenya (Batian) 5199.0 3825.0 Mount Kenya Kenya
*/ | What are the countries that have both mountains that are higher than 5600 and lower than 5200? | SELECT Country FROM mountain WHERE Height > 5600 INTERSECT SELECT Country FROM mountain WHERE Height < 5200 | [{'Country': 'Tanzania'}] | Hard | false | false | false | false | false | false | false | false | false | false | true | false | false | ||||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | who has written the most papers on semantic parsing since 2005 ? | SELECT DISTINCT COUNT ( t4.paperid ) , t3.authorid FROM paperkeyphrase AS t1 JOIN keyphrase AS t2 ON t1.keyphraseid = t2.keyphraseid JOIN paper AS t4 ON t4.paperid = t1.paperid JOIN writes AS t3 ON t3.paperid = t4.paperid WHERE t2.keyphrasename = "semantic parsing" AND t4.year > 2005 GROUP BY t3.authorid ORDER BY COUNT ( t4.paperid ) DESC; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | true | false | true | false | false | true | false | false | false | false | ||||
local_govt_and_lot |
CREATE TABLE "Customer_Event_Notes" (
"Customer_Event_Note_ID" INTEGER NOT NULL,
"Customer_Event_ID" INTEGER NOT NULL,
service_type_code CHAR(15) NOT NULL,
resident_id INTEGER NOT NULL,
property_id INTEGER NOT NULL,
date_moved_in DATETIME NOT NULL,
PRIMARY KEY ("Customer_Event_Note_ID"),
FOREIGN KEY("Customer_Event_ID") REFERENCES "Customer_Events" ("Customer_Event_ID")
)
CREATE TABLE "Customer_Events" (
"Customer_Event_ID" INTEGER NOT NULL,
customer_id INTEGER,
date_moved_in DATETIME,
property_id INTEGER,
resident_id INTEGER,
thing_id INTEGER NOT NULL,
PRIMARY KEY ("Customer_Event_ID"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES "Residents" (resident_id, property_id, date_moved_in)
)
CREATE TABLE "Customers" (
customer_id INTEGER NOT NULL,
customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Organizations" (
organization_id INTEGER NOT NULL,
parent_organization_id INTEGER,
organization_details VARCHAR(255),
PRIMARY KEY (organization_id)
)
CREATE TABLE "Properties" (
property_id INTEGER NOT NULL,
property_type_code CHAR(15) NOT NULL,
property_address VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (property_id)
)
CREATE TABLE "Residents" (
resident_id INTEGER NOT NULL,
property_id INTEGER NOT NULL,
date_moved_in DATETIME NOT NULL,
date_moved_out DATETIME NOT NULL,
other_details VARCHAR(255),
PRIMARY KEY (resident_id, property_id, date_moved_in),
FOREIGN KEY(property_id) REFERENCES "Properties" (property_id)
)
CREATE TABLE "Residents_Services" (
resident_id INTEGER NOT NULL,
service_id INTEGER NOT NULL,
date_moved_in DATETIME,
property_id INTEGER,
date_requested DATETIME,
date_provided DATETIME,
other_details VARCHAR(255),
PRIMARY KEY (resident_id, service_id),
FOREIGN KEY(service_id) REFERENCES "Services" (service_id),
FOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES "Residents" (resident_id, property_id, date_moved_in)
)
CREATE TABLE "Services" (
service_id INTEGER NOT NULL,
organization_id INTEGER NOT NULL,
service_type_code CHAR(15) NOT NULL,
service_details VARCHAR(255),
PRIMARY KEY (service_id),
FOREIGN KEY(organization_id) REFERENCES "Organizations" (organization_id)
)
CREATE TABLE "Things" (
thing_id INTEGER NOT NULL,
organization_id INTEGER NOT NULL,
"Type_of_Thing_Code" CHAR(15) NOT NULL,
service_type_code CHAR(10) NOT NULL,
service_details VARCHAR(255),
PRIMARY KEY (thing_id),
FOREIGN KEY(organization_id) REFERENCES "Organizations" (organization_id)
)
CREATE TABLE "Timed_Locations_of_Things" (
thing_id INTEGER NOT NULL,
"Date_and_Time" DATETIME NOT NULL,
"Location_Code" CHAR(15) NOT NULL,
PRIMARY KEY (thing_id, "Date_and_Time", "Location_Code"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id)
)
CREATE TABLE "Timed_Status_of_Things" (
thing_id INTEGER NOT NULL,
"Date_and_Date" DATETIME NOT NULL,
"Status_of_Thing_Code" CHAR(15) NOT NULL,
PRIMARY KEY (thing_id, "Date_and_Date", "Status_of_Thing_Code"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id)
) |
CREATE TABLE "Customer_Event_Notes" (
"Customer_Event_Note_ID" INTEGER NOT NULL,
"Customer_Event_ID" INTEGER NOT NULL,
service_type_code CHAR(15) NOT NULL,
resident_id INTEGER NOT NULL,
property_id INTEGER NOT NULL,
date_moved_in DATETIME NOT NULL,
PRIMARY KEY ("Customer_Event_Note_ID"),
FOREIGN KEY("Customer_Event_ID") REFERENCES "Customer_Events" ("Customer_Event_ID")
)
/*
2 rows from Customer_Event_Notes table:
Customer_Event_Note_ID Customer_Event_ID service_type_code resident_id property_id date_moved_in
18 70 Cleanning 58 107 2016-08-04 01:06:05
21 428 Check 87 445 2016-12-11 01:05:14
*/
CREATE TABLE "Customer_Events" (
"Customer_Event_ID" INTEGER NOT NULL,
customer_id INTEGER,
date_moved_in DATETIME,
property_id INTEGER,
resident_id INTEGER,
thing_id INTEGER NOT NULL,
PRIMARY KEY ("Customer_Event_ID"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES "Residents" (resident_id, property_id, date_moved_in)
)
/*
2 rows from Customer_Events table:
Customer_Event_ID customer_id date_moved_in property_id resident_id thing_id
70 19 2015-03-27 12:00:00 605 10 1
160 5 2015-03-27 12:00:00 879 23 80
*/
CREATE TABLE "Customers" (
customer_id INTEGER NOT NULL,
customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id customer_details
4 Mr. Raul Prosacco
5 Esteban Senger
*/
CREATE TABLE "Organizations" (
organization_id INTEGER NOT NULL,
parent_organization_id INTEGER,
organization_details VARCHAR(255),
PRIMARY KEY (organization_id)
)
/*
2 rows from Organizations table:
organization_id parent_organization_id organization_details
7 7 Reinger, Hudson and Nolan Group
8 7 Denesik and Sons Party
*/
CREATE TABLE "Properties" (
property_id INTEGER NOT NULL,
property_type_code CHAR(15) NOT NULL,
property_address VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (property_id)
)
/*
2 rows from Properties table:
property_id property_type_code property_address other_details
24 apartment 85456 Annie Lodge Suite 449 USA
107 house 2580 Yundt Plains USA
*/
CREATE TABLE "Residents" (
resident_id INTEGER NOT NULL,
property_id INTEGER NOT NULL,
date_moved_in DATETIME NOT NULL,
date_moved_out DATETIME NOT NULL,
other_details VARCHAR(255),
PRIMARY KEY (resident_id, property_id, date_moved_in),
FOREIGN KEY(property_id) REFERENCES "Properties" (property_id)
)
/*
2 rows from Residents table:
resident_id property_id date_moved_in date_moved_out other_details
6 954 2017-06-17 15:43:33 2017-12-18 03:46:04 Anderson Batz
10 605 2015-03-27 12:00:00 2018-03-17 07:48:09 Miss Naomie Osinski
*/
CREATE TABLE "Residents_Services" (
resident_id INTEGER NOT NULL,
service_id INTEGER NOT NULL,
date_moved_in DATETIME,
property_id INTEGER,
date_requested DATETIME,
date_provided DATETIME,
other_details VARCHAR(255),
PRIMARY KEY (resident_id, service_id),
FOREIGN KEY(service_id) REFERENCES "Services" (service_id),
FOREIGN KEY(resident_id, property_id, date_moved_in) REFERENCES "Residents" (resident_id, property_id, date_moved_in)
)
/*
2 rows from Residents_Services table:
resident_id service_id date_moved_in property_id date_requested date_provided other_details
6 49 2017-06-17 15:43:33 954 2016-07-25 01:32:23 2018-02-26 00:27:11 Satisfied
23 41 2015-03-27 12:00:00 879 2016-10-10 21:42:21 2017-08-21 06:23:06 Unsatisfied
*/
CREATE TABLE "Services" (
service_id INTEGER NOT NULL,
organization_id INTEGER NOT NULL,
service_type_code CHAR(15) NOT NULL,
service_details VARCHAR(255),
PRIMARY KEY (service_id),
FOREIGN KEY(organization_id) REFERENCES "Organizations" (organization_id)
)
/*
2 rows from Services table:
service_id organization_id service_type_code service_details
10 10 Cleanning Satisfied
11 7 Check Satisfied
*/
CREATE TABLE "Things" (
thing_id INTEGER NOT NULL,
organization_id INTEGER NOT NULL,
"Type_of_Thing_Code" CHAR(15) NOT NULL,
service_type_code CHAR(10) NOT NULL,
service_details VARCHAR(255),
PRIMARY KEY (thing_id),
FOREIGN KEY(organization_id) REFERENCES "Organizations" (organization_id)
)
/*
2 rows from Things table:
thing_id organization_id Type_of_Thing_Code service_type_code service_details
1 8 Electronics Check Unsatisfied
2 8 Electronics Cleanning Satisfied
*/
CREATE TABLE "Timed_Locations_of_Things" (
thing_id INTEGER NOT NULL,
"Date_and_Time" DATETIME NOT NULL,
"Location_Code" CHAR(15) NOT NULL,
PRIMARY KEY (thing_id, "Date_and_Time", "Location_Code"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id)
)
/*
2 rows from Timed_Locations_of_Things table:
thing_id Date_and_Time Location_Code
2 2016-10-12 12:03:07 064 Charles Mou
10 2016-12-29 00:39:19 288 Lang Ferry
*/
CREATE TABLE "Timed_Status_of_Things" (
thing_id INTEGER NOT NULL,
"Date_and_Date" DATETIME NOT NULL,
"Status_of_Thing_Code" CHAR(15) NOT NULL,
PRIMARY KEY (thing_id, "Date_and_Date", "Status_of_Thing_Code"),
FOREIGN KEY(thing_id) REFERENCES "Things" (thing_id)
)
/*
2 rows from Timed_Status_of_Things table:
thing_id Date_and_Date Status_of_Thing_Code
2 2016-05-27 23:33:34 Open
2 2016-07-17 08:35:27 Close
*/ | How many services has each resident requested? List the resident id, details, and the count in descending order of the count. | SELECT T1.resident_id , T1.other_details , count(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id = T2.resident_id GROUP BY T1.resident_id ORDER BY count(*) DESC | [{'resident_id': 6, 'other_details': 'Anderson Batz', 'count(*)': 1}, {'resident_id': 23, 'other_details': 'Jess Wyman', 'count(*)': 1}, {'resident_id': 28, 'other_details': 'Miss Alanis Lockman', 'count(*)': 1}, {'resident_id': 43, 'other_details': 'Elroy Schuster', 'count(*)': 1}, {'resident_id': 45, 'other_details': 'Prof. Nasir Hoppe', 'count(*)': 1}, {'resident_id': 47, 'other_details': 'Tiffany Jaskolski', 'count(*)': 1}, {'resident_id': 67, 'other_details': 'Terrill Bernhard', 'count(*)': 1}, {'resident_id': 83, 'other_details': 'Loy Walter', 'count(*)': 1}, {'resident_id': 87, 'other_details': 'Mrs. Raphaelle Fisher', 'count(*)': 1}, {'resident_id': 88, 'other_details': 'Jacques Glover II', 'count(*)': 1}, {'resident_id': 90, 'other_details': 'Cassie Johnson', 'count(*)': 1}] | Medium | false | false | false | true | false | true | false | true | false | false | false | false | false | ||||
decoration_competition |
CREATE TABLE college (
"College_ID" INTEGER,
"Name" TEXT,
"Leader_Name" TEXT,
"College_Location" TEXT,
PRIMARY KEY ("College_ID")
)
CREATE TABLE member (
"Member_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"College_ID" INTEGER,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY("College_ID") REFERENCES college ("College_ID")
)
CREATE TABLE round (
"Round_ID" INTEGER,
"Member_ID" INTEGER,
"Decoration_Theme" TEXT,
"Rank_in_Round" INTEGER,
PRIMARY KEY ("Member_ID", "Round_ID"),
FOREIGN KEY("Member_ID") REFERENCES member ("Member_ID")
) |
CREATE TABLE college (
"College_ID" INTEGER,
"Name" TEXT,
"Leader_Name" TEXT,
"College_Location" TEXT,
PRIMARY KEY ("College_ID")
)
/*
2 rows from college table:
College_ID Name Leader_Name College_Location
1 Saskatchewan School Ousame Tounkara Ottawa
2 B.C. School Ryan Thelwell Minnesota
*/
CREATE TABLE member (
"Member_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"College_ID" INTEGER,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY("College_ID") REFERENCES college ("College_ID")
)
/*
2 rows from member table:
Member_ID Name Country College_ID
1 Jack Nicklaus United States 1
2 Billy Casper United States 1
*/
CREATE TABLE round (
"Round_ID" INTEGER,
"Member_ID" INTEGER,
"Decoration_Theme" TEXT,
"Rank_in_Round" INTEGER,
PRIMARY KEY ("Member_ID", "Round_ID"),
FOREIGN KEY("Member_ID") REFERENCES member ("Member_ID")
)
/*
2 rows from round table:
Round_ID Member_ID Decoration_Theme Rank_in_Round
1 1 Walk on the Moon 1
1 2 Soft Dream 2
*/ | List the names of members in ascending alphabetical order. | SELECT Name FROM member ORDER BY Name ASC | [{'Name': 'Arnold Palmer'}, {'Name': 'Billy Casper'}, {'Name': 'Bobby Nichols'}, {'Name': 'Homero Blancas'}, {'Name': 'J. C. Snead'}, {'Name': 'Jack Nicklaus'}, {'Name': 'Lee Trevino'}, {'Name': 'Pat Fitzsimons'}, {'Name': 'Tom Watson'}, {'Name': 'Tom Weiskopf'}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]List the names and birth dates of people in ascending alphabetical order of name.[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]List the names and birth dates of people in ascending alphabetical order of name.[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]List the names and birth dates of people in ascending alphabetical order of name.[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] | [QUESTION]List the names and birth dates of people in ascending alphabetical order of name.[/QUESTION]
[SQL]SELECT Name , Birth_Date FROM people ORDER BY Name ASC[/SQL] |
roller_coaster |
CREATE TABLE country (
"Country_ID" INTEGER,
"Name" TEXT,
"Population" INTEGER,
"Area" INTEGER,
"Languages" TEXT,
PRIMARY KEY ("Country_ID")
)
CREATE TABLE roller_coaster (
"Roller_Coaster_ID" INTEGER,
"Name" TEXT,
"Park" TEXT,
"Country_ID" INTEGER,
"Length" REAL,
"Height" REAL,
"Speed" TEXT,
"Opened" TEXT,
"Status" TEXT,
PRIMARY KEY ("Roller_Coaster_ID"),
FOREIGN KEY("Country_ID") REFERENCES country ("Country_ID")
) |
CREATE TABLE country (
"Country_ID" INTEGER,
"Name" TEXT,
"Population" INTEGER,
"Area" INTEGER,
"Languages" TEXT,
PRIMARY KEY ("Country_ID")
)
/*
2 rows from country table:
Country_ID Name Population Area Languages
1 Austria 8206524 83871 German
2 Finland 5261008 338145 Finnish Swedish
*/
CREATE TABLE roller_coaster (
"Roller_Coaster_ID" INTEGER,
"Name" TEXT,
"Park" TEXT,
"Country_ID" INTEGER,
"Length" REAL,
"Height" REAL,
"Speed" TEXT,
"Opened" TEXT,
"Status" TEXT,
PRIMARY KEY ("Roller_Coaster_ID"),
FOREIGN KEY("Country_ID") REFERENCES country ("Country_ID")
)
/*
2 rows from roller_coaster table:
Roller_Coaster_ID Name Park Country_ID Length Height Speed Opened Status
1 Boardwalk Bullet Kemah Boardwalk 1 3236.0 96.0 51 August 31, 2007 Operating
2 Dauling Dragon Happy Valley 1 3914.0 105.0 55 2012 Operating
*/ | What is the average speed of roller coasters? | SELECT avg(Speed) FROM roller_coaster | [{'avg(Speed)': 56.31666666666666}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
college_2 |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
) |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
/*
2 rows from advisor table:
s_ID i_ID
24746 19368
79352 95030
*/
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
/*
2 rows from classroom table:
building room_number capacity
Lamberton 134 10
Chandler 375 10
*/
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
/*
2 rows from course table:
course_id title dept_name credits
787 C Programming Mech. Eng. 4
238 The Music of Donovan Mech. Eng. 3
*/
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
/*
2 rows from department table:
dept_name building budget
Civil Eng. Chandler 255041.46
Biology Candlestick 647610.55
*/
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
/*
2 rows from instructor table:
ID name dept_name salary
63395 McKinnon Cybernetics 94333.99
78699 Pingr Statistics 59303.62
*/
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
/*
2 rows from prereq table:
course_id prereq_id
376 130
760 169
*/
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
/*
2 rows from section table:
course_id sec_id semester year building room_number time_slot_id
313 1 Fall 2010 Chandler 804 N
747 1 Spring 2004 Gates 314 K
*/
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
/*
2 rows from student table:
ID name dept_name tot_cred
24746 Schrefl History 4
79352 Rumat Finance 100
*/
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
/*
2 rows from takes table:
ID course_id sec_id semester year grade
65901 401 1 Fall 2003 C-
24932 802 1 Spring 2003 B-
*/
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
/*
2 rows from teaches table:
ID course_id sec_id semester year
34175 747 1 Spring 2004
3199 169 1 Spring 2007
*/
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
)
/*
2 rows from time_slot table:
time_slot_id day start_hr start_min end_hr end_min
A M 8.0000000000 0E-10 8.0000000000 50.0000000000
A W 8.0000000000 0E-10 8.0000000000 50.0000000000
*/ | Count the number of rooms that are not in the Lamberton building. | SELECT count(*) FROM classroom WHERE building != 'Lamberton' | [{'count(*)': 28}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Find the number of classes offered for all class rooms that held at least 2 classes.[/QUESTION]
[SQL]SELECT count(*) , class_room FROM CLASS GROUP BY class_room HAVING count(*) >= 2[/SQL] |
|||
manufactory_1 |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
) |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
/*
2 rows from Manufacturers table:
Code Name Headquarter Founder Revenue
1 Sony Tokyo Andy 120.0
2 Creative Labs Austin Owen 100.0
*/
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
)
/*
2 rows from Products table:
Code Name Price Manufacturer
1 Hard drive 240.0000000000 5
2 Memory 120.0000000000 6
*/ | Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first. | SELECT name , headquarter FROM manufacturers ORDER BY revenue DESC | [{'Name': 'Iomega', 'Headquarter': 'Beijing'}, {'Name': 'Fujitsu', 'Headquarter': 'Taiwan'}, {'Name': 'Sony', 'Headquarter': 'Tokyo'}, {'Name': 'Creative Labs', 'Headquarter': 'Austin'}, {'Name': 'Hewlett-Packard', 'Headquarter': 'Los Angeles'}, {'Name': 'Winchester', 'Headquarter': 'Paris'}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]Find the manager name and district of the shop whose number of products is the largest.[/QUESTION]
[SQL]SELECT manager_name , district FROM shop ORDER BY number_products DESC LIMIT 1[/SQL] | [QUESTION]Find the manager name and district of the shop whose number of products is the largest.[/QUESTION]
[SQL]SELECT manager_name , district FROM shop ORDER BY number_products DESC LIMIT 1[/SQL] | [QUESTION]Find the manager name and district of the shop whose number of products is the largest.[/QUESTION]
[SQL]SELECT manager_name , district FROM shop ORDER BY number_products DESC LIMIT 1[/SQL] | [QUESTION]Find the manager name and district of the shop whose number of products is the largest.[/QUESTION]
[SQL]SELECT manager_name , district FROM shop ORDER BY number_products DESC LIMIT 1[/SQL] |
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | who has the most publications in syntactic parsing ? | SELECT DISTINCT COUNT ( t4.paperid ) , t3.authorid FROM paperkeyphrase AS t1 JOIN keyphrase AS t2 ON t1.keyphraseid = t2.keyphraseid JOIN paper AS t4 ON t4.paperid = t1.paperid JOIN writes AS t3 ON t3.paperid = t4.paperid WHERE t2.keyphrasename = "syntactic parsing" GROUP BY t3.authorid ORDER BY COUNT ( t4.paperid ) DESC; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | true | false | true | false | false | true | false | false | false | false | ||||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | how many papers use ImageNet ? | SELECT DISTINCT COUNT ( DISTINCT t3.paperid ) FROM paperdataset AS t2 JOIN dataset AS t1 ON t2.datasetid = t1.datasetid JOIN paper AS t3 ON t3.paperid = t2.paperid WHERE t1.datasetname LIKE "ImageNet"; | [{'COUNT ( DISTINCT t3.paperid )': 0}] | Hard | true | true | false | false | false | false | false | false | true | false | false | false | false | ||||
program_share |
CREATE TABLE broadcast (
"Channel_ID" INTEGER,
"Program_ID" INTEGER,
"Time_of_day" TEXT,
PRIMARY KEY ("Channel_ID", "Program_ID"),
FOREIGN KEY("Program_ID") REFERENCES program ("Program_ID"),
FOREIGN KEY("Channel_ID") REFERENCES channel ("Channel_ID")
)
CREATE TABLE broadcast_share (
"Channel_ID" INTEGER,
"Program_ID" INTEGER,
"Date" TEXT,
"Share_in_percent" REAL,
PRIMARY KEY ("Channel_ID", "Program_ID"),
FOREIGN KEY("Program_ID") REFERENCES program ("Program_ID"),
FOREIGN KEY("Channel_ID") REFERENCES channel ("Channel_ID")
)
CREATE TABLE channel (
"Channel_ID" INTEGER,
"Name" TEXT,
"Owner" TEXT,
"Share_in_percent" REAL,
"Rating_in_percent" REAL,
PRIMARY KEY ("Channel_ID")
)
CREATE TABLE program (
"Program_ID" INTEGER,
"Name" TEXT,
"Origin" TEXT,
"Launch" REAL,
"Owner" TEXT,
PRIMARY KEY ("Program_ID")
) |
CREATE TABLE broadcast (
"Channel_ID" INTEGER,
"Program_ID" INTEGER,
"Time_of_day" TEXT,
PRIMARY KEY ("Channel_ID", "Program_ID"),
FOREIGN KEY("Program_ID") REFERENCES program ("Program_ID"),
FOREIGN KEY("Channel_ID") REFERENCES channel ("Channel_ID")
)
/*
2 rows from broadcast table:
Channel_ID Program_ID Time_of_day
1 1 Morning
2 1 Night
*/
CREATE TABLE broadcast_share (
"Channel_ID" INTEGER,
"Program_ID" INTEGER,
"Date" TEXT,
"Share_in_percent" REAL,
PRIMARY KEY ("Channel_ID", "Program_ID"),
FOREIGN KEY("Program_ID") REFERENCES program ("Program_ID"),
FOREIGN KEY("Channel_ID") REFERENCES channel ("Channel_ID")
)
/*
2 rows from broadcast_share table:
Channel_ID Program_ID Date Share_in_percent
1 1 01,May 3.1
2 1 02,May 1.8
*/
CREATE TABLE channel (
"Channel_ID" INTEGER,
"Name" TEXT,
"Owner" TEXT,
"Share_in_percent" REAL,
"Rating_in_percent" REAL,
PRIMARY KEY ("Channel_ID")
)
/*
2 rows from channel table:
Channel_ID Name Owner Share_in_percent Rating_in_percent
1 CCTV-1 CCTV 4.9 0.54
2 Hunan Satellite TV HBS 4.81 0.53
*/
CREATE TABLE program (
"Program_ID" INTEGER,
"Name" TEXT,
"Origin" TEXT,
"Launch" REAL,
"Owner" TEXT,
PRIMARY KEY ("Program_ID")
)
/*
2 rows from program table:
Program_ID Name Origin Launch Owner
1 Aniworld Hunan 2005.0 Hunan Broadcasting System (HBS)
2 Kaku Beijing 2004.0 Beijing Television (BTV)
*/ | find the names of programs whose origin is not in Beijing. | SELECT name FROM program WHERE origin != 'Beijing' | [{'Name': 'Aniworld'}, {'Name': 'Toonmax'}, {'Name': 'Jiajia'}, {'Name': 'Youman'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Return the different names of cities that are in Asia and for which Chinese is the official language.[/QUESTION]
[SQL]SELECT DISTINCT T3.Name FROM country AS T1 JOIN countrylanguage AS T2 ON T1.Code = T2.CountryCode JOIN city AS T3 ON T1.Code = T3.CountryCode WHERE T2.IsOfficial = 'T' AND T2.Language = 'Chinese' AND T1.Continent = "Asia"[/SQL] |
|||
music_4 |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
) |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
/*
2 rows from artist table:
Artist_ID Artist Age Famous_Title Famous_Release_date
1 Gorgoroth 34 Bergen 1996 November 2007
2 Ophiolatry 35 Transmutation January 21, 2008
*/
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
/*
2 rows from music_festival table:
ID Music_Festival Date_of_ceremony Category Volume Result
1 34th England Academy Prize 18 February 2011 Best Song 1 Nominated
2 34th Japan Academy Prize 18 February 2011 Best Lyrics 2 Nominated
*/
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
)
/*
2 rows from volume table:
Volume_ID Volume_Issue Issue_Date Weeks_on_Top Song Artist_ID
1 45:14 § 27 December 1986 - 10 January 3.0 The Way 1
2 45:15 17 January 1.0 Everybody Have Fun Tonight 2
*/ | Return the issue dates of volumes that are by the artist named Gorgoroth. | SELECT T2.Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.Artist = "Gorgoroth" | [{'Issue_Date': '27 December 1986 - 10 January'}, {'Issue_Date': '24 January'}, {'Issue_Date': '9 May'}, {'Issue_Date': '16 May - 30 May'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
formula_1 |
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER,
"raceId" INTEGER,
"constructorId" INTEGER,
points REAL,
status TEXT,
PRIMARY KEY ("constructorResultsId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId")
)
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER,
"raceId" INTEGER,
"constructorId" INTEGER,
points REAL,
position INTEGER,
"positionText" TEXT,
wins INTEGER,
PRIMARY KEY ("constructorStandingsId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId")
)
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
points REAL,
position INTEGER,
"positionText" TEXT,
wins INTEGER,
PRIMARY KEY ("driverStandingsId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
lap INTEGER,
position INTEGER,
time TEXT,
milliseconds INTEGER,
PRIMARY KEY ("raceId", "driverId", lap),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
stop INTEGER,
lap INTEGER,
time TEXT,
duration TEXT,
milliseconds INTEGER,
PRIMARY KEY ("raceId", "driverId", stop),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
CREATE TABLE circuits (
"circuitId" INTEGER,
"circuitRef" TEXT,
name TEXT,
location TEXT,
country TEXT,
lat REAL,
lng REAL,
alt TEXT,
url TEXT,
PRIMARY KEY ("circuitId")
)
CREATE TABLE constructors (
"constructorId" INTEGER,
"constructorRef" TEXT,
name TEXT,
nationality TEXT,
url TEXT,
PRIMARY KEY ("constructorId")
)
CREATE TABLE drivers (
"driverId" INTEGER,
"driverRef" TEXT,
number TEXT,
code TEXT,
forename TEXT,
surname TEXT,
dob TEXT,
nationality TEXT,
url TEXT,
PRIMARY KEY ("driverId")
)
CREATE TABLE qualifying (
"qualifyId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
number INTEGER,
position INTEGER,
q1 TEXT,
q2 TEXT,
q3 TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
CREATE TABLE races (
"raceId" INTEGER,
year INTEGER,
round INTEGER,
"circuitId" INTEGER,
name TEXT,
date TEXT,
time TEXT,
url TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY("circuitId") REFERENCES circuits ("circuitId")
)
CREATE TABLE results (
"resultId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
number INTEGER,
grid INTEGER,
position TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
points REAL,
laps TEXT,
time TEXT,
milliseconds TEXT,
"fastestLap" TEXT,
rank TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
PRIMARY KEY ("resultId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
CREATE TABLE seasons (
year INTEGER,
url TEXT,
PRIMARY KEY (year)
)
CREATE TABLE status (
"statusId" INTEGER,
status TEXT,
PRIMARY KEY ("statusId")
) |
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER,
"raceId" INTEGER,
"constructorId" INTEGER,
points REAL,
status TEXT,
PRIMARY KEY ("constructorResultsId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId")
)
/*
2 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
*/
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER,
"raceId" INTEGER,
"constructorId" INTEGER,
points REAL,
position INTEGER,
"positionText" TEXT,
wins INTEGER,
PRIMARY KEY ("constructorStandingsId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId")
)
/*
2 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
*/
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
points REAL,
position INTEGER,
"positionText" TEXT,
wins INTEGER,
PRIMARY KEY ("driverStandingsId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
/*
2 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
*/
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
lap INTEGER,
position INTEGER,
time TEXT,
milliseconds INTEGER,
PRIMARY KEY ("raceId", "driverId", lap),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
/*
2 rows from lapTimes table:
raceId driverId lap position time milliseconds
*/
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
stop INTEGER,
lap INTEGER,
time TEXT,
duration TEXT,
milliseconds INTEGER,
PRIMARY KEY ("raceId", "driverId", stop),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
/*
2 rows from pitStops table:
raceId driverId stop lap time duration milliseconds
*/
CREATE TABLE circuits (
"circuitId" INTEGER,
"circuitRef" TEXT,
name TEXT,
location TEXT,
country TEXT,
lat REAL,
lng REAL,
alt TEXT,
url TEXT,
PRIMARY KEY ("circuitId")
)
/*
2 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.8497 144.968 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.738 http://en.wikipedia.org/wiki/Sepang_International_Circuit
*/
CREATE TABLE constructors (
"constructorId" INTEGER,
"constructorRef" TEXT,
name TEXT,
nationality TEXT,
url TEXT,
PRIMARY KEY ("constructorId")
)
/*
2 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
*/
CREATE TABLE drivers (
"driverId" INTEGER,
"driverRef" TEXT,
number TEXT,
code TEXT,
forename TEXT,
surname TEXT,
dob TEXT,
nationality TEXT,
url TEXT,
PRIMARY KEY ("driverId")
)
/*
2 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
*/
CREATE TABLE qualifying (
"qualifyId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
number INTEGER,
position INTEGER,
q1 TEXT,
q2 TEXT,
q3 TEXT,
PRIMARY KEY ("qualifyId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
/*
2 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
*/
CREATE TABLE races (
"raceId" INTEGER,
year INTEGER,
round INTEGER,
"circuitId" INTEGER,
name TEXT,
date TEXT,
time TEXT,
url TEXT,
PRIMARY KEY ("raceId"),
FOREIGN KEY("circuitId") REFERENCES circuits ("circuitId")
)
/*
2 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
*/
CREATE TABLE results (
"resultId" INTEGER,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
number INTEGER,
grid INTEGER,
position TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
points REAL,
laps TEXT,
time TEXT,
milliseconds TEXT,
"fastestLap" TEXT,
rank TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
PRIMARY KEY ("resultId"),
FOREIGN KEY("constructorId") REFERENCES constructors ("constructorId"),
FOREIGN KEY("raceId") REFERENCES races ("raceId"),
FOREIGN KEY("driverId") REFERENCES drivers ("driverId")
)
/*
2 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
*/
CREATE TABLE seasons (
year INTEGER,
url TEXT,
PRIMARY KEY (year)
)
/*
2 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
*/
CREATE TABLE status (
"statusId" INTEGER,
status TEXT,
PRIMARY KEY ("statusId")
)
/*
2 rows from status table:
statusId status
1 Finished
2 Disqualified
*/ | What are the ids and locations of all circuits in France or Belgium? | SELECT circuitid , LOCATION FROM circuits WHERE country = "France" OR country = "Belgium" | [{'circuitId': 8, 'location': 'Magny Cours'}, {'circuitId': 13, 'location': 'Spa'}, {'circuitId': 34, 'location': 'Le Castellet'}, {'circuitId': 40, 'location': 'Heusden-Zolder'}, {'circuitId': 41, 'location': 'Dijon'}, {'circuitId': 50, 'location': 'Brussels'}, {'circuitId': 51, 'location': 'Clermont-Ferrand'}, {'circuitId': 53, 'location': 'Rouen'}, {'circuitId': 54, 'location': 'Le Mans'}, {'circuitId': 55, 'location': 'Reims'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
gymnast |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
/*
2 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.75 58.061
2 9.7 9.625 9.625 9.65 9.587 9.737 57.924
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
*/ | Return the age of the person with the greatest height. | SELECT Age FROM people ORDER BY Height DESC LIMIT 1 | [{'Age': 23.0}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | [QUESTION]Return the money rank of the poker player with the greatest height.[/QUESTION]
[SQL]SELECT T2.Money_Rank FROM people AS T1 JOIN poker_player AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1[/SQL] | [QUESTION]Return the money rank of the poker player with the greatest height.[/QUESTION]
[SQL]SELECT T2.Money_Rank FROM people AS T1 JOIN poker_player AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1[/SQL] | [QUESTION]Return the money rank of the poker player with the greatest height.[/QUESTION]
[SQL]SELECT T2.Money_Rank FROM people AS T1 JOIN poker_player AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1[/SQL] | [QUESTION]Return the money rank of the poker player with the greatest height.[/QUESTION]
[SQL]SELECT T2.Money_Rank FROM people AS T1 JOIN poker_player AS T2 ON T1.People_ID = T2.People_ID ORDER BY T1.Height DESC LIMIT 1[/SQL] |
sakila_1 |
CREATE TABLE actor (
actor_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (actor_id)
)
CREATE TABLE address (
address_id INTEGER NOT NULL,
address VARCHAR(50) NOT NULL,
address2 VARCHAR(50) DEFAULT NULL,
district VARCHAR(20) NOT NULL,
city_id INTEGER NOT NULL,
postal_code VARCHAR(10) DEFAULT NULL,
phone VARCHAR(20) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (address_id),
FOREIGN KEY(city_id) REFERENCES city (city_id)
)
CREATE TABLE category (
category_id INTEGER NOT NULL,
name VARCHAR(25) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (category_id)
)
CREATE TABLE city (
city_id INTEGER NOT NULL,
city VARCHAR(50) NOT NULL,
country_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (city_id),
FOREIGN KEY(country_id) REFERENCES country (country_id)
)
CREATE TABLE country (
country_id INTEGER NOT NULL,
country VARCHAR(50) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (country_id)
)
CREATE TABLE customer (
customer_id INTEGER NOT NULL,
store_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
email VARCHAR(50) DEFAULT NULL,
address_id INTEGER NOT NULL,
active BOOLEAN DEFAULT TRUE NOT NULL,
create_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (customer_id),
FOREIGN KEY(address_id) REFERENCES address (address_id),
FOREIGN KEY(store_id) REFERENCES store (store_id)
)
CREATE TABLE film (
film_id INTEGER NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
release_year NUMERIC DEFAULT NULL,
language_id INTEGER NOT NULL,
original_language_id INTEGER DEFAULT NULL,
rental_duration INTEGER DEFAULT 3 NOT NULL,
rental_rate DECIMAL(4, 2) DEFAULT 4.99 NOT NULL,
length INTEGER DEFAULT NULL,
replacement_cost DECIMAL(5, 2) DEFAULT 19.99 NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (film_id),
FOREIGN KEY(language_id) REFERENCES language (language_id),
FOREIGN KEY(original_language_id) REFERENCES language (language_id)
)
CREATE TABLE film_actor (
actor_id INTEGER NOT NULL,
film_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (actor_id, film_id),
FOREIGN KEY(actor_id) REFERENCES actor (actor_id),
FOREIGN KEY(film_id) REFERENCES film (film_id)
)
CREATE TABLE film_category (
film_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (film_id, category_id),
FOREIGN KEY(film_id) REFERENCES film (film_id),
FOREIGN KEY(category_id) REFERENCES category (category_id)
)
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id)
)
CREATE TABLE inventory (
inventory_id INTEGER NOT NULL,
film_id INTEGER NOT NULL,
store_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (inventory_id),
FOREIGN KEY(store_id) REFERENCES store (store_id),
FOREIGN KEY(film_id) REFERENCES film (film_id)
)
CREATE TABLE language (
language_id INTEGER NOT NULL,
name CHAR(20) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (language_id)
)
CREATE TABLE payment (
payment_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
staff_id INTEGER NOT NULL,
rental_id INTEGER DEFAULT NULL,
amount DECIMAL(5, 2) NOT NULL,
payment_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (payment_id),
FOREIGN KEY(rental_id) REFERENCES rental (rental_id),
FOREIGN KEY(customer_id) REFERENCES customer (customer_id),
FOREIGN KEY(staff_id) REFERENCES staff (staff_id)
)
CREATE TABLE rental (
rental_id INTEGER NOT NULL,
rental_date DATETIME NOT NULL,
inventory_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
return_date DATETIME DEFAULT NULL,
staff_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (rental_id),
FOREIGN KEY(staff_id) REFERENCES staff (staff_id),
FOREIGN KEY(inventory_id) REFERENCES inventory (inventory_id),
FOREIGN KEY(customer_id) REFERENCES customer (customer_id)
)
CREATE TABLE staff (
staff_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
address_id INTEGER NOT NULL,
picture BLOB DEFAULT NULL,
email VARCHAR(50) DEFAULT NULL,
store_id INTEGER NOT NULL,
active BOOLEAN DEFAULT TRUE NOT NULL,
username VARCHAR(16) NOT NULL,
password VARCHAR(40) DEFAULT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (staff_id),
FOREIGN KEY(address_id) REFERENCES address (address_id)
)
CREATE TABLE store (
store_id INTEGER NOT NULL,
manager_staff_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (store_id),
FOREIGN KEY(manager_staff_id) REFERENCES staff (staff_id),
FOREIGN KEY(address_id) REFERENCES address (address_id)
) |
CREATE TABLE actor (
actor_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (actor_id)
)
/*
2 rows from actor table:
actor_id first_name last_name last_update
1 PENELOPE GUINESS 2006-02-15 04:34:33
2 NICK WAHLBERG 2006-02-15 04:34:33
*/
CREATE TABLE address (
address_id INTEGER NOT NULL,
address VARCHAR(50) NOT NULL,
address2 VARCHAR(50) DEFAULT NULL,
district VARCHAR(20) NOT NULL,
city_id INTEGER NOT NULL,
postal_code VARCHAR(10) DEFAULT NULL,
phone VARCHAR(20) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (address_id),
FOREIGN KEY(city_id) REFERENCES city (city_id)
)
/*
2 rows from address table:
address_id address address2 district city_id postal_code phone last_update
1 47 MySakila Drive None Alberta 300 2006-02-15 04:45:30
2 28 MySQL Boulevard None QLD 576 2006-02-15 04:45:30
*/
CREATE TABLE category (
category_id INTEGER NOT NULL,
name VARCHAR(25) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (category_id)
)
/*
2 rows from category table:
category_id name last_update
1 Action 2006-02-15 04:46:27
2 Animation 2006-02-15 04:46:27
*/
CREATE TABLE city (
city_id INTEGER NOT NULL,
city VARCHAR(50) NOT NULL,
country_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (city_id),
FOREIGN KEY(country_id) REFERENCES country (country_id)
)
/*
2 rows from city table:
city_id city country_id last_update
1 A Corua (La Corua) 87 2006-02-15 04:45:25
2 Abha 82 2006-02-15 04:45:25
*/
CREATE TABLE country (
country_id INTEGER NOT NULL,
country VARCHAR(50) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (country_id)
)
/*
2 rows from country table:
country_id country last_update
1 Afghanistan 2006-02-15 04:44:00
2 Algeria 2006-02-15 04:44:00
*/
CREATE TABLE customer (
customer_id INTEGER NOT NULL,
store_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
email VARCHAR(50) DEFAULT NULL,
address_id INTEGER NOT NULL,
active BOOLEAN DEFAULT TRUE NOT NULL,
create_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (customer_id),
FOREIGN KEY(address_id) REFERENCES address (address_id),
FOREIGN KEY(store_id) REFERENCES store (store_id)
)
/*
2 rows from customer table:
customer_id store_id first_name last_name email address_id active create_date last_update
1 1 MARY SMITH [email protected] 5 True 2006-02-14 22:04:36 2006-02-15 04:57:20
2 1 PATRICIA JOHNSON [email protected] 6 True 2006-02-14 22:04:36 2006-02-15 04:57:20
*/
CREATE TABLE film (
film_id INTEGER NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
release_year NUMERIC DEFAULT NULL,
language_id INTEGER NOT NULL,
original_language_id INTEGER DEFAULT NULL,
rental_duration INTEGER DEFAULT 3 NOT NULL,
rental_rate DECIMAL(4, 2) DEFAULT 4.99 NOT NULL,
length INTEGER DEFAULT NULL,
replacement_cost DECIMAL(5, 2) DEFAULT 19.99 NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (film_id),
FOREIGN KEY(language_id) REFERENCES language (language_id),
FOREIGN KEY(original_language_id) REFERENCES language (language_id)
)
/*
2 rows from film table:
film_id title description release_year language_id original_language_id rental_duration rental_rate length replacement_cost last_update
1 ACADEMY DINOSAUR A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies 2006.0000000000 1 None 6 0.99 86 20.99 2006-02-15 05:03:42
2 ACE GOLDFINGER A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China 2006.0000000000 1 None 3 4.99 48 12.99 2006-02-15 05:03:42
*/
CREATE TABLE film_actor (
actor_id INTEGER NOT NULL,
film_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (actor_id, film_id),
FOREIGN KEY(actor_id) REFERENCES actor (actor_id),
FOREIGN KEY(film_id) REFERENCES film (film_id)
)
/*
2 rows from film_actor table:
actor_id film_id last_update
1 1 2006-02-15 05:05:03
1 23 2006-02-15 05:05:03
*/
CREATE TABLE film_category (
film_id INTEGER NOT NULL,
category_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (film_id, category_id),
FOREIGN KEY(film_id) REFERENCES film (film_id),
FOREIGN KEY(category_id) REFERENCES category (category_id)
)
/*
2 rows from film_category table:
film_id category_id last_update
1 6 2006-02-15 05:07:09
2 11 2006-02-15 05:07:09
*/
CREATE TABLE film_text (
film_id SMALLINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
PRIMARY KEY (film_id)
)
/*
2 rows from film_text table:
film_id title description
*/
CREATE TABLE inventory (
inventory_id INTEGER NOT NULL,
film_id INTEGER NOT NULL,
store_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (inventory_id),
FOREIGN KEY(store_id) REFERENCES store (store_id),
FOREIGN KEY(film_id) REFERENCES film (film_id)
)
/*
2 rows from inventory table:
inventory_id film_id store_id last_update
1 1 1 2006-02-15 05:09:17
2 1 1 2006-02-15 05:09:17
*/
CREATE TABLE language (
language_id INTEGER NOT NULL,
name CHAR(20) NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (language_id)
)
/*
2 rows from language table:
language_id name last_update
*/
CREATE TABLE payment (
payment_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
staff_id INTEGER NOT NULL,
rental_id INTEGER DEFAULT NULL,
amount DECIMAL(5, 2) NOT NULL,
payment_date DATETIME NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (payment_id),
FOREIGN KEY(rental_id) REFERENCES rental (rental_id),
FOREIGN KEY(customer_id) REFERENCES customer (customer_id),
FOREIGN KEY(staff_id) REFERENCES staff (staff_id)
)
/*
2 rows from payment table:
payment_id customer_id staff_id rental_id amount payment_date last_update
1 1 1 76 2.99 2005-05-25 11:30:37 2006-02-15 22:12:30
2 1 1 573 0.99 2005-05-28 10:35:23 2006-02-15 22:12:30
*/
CREATE TABLE rental (
rental_id INTEGER NOT NULL,
rental_date DATETIME NOT NULL,
inventory_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
return_date DATETIME DEFAULT NULL,
staff_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (rental_id),
FOREIGN KEY(staff_id) REFERENCES staff (staff_id),
FOREIGN KEY(inventory_id) REFERENCES inventory (inventory_id),
FOREIGN KEY(customer_id) REFERENCES customer (customer_id)
)
/*
2 rows from rental table:
rental_id rental_date inventory_id customer_id return_date staff_id last_update
1 2005-05-24 22:53:30 367 130 2005-05-26 22:04:30 1 2006-02-15 21:30:53
2 2005-05-24 22:54:33 1525 459 2005-05-28 19:40:33 1 2006-02-15 21:30:53
*/
CREATE TABLE staff (
staff_id INTEGER NOT NULL,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
address_id INTEGER NOT NULL,
picture BLOB DEFAULT NULL,
email VARCHAR(50) DEFAULT NULL,
store_id INTEGER NOT NULL,
active BOOLEAN DEFAULT TRUE NOT NULL,
username VARCHAR(16) NOT NULL,
password VARCHAR(40) DEFAULT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (staff_id),
FOREIGN KEY(address_id) REFERENCES address (address_id)
)
/*
2 rows from staff table:
staff_id first_name last_name address_id picture email store_id active username password last_update
*/
CREATE TABLE store (
store_id INTEGER NOT NULL,
manager_staff_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
last_update TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY (store_id),
FOREIGN KEY(manager_staff_id) REFERENCES staff (staff_id),
FOREIGN KEY(address_id) REFERENCES address (address_id)
)
/*
2 rows from store table:
store_id manager_staff_id address_id last_update
*/ | How many kinds of different ratings are listed? | SELECT count(DISTINCT rating) FROM film | [{'count(DISTINCT rating)': 5}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of all genres in alphabetical order, combined with its ratings?[/QUESTION]
[SQL]SELECT g_name , rating FROM genre ORDER BY g_name[/SQL] | [QUESTION]What are the names of all genres in alphabetical order, combined with its ratings?[/QUESTION]
[SQL]SELECT g_name , rating FROM genre ORDER BY g_name[/SQL] | [QUESTION]What are the names of all genres in alphabetical order, combined with its ratings?[/QUESTION]
[SQL]SELECT g_name , rating FROM genre ORDER BY g_name[/SQL] | [QUESTION]What are the names of all genres in alphabetical order, combined with its ratings?[/QUESTION]
[SQL]SELECT g_name , rating FROM genre ORDER BY g_name[/SQL] |
e_learning |
CREATE TABLE "Course_Authors_and_Tutors" (
author_id INTEGER,
"author_tutor_ATB" VARCHAR(3),
login_name VARCHAR(40),
password VARCHAR(40),
personal_name VARCHAR(80),
middle_name VARCHAR(80),
family_name VARCHAR(80),
gender_mf VARCHAR(1),
address_line_1 VARCHAR(80),
PRIMARY KEY (author_id)
)
CREATE TABLE "Courses" (
course_id INTEGER,
author_id INTEGER NOT NULL,
subject_id INTEGER NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
PRIMARY KEY (course_id),
FOREIGN KEY(subject_id) REFERENCES "Subjects" (subject_id),
FOREIGN KEY(author_id) REFERENCES "Course_Authors_and_Tutors" (author_id)
)
CREATE TABLE "Student_Course_Enrolment" (
registration_id INTEGER,
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_enrolment DATETIME NOT NULL,
date_of_completion DATETIME NOT NULL,
PRIMARY KEY (registration_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
CREATE TABLE "Student_Tests_Taken" (
registration_id INTEGER NOT NULL,
date_test_taken DATETIME NOT NULL,
test_result VARCHAR(255),
FOREIGN KEY(registration_id) REFERENCES "Student_Course_Enrolment" (registration_id)
)
CREATE TABLE "Students" (
student_id INTEGER,
date_of_registration DATETIME,
date_of_latest_logon DATETIME,
login_name VARCHAR(40),
password VARCHAR(10),
personal_name VARCHAR(40),
middle_name VARCHAR(40),
family_name VARCHAR(40),
PRIMARY KEY (student_id)
)
CREATE TABLE "Subjects" (
subject_id INTEGER,
subject_name VARCHAR(120),
PRIMARY KEY (subject_id)
) |
CREATE TABLE "Course_Authors_and_Tutors" (
author_id INTEGER,
"author_tutor_ATB" VARCHAR(3),
login_name VARCHAR(40),
password VARCHAR(40),
personal_name VARCHAR(80),
middle_name VARCHAR(80),
family_name VARCHAR(80),
gender_mf VARCHAR(1),
address_line_1 VARCHAR(80),
PRIMARY KEY (author_id)
)
/*
2 rows from Course_Authors_and_Tutors table:
author_id author_tutor_ATB login_name password personal_name middle_name family_name gender_mf address_line_1
1 331 jmckenzie c40fa148bdd0d2d45cd6e9ec1e685750fe07f81b Cathrine Ruthie Grant 0 756 Monahan Mews
Spinkashire, NJ 64230-5098
2 975 heidenreich.ara 24b0ee84063c3b017ab1839e01b7280f47f7c7c2 Retha Corene Armstrong 0 98623 Huels Manor
Jasttown, DE 31611
*/
CREATE TABLE "Courses" (
course_id INTEGER,
author_id INTEGER NOT NULL,
subject_id INTEGER NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
PRIMARY KEY (course_id),
FOREIGN KEY(subject_id) REFERENCES "Subjects" (subject_id),
FOREIGN KEY(author_id) REFERENCES "Course_Authors_and_Tutors" (author_id)
)
/*
2 rows from Courses table:
course_id author_id subject_id course_name course_description
1 8 1 database database
2 6 1 advanced database advanced database
*/
CREATE TABLE "Student_Course_Enrolment" (
registration_id INTEGER,
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_enrolment DATETIME NOT NULL,
date_of_completion DATETIME NOT NULL,
PRIMARY KEY (registration_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
/*
2 rows from Student_Course_Enrolment table:
registration_id student_id course_id date_of_enrolment date_of_completion
1 11 2 2017-10-09 07:09:02 2018-02-26 07:48:52
2 15 4 2017-11-13 12:49:33 2018-03-04 01:24:56
*/
CREATE TABLE "Student_Tests_Taken" (
registration_id INTEGER NOT NULL,
date_test_taken DATETIME NOT NULL,
test_result VARCHAR(255),
FOREIGN KEY(registration_id) REFERENCES "Student_Course_Enrolment" (registration_id)
)
/*
2 rows from Student_Tests_Taken table:
registration_id date_test_taken test_result
12 2018-03-25 03:27:16 Fail
10 2018-03-25 21:50:22 Pass
*/
CREATE TABLE "Students" (
student_id INTEGER,
date_of_registration DATETIME,
date_of_latest_logon DATETIME,
login_name VARCHAR(40),
password VARCHAR(10),
personal_name VARCHAR(40),
middle_name VARCHAR(40),
family_name VARCHAR(40),
PRIMARY KEY (student_id)
)
/*
2 rows from Students table:
student_id date_of_registration date_of_latest_logon login_name password personal_name middle_name family_name
1 2015-07-22 13:32:35 2017-10-17 22:52:26 annamae.hoppe db8765bb6f Wilson Aubrey Ward
2 2015-07-02 00:21:42 2017-06-24 22:16:27 wmiller 35faf8182a Karson Luella Jaskolski
*/
CREATE TABLE "Subjects" (
subject_id INTEGER,
subject_name VARCHAR(120),
PRIMARY KEY (subject_id)
)
/*
2 rows from Subjects table:
subject_id subject_name
1 Computer Science
2 Arts
*/ | What are the descriptions and names of the courses that have student enrollment bigger than 2? | SELECT T1.course_description , T1.course_name FROM Courses AS T1 JOIN Student_Course_Enrolment AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name HAVING COUNT(*) > 2 | [{'course_description': 'French', 'course_name': 'French'}] | Medium | false | false | false | false | false | true | true | true | false | false | false | false | false | [QUESTION]What's the name of the course with most number of enrollments?[/QUESTION]
[SQL]SELECT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What's the name of the course with most number of enrollments?[/QUESTION]
[SQL]SELECT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What's the name of the course with most number of enrollments?[/QUESTION]
[SQL]SELECT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What's the name of the course with most number of enrollments?[/QUESTION]
[SQL]SELECT T1.course_name FROM Courses AS T1 JOIN Student_Enrolment_Courses AS T2 ON T1.course_id = T2.course_id GROUP BY T1.course_name ORDER BY count(*) DESC LIMIT 1[/SQL] |
election |
CREATE TABLE county (
"County_Id" INTEGER,
"County_name" TEXT,
"Population" REAL,
"Zip_code" TEXT,
PRIMARY KEY ("County_Id")
)
CREATE TABLE election (
"Election_ID" INTEGER,
"Counties_Represented" TEXT,
"District" INTEGER,
"Delegate" TEXT,
"Party" INTEGER,
"First_Elected" REAL,
"Committee" TEXT,
PRIMARY KEY ("Election_ID"),
FOREIGN KEY("District") REFERENCES county ("County_Id"),
FOREIGN KEY("Party") REFERENCES party ("Party_ID")
)
CREATE TABLE party (
"Party_ID" INTEGER,
"Year" REAL,
"Party" TEXT,
"Governor" TEXT,
"Lieutenant_Governor" TEXT,
"Comptroller" TEXT,
"Attorney_General" TEXT,
"US_Senate" TEXT,
PRIMARY KEY ("Party_ID")
) |
CREATE TABLE county (
"County_Id" INTEGER,
"County_name" TEXT,
"Population" REAL,
"Zip_code" TEXT,
PRIMARY KEY ("County_Id")
)
/*
2 rows from county table:
County_Id County_name Population Zip_code
1 Howard 21000.0 D21
2 Baltimore County 90000.0 D08
*/
CREATE TABLE election (
"Election_ID" INTEGER,
"Counties_Represented" TEXT,
"District" INTEGER,
"Delegate" TEXT,
"Party" INTEGER,
"First_Elected" REAL,
"Committee" TEXT,
PRIMARY KEY ("Election_ID"),
FOREIGN KEY("District") REFERENCES county ("County_Id"),
FOREIGN KEY("Party") REFERENCES party ("Party_ID")
)
/*
2 rows from election table:
Election_ID Counties_Represented District Delegate Party First_Elected Committee
1 09.1 9A 1 Bates, Gail H. Gail H. Bates 1 2002.0 Appropriations
2 09.1 9A 1 Miller, Warren E. Warren E. Miller 1 2003.0 Economic Matters
*/
CREATE TABLE party (
"Party_ID" INTEGER,
"Year" REAL,
"Party" TEXT,
"Governor" TEXT,
"Lieutenant_Governor" TEXT,
"Comptroller" TEXT,
"Attorney_General" TEXT,
"US_Senate" TEXT,
PRIMARY KEY ("Party_ID")
)
/*
2 rows from party table:
Party_ID Year Party Governor Lieutenant_Governor Comptroller Attorney_General US_Senate
1 1998.0 Democratic Peter Vallone Sandra Frankel Carl McCall Eliot Spitzer Charles Schumer
2 1998.0 Liberal Betsy McCaughey Ross Jonathan Reiter Carl McCall Eliot Spitzer Charles Schumer
*/ | What are the delegate and name of the county they belong to, for each county? | SELECT T2.Delegate , T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District | [{'Delegate': 'Bates, Gail H. Gail H. Bates', 'County_name': 'Howard'}, {'Delegate': 'Miller, Warren E. Warren E. Miller', 'County_name': 'Howard'}, {'Delegate': 'DeBoy, Steven J. Sr. Steven J. DeBoy, Sr.', 'County_name': 'Baltimore County'}, {'Delegate': 'Malone, James E. Jr. James E. Malone, Jr.', 'County_name': 'Colony'}, {'Delegate': 'Bobo, Elizabeth Elizabeth Bobo', 'County_name': 'Baltimore County'}, {'Delegate': 'Pendergrass, Shane E. Shane Pendergrass', 'County_name': 'Howard'}, {'Delegate': 'Guzzone, Guy Guy Guzzone', 'County_name': 'Mansfield'}, {'Delegate': 'Turner, Frank S. Frank S. Turner', 'County_name': 'Colony'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
customers_and_addresses |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_content VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
other_address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Customer_Contact_Channels" (
customer_id INTEGER NOT NULL,
channel_code VARCHAR(15) NOT NULL,
active_from_date DATETIME NOT NULL,
active_to_date DATETIME,
contact_number VARCHAR(50) NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status VARCHAR(15) NOT NULL,
order_date DATETIME,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
date_became_customer DATETIME,
other_customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Order_Items" (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
order_quantity VARCHAR(15),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
product_details VARCHAR(255),
PRIMARY KEY (product_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_content VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
other_address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id address_content city zip_postcode state_province_county country other_address_details
1 9443 Boyle Route Suite 857 Lucasville 416 Colorado USA None
2 1969 Jabari Port Suite 393 New Sabryna 721 SouthCarolina USA None
*/
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Customer_Addresses table:
customer_id address_id date_address_from address_type date_address_to
2 11 1985-03-29 20:31:43 Billing 1993-02-17 17:55:18
13 11 2010-08-25 04:24:35 Billing 1972-02-17 22:23:38
*/
CREATE TABLE "Customer_Contact_Channels" (
customer_id INTEGER NOT NULL,
channel_code VARCHAR(15) NOT NULL,
active_from_date DATETIME NOT NULL,
active_to_date DATETIME,
contact_number VARCHAR(50) NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Contact_Channels table:
customer_id channel_code active_from_date active_to_date contact_number
9 Email 2017-12-07 18:18:15 2018-03-23 13:37:14 940.035.6435x0225
2 Email 2017-04-07 04:51:41 2018-03-23 01:30:52 189.449.8326x7607
*/
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status VARCHAR(15) NOT NULL,
order_date DATETIME,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Orders table:
order_id customer_id order_status order_date order_details
1 15 Cancelled 2018-03-21 11:20:46 None
2 3 Cancelled 2018-03-05 06:35:33 None
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
date_became_customer DATETIME,
other_customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id payment_method customer_name date_became_customer other_customer_details
1 Cash Dr. Julia Wuckert MD 2018-03-01 23:20:10 None
2 Cheque Tillman Ernser 2018-02-28 11:37:44 None
*/
CREATE TABLE "Order_Items" (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
order_quantity VARCHAR(15),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
order_id product_id order_quantity
14 2 5
5 2 9
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_details VARCHAR(255),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_details
1 Americano
2 Dove Chocolate
*/ | Find the number of customers who live in the city called Lake Geovannyton. | SELECT count(*) FROM customers AS t1 JOIN customer_addresses AS t2 ON t1.customer_id = t2.customer_id JOIN addresses AS t3 ON t2.address_id = t3.address_id WHERE t3.city = "Lake Geovannyton" | [{'count(*)': 3}] | Hard | false | false | false | false | false | false | false | false | true | false | false | false | false | [QUESTION]Find the number of customers in the banks at New York City.[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'[/SQL] | [QUESTION]Find the number of customers in the banks at New York City.[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'[/SQL] | [QUESTION]Find the number of customers in the banks at New York City.[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'[/SQL] | [QUESTION]Find the number of customers in the banks at New York City.[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'[/SQL] |
college_2 |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
) |
CREATE TABLE advisor (
"s_ID" VARCHAR(5),
"i_ID" VARCHAR(5),
PRIMARY KEY ("s_ID"),
FOREIGN KEY("i_ID") REFERENCES instructor ("ID"),
FOREIGN KEY("s_ID") REFERENCES student ("ID")
)
/*
2 rows from advisor table:
s_ID i_ID
24746 19368
79352 95030
*/
CREATE TABLE classroom (
building VARCHAR(15),
room_number VARCHAR(7),
capacity NUMERIC(4, 0),
PRIMARY KEY (building, room_number)
)
/*
2 rows from classroom table:
building room_number capacity
Lamberton 134 10
Chandler 375 10
*/
CREATE TABLE course (
course_id VARCHAR(8),
title VARCHAR(50),
dept_name VARCHAR(20),
credits NUMERIC(2, 0),
PRIMARY KEY (course_id),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (credits > 0)
)
/*
2 rows from course table:
course_id title dept_name credits
787 C Programming Mech. Eng. 4
238 The Music of Donovan Mech. Eng. 3
*/
CREATE TABLE department (
dept_name VARCHAR(20),
building VARCHAR(15),
budget NUMERIC(12, 2),
PRIMARY KEY (dept_name),
CHECK (budget > 0)
)
/*
2 rows from department table:
dept_name building budget
Civil Eng. Chandler 255041.46
Biology Candlestick 647610.55
*/
CREATE TABLE instructor (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
salary NUMERIC(8, 2),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (salary > 29000)
)
/*
2 rows from instructor table:
ID name dept_name salary
63395 McKinnon Cybernetics 94333.99
78699 Pingr Statistics 59303.62
*/
CREATE TABLE prereq (
course_id VARCHAR(8),
prereq_id VARCHAR(8),
PRIMARY KEY (course_id, prereq_id),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(prereq_id) REFERENCES course (course_id)
)
/*
2 rows from prereq table:
course_id prereq_id
376 130
760 169
*/
CREATE TABLE section (
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
building VARCHAR(15),
room_number VARCHAR(7),
time_slot_id VARCHAR(4),
PRIMARY KEY (course_id, sec_id, semester, year),
FOREIGN KEY(course_id) REFERENCES course (course_id),
FOREIGN KEY(building, room_number) REFERENCES classroom (building, room_number),
CHECK (semester in ('Fall', 'Winter', 'Spring', 'Summer')),
CHECK (year > 1701 and year < 2100)
)
/*
2 rows from section table:
course_id sec_id semester year building room_number time_slot_id
313 1 Fall 2010 Chandler 804 N
747 1 Spring 2004 Gates 314 K
*/
CREATE TABLE student (
"ID" VARCHAR(5),
name VARCHAR(20) NOT NULL,
dept_name VARCHAR(20),
tot_cred NUMERIC(3, 0),
PRIMARY KEY ("ID"),
FOREIGN KEY(dept_name) REFERENCES department (dept_name),
CHECK (tot_cred >= 0)
)
/*
2 rows from student table:
ID name dept_name tot_cred
24746 Schrefl History 4
79352 Rumat Finance 100
*/
CREATE TABLE takes (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
grade VARCHAR(2),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES student ("ID")
)
/*
2 rows from takes table:
ID course_id sec_id semester year grade
65901 401 1 Fall 2003 C-
24932 802 1 Spring 2003 B-
*/
CREATE TABLE teaches (
"ID" VARCHAR(5),
course_id VARCHAR(8),
sec_id VARCHAR(8),
semester VARCHAR(6),
year NUMERIC(4, 0),
PRIMARY KEY ("ID", course_id, sec_id, semester, year),
FOREIGN KEY(course_id, sec_id, semester, year) REFERENCES section (course_id, sec_id, semester, year),
FOREIGN KEY("ID") REFERENCES instructor ("ID")
)
/*
2 rows from teaches table:
ID course_id sec_id semester year
34175 747 1 Spring 2004
3199 169 1 Spring 2007
*/
CREATE TABLE time_slot (
time_slot_id VARCHAR(4),
day VARCHAR(1),
start_hr NUMERIC(2),
start_min NUMERIC(2),
end_hr NUMERIC(2),
end_min NUMERIC(2),
PRIMARY KEY (time_slot_id, day, start_hr, start_min),
CHECK (start_hr >= 0 and start_hr < 24),
CHECK (start_min >= 0 and start_min < 60),
CHECK (end_hr >= 0 and end_hr < 24),
CHECK (end_min >= 0 and end_min < 60)
)
/*
2 rows from time_slot table:
time_slot_id day start_hr start_min end_hr end_min
A M 8.0000000000 0E-10 8.0000000000 50.0000000000
A W 8.0000000000 0E-10 8.0000000000 50.0000000000
*/ | Find the name of department has the highest amount of students? | SELECT dept_name FROM student GROUP BY dept_name ORDER BY count(*) DESC LIMIT 1 | [{'dept_name': 'Civil Eng.'}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | [QUESTION]Find the name and address of the department that has the highest number of students.[/QUESTION]
[SQL]SELECT T2.dept_name , T2.dept_address FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the name and address of the department that has the highest number of students.[/QUESTION]
[SQL]SELECT T2.dept_name , T2.dept_address FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the name and address of the department that has the highest number of students.[/QUESTION]
[SQL]SELECT T2.dept_name , T2.dept_address FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the name and address of the department that has the highest number of students.[/QUESTION]
[SQL]SELECT T2.dept_name , T2.dept_address FROM student AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) DESC LIMIT 1[/SQL] |
store_1 |
CREATE TABLE albums (
id INTEGER,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(artist_id) REFERENCES artists (id)
)
CREATE TABLE artists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE customers (
id INTEGER,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(support_rep_id) REFERENCES employees (id)
)
CREATE TABLE employees (
id INTEGER,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
PRIMARY KEY (id),
FOREIGN KEY(reports_to) REFERENCES employees (id)
)
CREATE TABLE genres (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE invoice_lines (
id INTEGER,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(invoice_id) REFERENCES invoices (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
CREATE TABLE invoices (
id INTEGER,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(customer_id) REFERENCES customers (id)
)
CREATE TABLE media_types (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE playlist_tracks (
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY(playlist_id) REFERENCES playlists (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
CREATE TABLE playlists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE tracks (
id INTEGER,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(album_id) REFERENCES albums (id),
FOREIGN KEY(genre_id) REFERENCES genres (id),
FOREIGN KEY(media_type_id) REFERENCES media_types (id)
) |
CREATE TABLE albums (
id INTEGER,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(artist_id) REFERENCES artists (id)
)
/*
2 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
*/
CREATE TABLE artists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from artists table:
id name
1 AC/DC
2 Accept
*/
CREATE TABLE customers (
id INTEGER,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(support_rep_id) REFERENCES employees (id)
)
/*
2 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 [email protected] 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None [email protected] 5
*/
CREATE TABLE employees (
id INTEGER,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
PRIMARY KEY (id),
FOREIGN KEY(reports_to) REFERENCES employees (id)
)
/*
2 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager None 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 [email protected]
2 Edwards Nancy Sales Manager 1 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 [email protected]
*/
CREATE TABLE genres (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from genres table:
id name
1 Rock
2 Jazz
*/
CREATE TABLE invoice_lines (
id INTEGER,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(invoice_id) REFERENCES invoices (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
*/
CREATE TABLE invoices (
id INTEGER,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(customer_id) REFERENCES customers (id)
)
/*
2 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
*/
CREATE TABLE media_types (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
*/
CREATE TABLE playlist_tracks (
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY(playlist_id) REFERENCES playlists (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
*/
CREATE TABLE playlists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from playlists table:
id name
1 Music
2 Movies
*/
CREATE TABLE tracks (
id INTEGER,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(album_id) REFERENCES albums (id),
FOREIGN KEY(genre_id) REFERENCES genres (id),
FOREIGN KEY(media_type_id) REFERENCES media_types (id)
)
/*
2 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
*/ | In which country does Roberto Almeida? | SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida"; | [{'country': 'Brazil'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
candidate_poll |
CREATE TABLE candidate (
"Candidate_ID" INTEGER,
"People_ID" INTEGER,
"Poll_Source" TEXT,
"Date" TEXT,
"Support_rate" REAL,
"Consider_rate" REAL,
"Oppose_rate" REAL,
"Unsure_rate" REAL,
PRIMARY KEY ("Candidate_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Sex" TEXT,
"Name" TEXT,
"Date_of_Birth" TEXT,
"Height" REAL,
"Weight" REAL,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE candidate (
"Candidate_ID" INTEGER,
"People_ID" INTEGER,
"Poll_Source" TEXT,
"Date" TEXT,
"Support_rate" REAL,
"Consider_rate" REAL,
"Oppose_rate" REAL,
"Unsure_rate" REAL,
PRIMARY KEY ("Candidate_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID")
)
/*
2 rows from candidate table:
Candidate_ID People_ID Poll_Source Date Support_rate Consider_rate Oppose_rate Unsure_rate
1 1 WNBC/Marist Poll Feb 12–15, 2007 0.25 0.3 0.43 0.2
2 3 WNBC/Marist Poll Feb 12–15, 2007 0.17 0.42 0.32 0.9
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Sex" TEXT,
"Name" TEXT,
"Date_of_Birth" TEXT,
"Height" REAL,
"Weight" REAL,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Sex Name Date_of_Birth Height Weight
1 M Hubert Henno 06.10.1976 188.0 83.0
2 M Dominique Daquin 10.11.1972 197.0 85.0
*/ | which poll source does the highest oppose rate come from? | SELECT poll_source FROM candidate ORDER BY oppose_rate DESC LIMIT 1 | [{'Poll_Source': 'Newsweek Poll'}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | ||||
student_1 |
CREATE TABLE list (
"LastName" TEXT,
"FirstName" TEXT,
"Grade" INTEGER,
"Classroom" INTEGER,
PRIMARY KEY ("LastName", "FirstName")
)
CREATE TABLE teachers (
"LastName" TEXT,
"FirstName" TEXT,
"Classroom" INTEGER,
PRIMARY KEY ("LastName", "FirstName")
) |
CREATE TABLE list (
"LastName" TEXT,
"FirstName" TEXT,
"Grade" INTEGER,
"Classroom" INTEGER,
PRIMARY KEY ("LastName", "FirstName")
)
/*
2 rows from list table:
LastName FirstName Grade Classroom
CAR MAUDE 2 101
KRISTENSEN STORMY 6 112
*/
CREATE TABLE teachers (
"LastName" TEXT,
"FirstName" TEXT,
"Classroom" INTEGER,
PRIMARY KEY ("LastName", "FirstName")
)
/*
2 rows from teachers table:
LastName FirstName Classroom
MACROSTIE MIN 101
COVIN JEROME 102
*/ | Which classrooms are used by grade 5? | SELECT DISTINCT classroom FROM list WHERE grade = 5 | [{'Classroom': 109}] | Easy | true | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many classes exist for each school?[/QUESTION]
[SQL]SELECT count(*) , T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code[/SQL] | [QUESTION]How many classes exist for each school?[/QUESTION]
[SQL]SELECT count(*) , T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code[/SQL] | [QUESTION]How many classes exist for each school?[/QUESTION]
[SQL]SELECT count(*) , T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code[/SQL] | [QUESTION]How many classes exist for each school?[/QUESTION]
[SQL]SELECT count(*) , T3.school_code FROM CLASS AS T1 JOIN course AS T2 ON T1.crs_code = T2.crs_code JOIN department AS T3 ON T2.dept_code = T3.dept_code GROUP BY T3.school_code[/SQL] |
geo |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
) |
CREATE TABLE border_info (
state_name TEXT,
border TEXT,
PRIMARY KEY (border, state_name),
FOREIGN KEY(border) REFERENCES state (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from border_info table:
state_name border
*/
CREATE TABLE city (
city_name TEXT,
population INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (city_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from city table:
city_name population country_name state_name
*/
CREATE TABLE highlow (
state_name TEXT,
highest_elevation TEXT,
lowest_point TEXT,
highest_point TEXT,
lowest_elevation TEXT,
PRIMARY KEY (state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from highlow table:
state_name highest_elevation lowest_point highest_point lowest_elevation
*/
CREATE TABLE lake (
lake_name TEXT,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT
)
/*
2 rows from lake table:
lake_name area country_name state_name
*/
CREATE TABLE mountain (
mountain_name TEXT,
mountain_altitude INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
state_name TEXT,
PRIMARY KEY (mountain_name, state_name),
FOREIGN KEY(state_name) REFERENCES state (state_name)
)
/*
2 rows from mountain table:
mountain_name mountain_altitude country_name state_name
*/
CREATE TABLE river (
river_name TEXT,
length INTEGER DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
traverse TEXT,
PRIMARY KEY (river_name),
FOREIGN KEY(traverse) REFERENCES state (state_name)
)
/*
2 rows from river table:
river_name length country_name traverse
*/
CREATE TABLE state (
state_name TEXT,
population INTEGER DEFAULT NULL,
area DOUBLE DEFAULT NULL,
country_name VARCHAR(3) DEFAULT '' NOT NULL,
capital TEXT,
density DOUBLE DEFAULT NULL,
PRIMARY KEY (state_name)
)
/*
2 rows from state table:
state_name population area country_name capital density
*/ | how many major cities are there in texas | SELECT COUNT ( city_name ) FROM city WHERE population > 150000 AND state_name = "texas"; | [{'COUNT ( city_name )': 0}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
customers_and_addresses |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_content VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
other_address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Customer_Contact_Channels" (
customer_id INTEGER NOT NULL,
channel_code VARCHAR(15) NOT NULL,
active_from_date DATETIME NOT NULL,
active_to_date DATETIME,
contact_number VARCHAR(50) NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status VARCHAR(15) NOT NULL,
order_date DATETIME,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
date_became_customer DATETIME,
other_customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Order_Items" (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
order_quantity VARCHAR(15),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
product_details VARCHAR(255),
PRIMARY KEY (product_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_content VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
other_address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id address_content city zip_postcode state_province_county country other_address_details
1 9443 Boyle Route Suite 857 Lucasville 416 Colorado USA None
2 1969 Jabari Port Suite 393 New Sabryna 721 SouthCarolina USA None
*/
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Customer_Addresses table:
customer_id address_id date_address_from address_type date_address_to
2 11 1985-03-29 20:31:43 Billing 1993-02-17 17:55:18
13 11 2010-08-25 04:24:35 Billing 1972-02-17 22:23:38
*/
CREATE TABLE "Customer_Contact_Channels" (
customer_id INTEGER NOT NULL,
channel_code VARCHAR(15) NOT NULL,
active_from_date DATETIME NOT NULL,
active_to_date DATETIME,
contact_number VARCHAR(50) NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Contact_Channels table:
customer_id channel_code active_from_date active_to_date contact_number
9 Email 2017-12-07 18:18:15 2018-03-23 13:37:14 940.035.6435x0225
2 Email 2017-04-07 04:51:41 2018-03-23 01:30:52 189.449.8326x7607
*/
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status VARCHAR(15) NOT NULL,
order_date DATETIME,
order_details VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Orders table:
order_id customer_id order_status order_date order_details
1 15 Cancelled 2018-03-21 11:20:46 None
2 3 Cancelled 2018-03-05 06:35:33 None
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
date_became_customer DATETIME,
other_customer_details VARCHAR(255),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id payment_method customer_name date_became_customer other_customer_details
1 Cash Dr. Julia Wuckert MD 2018-03-01 23:20:10 None
2 Cheque Tillman Ernser 2018-02-28 11:37:44 None
*/
CREATE TABLE "Order_Items" (
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
order_quantity VARCHAR(15),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
order_id product_id order_quantity
14 2 5
5 2 9
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_details VARCHAR(255),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_details
1 Americano
2 Dove Chocolate
*/ | Find all the addresses in East Julianaside, Texas or in Gleasonmouth, Arizona. | SELECT address_content FROM addresses WHERE city = "East Julianaside" AND state_province_county = "Texas" UNION SELECT address_content FROM addresses WHERE city = "Gleasonmouth" AND state_province_county = "Arizona" | [{'address_content': '120 Noble Radial'}, {'address_content': '92865 Margaretta Streets Suite 467'}] | Hard | false | false | false | false | false | false | false | false | false | false | false | false | true | [QUESTION]What are the different addresses that have students living there?[/QUESTION]
[SQL]SELECT count(DISTINCT current_address_id) FROM Students[/SQL] |
|||
game_1 |
CREATE TABLE "Plays_Games" (
"StuID" INTEGER,
"GameID" INTEGER,
"Hours_Played" INTEGER,
FOREIGN KEY("GameID") REFERENCES "Video_Games" ("GameID"),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
CREATE TABLE "SportsInfo" (
"StuID" INTEGER,
"SportName" VARCHAR(32),
"HoursPerWeek" INTEGER,
"GamesPlayed" INTEGER,
"OnScholarship" VARCHAR(1),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
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 "Video_Games" (
"GameID" INTEGER,
"GName" VARCHAR(40),
"GType" VARCHAR(40),
PRIMARY KEY ("GameID")
) |
CREATE TABLE "Plays_Games" (
"StuID" INTEGER,
"GameID" INTEGER,
"Hours_Played" INTEGER,
FOREIGN KEY("GameID") REFERENCES "Video_Games" ("GameID"),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
/*
2 rows from Plays_Games table:
StuID GameID Hours_Played
1001 1 35
1001 2 15
*/
CREATE TABLE "SportsInfo" (
"StuID" INTEGER,
"SportName" VARCHAR(32),
"HoursPerWeek" INTEGER,
"GamesPlayed" INTEGER,
"OnScholarship" VARCHAR(1),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
/*
2 rows from SportsInfo table:
StuID SportName HoursPerWeek GamesPlayed OnScholarship
1001 Athletics 2 5 N
1002 Football 7 20 Y
*/
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
*/
CREATE TABLE "Video_Games" (
"GameID" INTEGER,
"GName" VARCHAR(40),
"GType" VARCHAR(40),
PRIMARY KEY ("GameID")
)
/*
2 rows from Video_Games table:
GameID GName GType
1 RNG Stone Collectible card game
2 The Vanishing of Eric Calder Walking Simulator
*/ | What are the ids for all sporty students who are on scholarship? | SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y' | [{'StuID': 1002}, {'StuID': 1003}, {'StuID': 1015}, {'StuID': 1019}, {'StuID': 1023}, {'StuID': 1023}, {'StuID': 1026}, {'StuID': 1033}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the first, middle, and last name, along with the id and number of enrollments, for the student who enrolled the most in any program?[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
|||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | authors of acl 2016 papers | SELECT DISTINCT t1.authorid FROM venue AS t3 JOIN paper AS t2 ON t3.venueid = t2.venueid JOIN writes AS t1 ON t1.paperid = t2.paperid WHERE t2.year = 2016 AND t3.venuename = "acl"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
gymnast |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
/*
2 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.75 58.061
2 9.7 9.625 9.625 9.65 9.587 9.737 57.924
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
*/ | What is the average horizontal bar points for all gymnasts? | SELECT avg(Horizontal_Bar_Points) FROM gymnast | [{'avg(Horizontal_Bar_Points)': 9.603428571428571}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
store_1 |
CREATE TABLE albums (
id INTEGER,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(artist_id) REFERENCES artists (id)
)
CREATE TABLE artists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE customers (
id INTEGER,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(support_rep_id) REFERENCES employees (id)
)
CREATE TABLE employees (
id INTEGER,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
PRIMARY KEY (id),
FOREIGN KEY(reports_to) REFERENCES employees (id)
)
CREATE TABLE genres (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE invoice_lines (
id INTEGER,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(invoice_id) REFERENCES invoices (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
CREATE TABLE invoices (
id INTEGER,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(customer_id) REFERENCES customers (id)
)
CREATE TABLE media_types (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE playlist_tracks (
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY(playlist_id) REFERENCES playlists (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
CREATE TABLE playlists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
CREATE TABLE tracks (
id INTEGER,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(album_id) REFERENCES albums (id),
FOREIGN KEY(genre_id) REFERENCES genres (id),
FOREIGN KEY(media_type_id) REFERENCES media_types (id)
) |
CREATE TABLE albums (
id INTEGER,
title VARCHAR(160) NOT NULL,
artist_id INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(artist_id) REFERENCES artists (id)
)
/*
2 rows from albums table:
id title artist_id
1 For Those About To Rock We Salute You 1
2 Balls to the Wall 2
*/
CREATE TABLE artists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from artists table:
id name
1 AC/DC
2 Accept
*/
CREATE TABLE customers (
id INTEGER,
first_name VARCHAR(40) NOT NULL,
last_name VARCHAR(20) NOT NULL,
company VARCHAR(80),
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60) NOT NULL,
support_rep_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(support_rep_id) REFERENCES employees (id)
)
/*
2 rows from customers table:
id first_name last_name company address city state country postal_code phone fax email support_rep_id
1 Luís Gonçalves Embraer - Empresa Brasileira de Aeronáutica S.A. Av. Brigadeiro Faria Lima, 2170 São José dos Campos SP Brazil 12227-000 +55 (12) 3923-5555 +55 (12) 3923-5566 [email protected] 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None [email protected] 5
*/
CREATE TABLE employees (
id INTEGER,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
PRIMARY KEY (id),
FOREIGN KEY(reports_to) REFERENCES employees (id)
)
/*
2 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager None 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 [email protected]
2 Edwards Nancy Sales Manager 1 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 [email protected]
*/
CREATE TABLE genres (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from genres table:
id name
1 Rock
2 Jazz
*/
CREATE TABLE invoice_lines (
id INTEGER,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(invoice_id) REFERENCES invoices (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
*/
CREATE TABLE invoices (
id INTEGER,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(customer_id) REFERENCES customers (id)
)
/*
2 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
*/
CREATE TABLE media_types (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
*/
CREATE TABLE playlist_tracks (
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY(playlist_id) REFERENCES playlists (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
*/
CREATE TABLE playlists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from playlists table:
id name
1 Music
2 Movies
*/
CREATE TABLE tracks (
id INTEGER,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(album_id) REFERENCES albums (id),
FOREIGN KEY(genre_id) REFERENCES genres (id),
FOREIGN KEY(media_type_id) REFERENCES media_types (id)
)
/*
2 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
*/ | What is employee Nancy Edwards's phone number? | SELECT phone FROM employees WHERE first_name = "Nancy" AND last_name = "Edwards"; | [{'phone': '+1 (403) 262-3443'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
election_representative |
CREATE TABLE election (
"Election_ID" INTEGER,
"Representative_ID" INTEGER,
"Date" TEXT,
"Votes" REAL,
"Vote_Percent" REAL,
"Seats" REAL,
"Place" REAL,
PRIMARY KEY ("Election_ID"),
FOREIGN KEY("Representative_ID") REFERENCES representative ("Representative_ID")
)
CREATE TABLE representative (
"Representative_ID" INTEGER,
"Name" TEXT,
"State" TEXT,
"Party" TEXT,
"Lifespan" TEXT,
PRIMARY KEY ("Representative_ID")
) |
CREATE TABLE election (
"Election_ID" INTEGER,
"Representative_ID" INTEGER,
"Date" TEXT,
"Votes" REAL,
"Vote_Percent" REAL,
"Seats" REAL,
"Place" REAL,
PRIMARY KEY ("Election_ID"),
FOREIGN KEY("Representative_ID") REFERENCES representative ("Representative_ID")
)
/*
2 rows from election table:
Election_ID Representative_ID Date Votes Vote_Percent Seats Place
1 1 July 1942 9423.0 16.2 6.0 3.0
2 2 October 1942 11059.0 18.5 10.0 1.0
*/
CREATE TABLE representative (
"Representative_ID" INTEGER,
"Name" TEXT,
"State" TEXT,
"Party" TEXT,
"Lifespan" TEXT,
PRIMARY KEY ("Representative_ID")
)
/*
2 rows from representative table:
Representative_ID Name State Party Lifespan
1 Dan Quayle Indiana Republican 1947–
2 John Quayle New York Democratic 1868–1930
*/ | What are the different parties of representative? Show the party name and the number of representatives in each party. | SELECT Party , COUNT(*) FROM representative GROUP BY Party | [{'Party': 'Democratic', 'COUNT(*)': 3}, {'Party': 'Republican', 'COUNT(*)': 4}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | ||||
csu_1 |
CREATE TABLE "Campuses" (
"Id" INTEGER,
"Campus" TEXT,
"Location" TEXT,
"County" TEXT,
"Year" INTEGER,
PRIMARY KEY ("Id")
)
CREATE TABLE csu_fees (
"Campus" INTEGER,
"Year" INTEGER,
"CampusFee" INTEGER,
PRIMARY KEY ("Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE degrees (
"Year" INTEGER,
"Campus" INTEGER,
"Degrees" INTEGER,
PRIMARY KEY ("Year", "Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE discipline_enrollments (
"Campus" INTEGER,
"Discipline" INTEGER,
"Year" INTEGER,
"Undergraduate" INTEGER,
"Graduate" INTEGER,
PRIMARY KEY ("Campus", "Discipline"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE enrollments (
"Campus" INTEGER,
"Year" INTEGER,
"TotalEnrollment_AY" INTEGER,
"FTE_AY" INTEGER,
PRIMARY KEY ("Campus", "Year"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
CREATE TABLE faculty (
"Campus" INTEGER,
"Year" INTEGER,
"Faculty" REAL,
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
) |
CREATE TABLE "Campuses" (
"Id" INTEGER,
"Campus" TEXT,
"Location" TEXT,
"County" TEXT,
"Year" INTEGER,
PRIMARY KEY ("Id")
)
/*
2 rows from Campuses table:
Id Campus Location County Year
1 California State University-Bakersfield Bakersfield Kern 1965
2 California State University-Channel Islands Camarillo Ventura 2002
*/
CREATE TABLE csu_fees (
"Campus" INTEGER,
"Year" INTEGER,
"CampusFee" INTEGER,
PRIMARY KEY ("Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from csu_fees table:
Campus Year CampusFee
1 1996 1951
2 2003 1868
*/
CREATE TABLE degrees (
"Year" INTEGER,
"Campus" INTEGER,
"Degrees" INTEGER,
PRIMARY KEY ("Year", "Campus"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from degrees table:
Year Campus Degrees
1990 1 701
1991 1 681
*/
CREATE TABLE discipline_enrollments (
"Campus" INTEGER,
"Discipline" INTEGER,
"Year" INTEGER,
"Undergraduate" INTEGER,
"Graduate" INTEGER,
PRIMARY KEY ("Campus", "Discipline"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from discipline_enrollments table:
Campus Discipline Year Undergraduate Graduate
1 4 2004 248 0
1 5 2004 811 73
*/
CREATE TABLE enrollments (
"Campus" INTEGER,
"Year" INTEGER,
"TotalEnrollment_AY" INTEGER,
"FTE_AY" INTEGER,
PRIMARY KEY ("Campus", "Year"),
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from enrollments table:
Campus Year TotalEnrollment_AY FTE_AY
1 1956 384 123
1 1957 432 151
*/
CREATE TABLE faculty (
"Campus" INTEGER,
"Year" INTEGER,
"Faculty" REAL,
FOREIGN KEY("Campus") REFERENCES "Campuses" ("Id")
)
/*
2 rows from faculty table:
Campus Year Faculty
1 2002 357.1
2 2002 48.4
*/ | How many degrees were conferred in "San Jose State University" in 2000? | SELECT degrees FROM campuses AS T1 JOIN degrees AS T2 ON t1.id = t2.campus WHERE t1.campus = "San Jose State University" AND t2.year = 2000 | [{'Degrees': 3951}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]What is the program id and the summary of the degree that has the most students enrolled?[/QUESTION]
[SQL]SELECT T1.degree_program_id , T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_program_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the program id and the summary of the degree that has the most students enrolled?[/QUESTION]
[SQL]SELECT T1.degree_program_id , T1.degree_summary_name FROM Degree_Programs AS T1 JOIN Student_Enrolment AS T2 ON T1.degree_program_id = T2.degree_program_id GROUP BY T1.degree_program_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
||
theme_gallery |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Year_Join" INTEGER,
"Age" INTEGER,
PRIMARY KEY ("Artist_ID")
)
CREATE TABLE exhibition (
"Exhibition_ID" INTEGER,
"Year" INTEGER,
"Theme" TEXT,
"Artist_ID" INTEGER,
"Ticket_Price" REAL,
PRIMARY KEY ("Exhibition_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
)
CREATE TABLE exhibition_record (
"Exhibition_ID" INTEGER,
"Date" TEXT,
"Attendance" INTEGER,
PRIMARY KEY ("Exhibition_ID", "Date"),
FOREIGN KEY("Exhibition_ID") REFERENCES exhibition ("Exhibition_ID")
) |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Year_Join" INTEGER,
"Age" INTEGER,
PRIMARY KEY ("Artist_ID")
)
/*
2 rows from artist table:
Artist_ID Name Country Year_Join Age
1 Vijay Singh Fiji 1998 45
2 John Daly United States 1991 46
*/
CREATE TABLE exhibition (
"Exhibition_ID" INTEGER,
"Year" INTEGER,
"Theme" TEXT,
"Artist_ID" INTEGER,
"Ticket_Price" REAL,
PRIMARY KEY ("Exhibition_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
)
/*
2 rows from exhibition table:
Exhibition_ID Year Theme Artist_ID Ticket_Price
1 2004 Santa Claus 1 19.95
2 2005 Christmas stocking 2 19.95
*/
CREATE TABLE exhibition_record (
"Exhibition_ID" INTEGER,
"Date" TEXT,
"Attendance" INTEGER,
PRIMARY KEY ("Exhibition_ID", "Date"),
FOREIGN KEY("Exhibition_ID") REFERENCES exhibition ("Exhibition_ID")
)
/*
2 rows from exhibition_record table:
Exhibition_ID Date Attendance
1 December 2 965
1 December 5 1098
*/ | What is the average and minimum age of all artists from United States. | SELECT avg(age) , min(age) FROM artist WHERE country = 'United States' | [{'avg(age)': 49.6, 'min(age)': 46}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many artists are male and how many are female?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]How many artists are male and how many are female?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]How many artists are male and how many are female?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] | [QUESTION]How many artists are male and how many are female?[/QUESTION]
[SQL]SELECT count(*) , gender FROM artist GROUP BY gender[/SQL] |
epinions_1 |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
) |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
/*
2 rows from item table:
i_id title
0 pear
1 orange
*/
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
/*
2 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
*/
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
/*
2 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
*/
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
)
/*
2 rows from useracct table:
u_id name
1 Helen
2 Mark
*/ | Find the name of the user who gives the most reviews. | SELECT T1.name FROM useracct AS T1 JOIN review AS T2 ON T1.u_id = T2.u_id GROUP BY T2.u_id ORDER BY count(*) DESC LIMIT 1 | [{'name': 'Mark'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
scholar |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
) |
CREATE TABLE "paperDataset" (
"paperId" INTEGER DEFAULT NULL,
"datasetId" INTEGER DEFAULT NULL,
PRIMARY KEY ("datasetId", "paperId")
)
/*
2 rows from paperDataset table:
paperId datasetId
*/
CREATE TABLE "paperKeyphrase" (
"paperId" INTEGER DEFAULT NULL,
"keyphraseId" INTEGER DEFAULT NULL,
PRIMARY KEY ("keyphraseId", "paperId"),
FOREIGN KEY("keyphraseId") REFERENCES keyphrase ("keyphraseId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from paperKeyphrase table:
paperId keyphraseId
*/
CREATE TABLE author (
"authorId" INTEGER NOT NULL,
"authorName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("authorId")
)
/*
2 rows from author table:
authorId authorName
*/
CREATE TABLE cite (
"citingPaperId" INTEGER NOT NULL,
"citedPaperId" INTEGER NOT NULL,
PRIMARY KEY ("citingPaperId", "citedPaperId"),
FOREIGN KEY("citingPaperId") REFERENCES paper ("paperId"),
FOREIGN KEY("citedPaperId") REFERENCES paper ("paperId")
)
/*
2 rows from cite table:
citingPaperId citedPaperId
*/
CREATE TABLE dataset (
"datasetId" INTEGER NOT NULL,
"datasetName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("datasetId")
)
/*
2 rows from dataset table:
datasetId datasetName
*/
CREATE TABLE journal (
"journalId" INTEGER NOT NULL,
"journalName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("journalId")
)
/*
2 rows from journal table:
journalId journalName
*/
CREATE TABLE keyphrase (
"keyphraseId" INTEGER NOT NULL,
"keyphraseName" VARCHAR(50) DEFAULT NULL,
PRIMARY KEY ("keyphraseId")
)
/*
2 rows from keyphrase table:
keyphraseId keyphraseName
*/
CREATE TABLE paper (
"paperId" INTEGER NOT NULL,
title VARCHAR(300) DEFAULT NULL,
"venueId" INTEGER DEFAULT NULL,
year INTEGER DEFAULT NULL,
"numCiting" INTEGER DEFAULT NULL,
"numCitedBy" INTEGER DEFAULT NULL,
"journalId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId"),
FOREIGN KEY("venueId") REFERENCES venue ("venueId"),
FOREIGN KEY("journalId") REFERENCES journal ("journalId")
)
/*
2 rows from paper table:
paperId title venueId year numCiting numCitedBy journalId
*/
CREATE TABLE venue (
"venueId" INTEGER NOT NULL,
"venueName" VARCHAR(100) DEFAULT NULL,
PRIMARY KEY ("venueId")
)
/*
2 rows from venue table:
venueId venueName
*/
CREATE TABLE writes (
"paperId" INTEGER DEFAULT NULL,
"authorId" INTEGER DEFAULT NULL,
PRIMARY KEY ("paperId", "authorId"),
FOREIGN KEY("authorId") REFERENCES author ("authorId"),
FOREIGN KEY("paperId") REFERENCES paper ("paperId")
)
/*
2 rows from writes table:
paperId authorId
*/ | parsing top papers | SELECT DISTINCT t4.citedpaperid , COUNT ( t4.citedpaperid ) FROM paperkeyphrase AS t2 JOIN keyphrase AS t1 ON t2.keyphraseid = t1.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid JOIN cite AS t4 ON t3.paperid = t4.citedpaperid WHERE t1.keyphrasename = "parsing" GROUP BY t4.citedpaperid ORDER BY COUNT ( t4.citedpaperid ) DESC; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | true | false | true | false | false | true | false | false | false | false | ||||
hospital_1 |
CREATE TABLE "Affiliated_With" (
"Physician" INTEGER NOT NULL,
"Department" INTEGER NOT NULL,
"PrimaryAffiliation" BOOLEAN NOT NULL,
PRIMARY KEY ("Physician", "Department"),
CONSTRAINT "fk_Affiliated_With_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Affiliated_With_Department_DepartmentID" FOREIGN KEY("Department") REFERENCES "Department" ("DepartmentID")
)
CREATE TABLE "Appointment" (
"AppointmentID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"PrepNurse" INTEGER,
"Physician" INTEGER NOT NULL,
"Start" DATETIME NOT NULL,
"End" DATETIME NOT NULL,
"ExaminationRoom" TEXT NOT NULL,
PRIMARY KEY ("AppointmentID"),
CONSTRAINT "fk_Appointment_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Appointment_Nurse_EmployeeID" FOREIGN KEY("PrepNurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_Appointment_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Block" (
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
PRIMARY KEY ("BlockFloor", "BlockCode")
)
CREATE TABLE "Department" (
"DepartmentID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Head" INTEGER NOT NULL,
CONSTRAINT "pk_Department" PRIMARY KEY ("DepartmentID"),
CONSTRAINT "fk_Department_Physician_EmployeeID" FOREIGN KEY("Head") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Medication" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Brand" VARCHAR(30) NOT NULL,
"Description" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Nurse" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"Registered" BOOLEAN NOT NULL,
"SSN" INTEGER NOT NULL,
PRIMARY KEY ("EmployeeID")
)
CREATE TABLE "On_Call" (
"Nurse" INTEGER NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"OnCallStart" DATETIME NOT NULL,
"OnCallEnd" DATETIME NOT NULL,
PRIMARY KEY ("Nurse", "BlockFloor", "BlockCode", "OnCallStart", "OnCallEnd"),
CONSTRAINT "fk_OnCall_Nurse_EmployeeID" FOREIGN KEY("Nurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_OnCall_Block_Floor" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
CREATE TABLE "Patient" (
"SSN" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Address" VARCHAR(30) NOT NULL,
"Phone" VARCHAR(30) NOT NULL,
"InsuranceID" INTEGER NOT NULL,
"PCP" INTEGER NOT NULL,
PRIMARY KEY ("SSN"),
CONSTRAINT "fk_Patient_Physician_EmployeeID" FOREIGN KEY("PCP") REFERENCES "Physician" ("EmployeeID")
)
CREATE TABLE "Physician" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"SSN" INTEGER NOT NULL,
CONSTRAINT pk_physician PRIMARY KEY ("EmployeeID")
)
CREATE TABLE "Prescribes" (
"Physician" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Medication" INTEGER NOT NULL,
"Date" DATETIME NOT NULL,
"Appointment" INTEGER,
"Dose" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Physician", "Patient", "Medication", "Date"),
CONSTRAINT "fk_Prescribes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Prescribes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Prescribes_Medication_Code" FOREIGN KEY("Medication") REFERENCES "Medication" ("Code"),
CONSTRAINT "fk_Prescribes_Appointment_AppointmentID" FOREIGN KEY("Appointment") REFERENCES "Appointment" ("AppointmentID")
)
CREATE TABLE "Procedures" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Cost" REAL NOT NULL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Room" (
"RoomNumber" INTEGER NOT NULL,
"RoomType" VARCHAR(30) NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"Unavailable" BOOLEAN NOT NULL,
PRIMARY KEY ("RoomNumber"),
CONSTRAINT "fk_Room_Block_PK" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
CREATE TABLE "Stay" (
"StayID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Room" INTEGER NOT NULL,
"StayStart" DATETIME NOT NULL,
"StayEnd" DATETIME NOT NULL,
PRIMARY KEY ("StayID"),
CONSTRAINT "fk_Stay_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Stay_Room_Number" FOREIGN KEY("Room") REFERENCES "Room" ("RoomNumber")
)
CREATE TABLE "Trained_In" (
"Physician" INTEGER NOT NULL,
"Treatment" INTEGER NOT NULL,
"CertificationDate" DATETIME NOT NULL,
"CertificationExpires" DATETIME NOT NULL,
PRIMARY KEY ("Physician", "Treatment"),
CONSTRAINT "fk_Trained_In_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Trained_In_Procedures_Code" FOREIGN KEY("Treatment") REFERENCES "Procedures" ("Code")
)
CREATE TABLE "Undergoes" (
"Patient" INTEGER NOT NULL,
"Procedures" INTEGER NOT NULL,
"Stay" INTEGER NOT NULL,
"DateUndergoes" DATETIME NOT NULL,
"Physician" INTEGER NOT NULL,
"AssistingNurse" INTEGER,
PRIMARY KEY ("Patient", "Procedures", "Stay", "DateUndergoes"),
CONSTRAINT "fk_Undergoes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Undergoes_Procedures_Code" FOREIGN KEY("Procedures") REFERENCES "Procedures" ("Code"),
CONSTRAINT "fk_Undergoes_Stay_StayID" FOREIGN KEY("Stay") REFERENCES "Stay" ("StayID"),
CONSTRAINT "fk_Undergoes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Undergoes_Nurse_EmployeeID" FOREIGN KEY("AssistingNurse") REFERENCES "Nurse" ("EmployeeID")
) |
CREATE TABLE "Affiliated_With" (
"Physician" INTEGER NOT NULL,
"Department" INTEGER NOT NULL,
"PrimaryAffiliation" BOOLEAN NOT NULL,
PRIMARY KEY ("Physician", "Department"),
CONSTRAINT "fk_Affiliated_With_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Affiliated_With_Department_DepartmentID" FOREIGN KEY("Department") REFERENCES "Department" ("DepartmentID")
)
/*
2 rows from Affiliated_With table:
Physician Department PrimaryAffiliation
1 1 True
2 1 True
*/
CREATE TABLE "Appointment" (
"AppointmentID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"PrepNurse" INTEGER,
"Physician" INTEGER NOT NULL,
"Start" DATETIME NOT NULL,
"End" DATETIME NOT NULL,
"ExaminationRoom" TEXT NOT NULL,
PRIMARY KEY ("AppointmentID"),
CONSTRAINT "fk_Appointment_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Appointment_Nurse_EmployeeID" FOREIGN KEY("PrepNurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_Appointment_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Appointment table:
AppointmentID Patient PrepNurse Physician Start End ExaminationRoom
13216584 100000001 101 1 2008-04-24 10:00:00 2008-04-24 11:00:00 A
26548913 100000002 101 2 2008-04-24 10:00:00 2008-04-24 11:00:00 B
*/
CREATE TABLE "Block" (
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
PRIMARY KEY ("BlockFloor", "BlockCode")
)
/*
2 rows from Block table:
BlockFloor BlockCode
1 1
1 2
*/
CREATE TABLE "Department" (
"DepartmentID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Head" INTEGER NOT NULL,
CONSTRAINT "pk_Department" PRIMARY KEY ("DepartmentID"),
CONSTRAINT "fk_Department_Physician_EmployeeID" FOREIGN KEY("Head") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Department table:
DepartmentID Name Head
1 General Medicine 4
2 Surgery 7
*/
CREATE TABLE "Medication" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Brand" VARCHAR(30) NOT NULL,
"Description" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Code")
)
/*
2 rows from Medication table:
Code Name Brand Description
1 Procrastin-X X N/A
2 Thesisin Foo Labs N/A
*/
CREATE TABLE "Nurse" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"Registered" BOOLEAN NOT NULL,
"SSN" INTEGER NOT NULL,
PRIMARY KEY ("EmployeeID")
)
/*
2 rows from Nurse table:
EmployeeID Name Position Registered SSN
101 Carla Espinosa Head Nurse True 111111110
102 Laverne Roberts Nurse True 222222220
*/
CREATE TABLE "On_Call" (
"Nurse" INTEGER NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"OnCallStart" DATETIME NOT NULL,
"OnCallEnd" DATETIME NOT NULL,
PRIMARY KEY ("Nurse", "BlockFloor", "BlockCode", "OnCallStart", "OnCallEnd"),
CONSTRAINT "fk_OnCall_Nurse_EmployeeID" FOREIGN KEY("Nurse") REFERENCES "Nurse" ("EmployeeID"),
CONSTRAINT "fk_OnCall_Block_Floor" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
/*
2 rows from On_Call table:
Nurse BlockFloor BlockCode OnCallStart OnCallEnd
101 1 1 2008-11-04 11:00:00 2008-11-04 19:00:00
101 1 2 2008-11-04 11:00:00 2008-11-04 19:00:00
*/
CREATE TABLE "Patient" (
"SSN" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Address" VARCHAR(30) NOT NULL,
"Phone" VARCHAR(30) NOT NULL,
"InsuranceID" INTEGER NOT NULL,
"PCP" INTEGER NOT NULL,
PRIMARY KEY ("SSN"),
CONSTRAINT "fk_Patient_Physician_EmployeeID" FOREIGN KEY("PCP") REFERENCES "Physician" ("EmployeeID")
)
/*
2 rows from Patient table:
SSN Name Address Phone InsuranceID PCP
100000001 John Smith 42 Foobar Lane 555-0256 68476213 1
100000002 Grace Ritchie 37 Snafu Drive 555-0512 36546321 2
*/
CREATE TABLE "Physician" (
"EmployeeID" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Position" VARCHAR(30) NOT NULL,
"SSN" INTEGER NOT NULL,
CONSTRAINT pk_physician PRIMARY KEY ("EmployeeID")
)
/*
2 rows from Physician table:
EmployeeID Name Position SSN
1 John Dorian Staff Internist 111111111
2 Elliot Reid Attending Physician 222222222
*/
CREATE TABLE "Prescribes" (
"Physician" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Medication" INTEGER NOT NULL,
"Date" DATETIME NOT NULL,
"Appointment" INTEGER,
"Dose" VARCHAR(30) NOT NULL,
PRIMARY KEY ("Physician", "Patient", "Medication", "Date"),
CONSTRAINT "fk_Prescribes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Prescribes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Prescribes_Medication_Code" FOREIGN KEY("Medication") REFERENCES "Medication" ("Code"),
CONSTRAINT "fk_Prescribes_Appointment_AppointmentID" FOREIGN KEY("Appointment") REFERENCES "Appointment" ("AppointmentID")
)
/*
2 rows from Prescribes table:
Physician Patient Medication Date Appointment Dose
1 100000001 1 2008-04-24 10:47:00 13216584 5
9 100000004 2 2008-04-27 10:53:00 86213939 10
*/
CREATE TABLE "Procedures" (
"Code" INTEGER NOT NULL,
"Name" VARCHAR(30) NOT NULL,
"Cost" REAL NOT NULL,
PRIMARY KEY ("Code")
)
/*
2 rows from Procedures table:
Code Name Cost
1 Reverse Rhinopodoplasty 1500.0
2 Obtuse Pyloric Recombobulation 3750.0
*/
CREATE TABLE "Room" (
"RoomNumber" INTEGER NOT NULL,
"RoomType" VARCHAR(30) NOT NULL,
"BlockFloor" INTEGER NOT NULL,
"BlockCode" INTEGER NOT NULL,
"Unavailable" BOOLEAN NOT NULL,
PRIMARY KEY ("RoomNumber"),
CONSTRAINT "fk_Room_Block_PK" FOREIGN KEY("BlockFloor", "BlockCode") REFERENCES "Block" ("BlockFloor", "BlockCode")
)
/*
2 rows from Room table:
RoomNumber RoomType BlockFloor BlockCode Unavailable
101 Single 1 1 False
102 Single 1 1 False
*/
CREATE TABLE "Stay" (
"StayID" INTEGER NOT NULL,
"Patient" INTEGER NOT NULL,
"Room" INTEGER NOT NULL,
"StayStart" DATETIME NOT NULL,
"StayEnd" DATETIME NOT NULL,
PRIMARY KEY ("StayID"),
CONSTRAINT "fk_Stay_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Stay_Room_Number" FOREIGN KEY("Room") REFERENCES "Room" ("RoomNumber")
)
/*
2 rows from Stay table:
StayID Patient Room StayStart StayEnd
3215 100000001 111 2008-05-01 00:00:00 2008-05-04 00:00:00
3216 100000003 123 2008-05-03 00:00:00 2008-05-14 00:00:00
*/
CREATE TABLE "Trained_In" (
"Physician" INTEGER NOT NULL,
"Treatment" INTEGER NOT NULL,
"CertificationDate" DATETIME NOT NULL,
"CertificationExpires" DATETIME NOT NULL,
PRIMARY KEY ("Physician", "Treatment"),
CONSTRAINT "fk_Trained_In_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Trained_In_Procedures_Code" FOREIGN KEY("Treatment") REFERENCES "Procedures" ("Code")
)
/*
2 rows from Trained_In table:
Physician Treatment CertificationDate CertificationExpires
3 1 2008-01-01 00:00:00 2008-12-31 00:00:00
3 2 2008-01-01 00:00:00 2008-12-31 00:00:00
*/
CREATE TABLE "Undergoes" (
"Patient" INTEGER NOT NULL,
"Procedures" INTEGER NOT NULL,
"Stay" INTEGER NOT NULL,
"DateUndergoes" DATETIME NOT NULL,
"Physician" INTEGER NOT NULL,
"AssistingNurse" INTEGER,
PRIMARY KEY ("Patient", "Procedures", "Stay", "DateUndergoes"),
CONSTRAINT "fk_Undergoes_Patient_SSN" FOREIGN KEY("Patient") REFERENCES "Patient" ("SSN"),
CONSTRAINT "fk_Undergoes_Procedures_Code" FOREIGN KEY("Procedures") REFERENCES "Procedures" ("Code"),
CONSTRAINT "fk_Undergoes_Stay_StayID" FOREIGN KEY("Stay") REFERENCES "Stay" ("StayID"),
CONSTRAINT "fk_Undergoes_Physician_EmployeeID" FOREIGN KEY("Physician") REFERENCES "Physician" ("EmployeeID"),
CONSTRAINT "fk_Undergoes_Nurse_EmployeeID" FOREIGN KEY("AssistingNurse") REFERENCES "Nurse" ("EmployeeID")
)
/*
2 rows from Undergoes table:
Patient Procedures Stay DateUndergoes Physician AssistingNurse
100000001 6 3215 2008-05-02 00:00:00 3 101
100000001 2 3215 2008-05-03 00:00:00 7 101
*/ | What is the names of the physicians who prescribe medication Thesisin? | SELECT DISTINCT T1.name FROM physician AS T1 JOIN prescribes AS T2 ON T1.employeeid = T2.physician JOIN medication AS T3 ON T3.code = T2.medication WHERE T3.name = "Thesisin" | [{'Name': 'Molly Clock'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | [QUESTION]What are the date and the operating professional's first name of each treatment?[/QUESTION]
[SQL]SELECT T1.date_of_treatment , T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id = T2.professional_id[/SQL] | [QUESTION]What are the date and the operating professional's first name of each treatment?[/QUESTION]
[SQL]SELECT T1.date_of_treatment , T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id = T2.professional_id[/SQL] | [QUESTION]What are the date and the operating professional's first name of each treatment?[/QUESTION]
[SQL]SELECT T1.date_of_treatment , T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id = T2.professional_id[/SQL] | [QUESTION]What are the date and the operating professional's first name of each treatment?[/QUESTION]
[SQL]SELECT T1.date_of_treatment , T2.first_name FROM Treatments AS T1 JOIN Professionals AS T2 ON T1.professional_id = T2.professional_id[/SQL] |
epinions_1 |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
) |
CREATE TABLE item (
i_id INTEGER NOT NULL,
title VARCHAR(20) DEFAULT NULL,
PRIMARY KEY (i_id)
)
/*
2 rows from item table:
i_id title
0 pear
1 orange
*/
CREATE TABLE review (
a_id INTEGER NOT NULL,
u_id INTEGER NOT NULL,
i_id INTEGER NOT NULL,
rating INTEGER DEFAULT NULL,
rank INTEGER DEFAULT NULL,
PRIMARY KEY (a_id),
FOREIGN KEY(i_id) REFERENCES item (i_id),
FOREIGN KEY(u_id) REFERENCES useracct (u_id)
)
/*
2 rows from review table:
a_id u_id i_id rating rank
1 1 1 10 1
2 2 1 5 2
*/
CREATE TABLE trust (
source_u_id INTEGER NOT NULL,
target_u_id INTEGER NOT NULL,
trust INTEGER NOT NULL,
FOREIGN KEY(target_u_id) REFERENCES useracct (u_id),
FOREIGN KEY(source_u_id) REFERENCES useracct (u_id)
)
/*
2 rows from trust table:
source_u_id target_u_id trust
1 2 10
1 3 6
*/
CREATE TABLE useracct (
u_id INTEGER NOT NULL,
name VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (u_id)
)
/*
2 rows from useracct table:
u_id name
1 Helen
2 Mark
*/ | Find the titles of items that received both a rating higher than 8 and a rating below 5. | SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating > 8 INTERSECT SELECT T1.title FROM item AS T1 JOIN review AS T2 ON T1.i_id = T2.i_id WHERE T2.rating < 5 | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | false | false | false | false | false | false | false | false | true | false | true | false | false | [QUESTION]Find the names of the artists who have produced English songs but have never received rating higher than 8.[/QUESTION]
[SQL]SELECT DISTINCT artist_name FROM song WHERE languages = "english" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 8[/SQL] | [QUESTION]Find the names of the artists who have produced English songs but have never received rating higher than 8.[/QUESTION]
[SQL]SELECT DISTINCT artist_name FROM song WHERE languages = "english" EXCEPT SELECT DISTINCT artist_name FROM song WHERE rating > 8[/SQL] |
||
cre_Theme_park |
CREATE TABLE "Features" (
"Feature_ID" INTEGER NOT NULL,
"Feature_Details" VARCHAR(255),
PRIMARY KEY ("Feature_ID")
)
CREATE TABLE "Hotels" (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range REAL,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY(star_rating_code) REFERENCES "Ref_Hotel_Star_Ratings" (star_rating_code)
)
CREATE TABLE "Locations" (
"Location_ID" INTEGER NOT NULL,
"Location_Name" VARCHAR(255),
"Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Location_ID")
)
CREATE TABLE "Museums" (
"Museum_ID" INTEGER NOT NULL,
"Museum_Details" VARCHAR(255),
PRIMARY KEY ("Museum_ID"),
FOREIGN KEY("Museum_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Photos" (
"Photo_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Filename" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Photo_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Ref_Attraction_Types" (
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Attraction_Type_Description" VARCHAR(255),
PRIMARY KEY ("Attraction_Type_Code"),
UNIQUE ("Attraction_Type_Code")
)
CREATE TABLE "Ref_Hotel_Star_Ratings" (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
)
CREATE TABLE "Royal_Family" (
"Royal_Family_ID" INTEGER NOT NULL,
"Royal_Family_Details" VARCHAR(255),
PRIMARY KEY ("Royal_Family_ID"),
FOREIGN KEY("Royal_Family_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Shops" (
"Shop_ID" INTEGER NOT NULL,
"Shop_Details" VARCHAR(255),
PRIMARY KEY ("Shop_ID"),
FOREIGN KEY("Shop_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Staff" (
"Staff_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(40),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Staff_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Street_Markets" (
"Market_ID" INTEGER NOT NULL,
"Market_Details" VARCHAR(255),
PRIMARY KEY ("Market_ID"),
FOREIGN KEY("Market_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Theme_Parks" (
"Theme_Park_ID" INTEGER NOT NULL,
"Theme_Park_Details" VARCHAR(255),
PRIMARY KEY ("Theme_Park_ID"),
FOREIGN KEY("Theme_Park_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Tourist_Attraction_Features" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Feature_ID" INTEGER NOT NULL,
PRIMARY KEY ("Tourist_Attraction_ID", "Feature_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Feature_ID") REFERENCES "Features" ("Feature_ID")
)
CREATE TABLE "Tourist_Attractions" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Location_ID" INTEGER NOT NULL,
"How_to_Get_There" VARCHAR(255),
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Opening_Hours" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_Attraction_ID"),
FOREIGN KEY("Location_ID") REFERENCES "Locations" ("Location_ID"),
FOREIGN KEY("Attraction_Type_Code") REFERENCES "Ref_Attraction_Types" ("Attraction_Type_Code")
)
CREATE TABLE "Visitors" (
"Tourist_ID" INTEGER NOT NULL,
"Tourist_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_ID"),
UNIQUE ("Tourist_ID")
)
CREATE TABLE "Visits" (
"Visit_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Tourist_ID" INTEGER NOT NULL,
"Visit_Date" DATETIME NOT NULL,
"Visit_Details" VARCHAR(40) NOT NULL,
PRIMARY KEY ("Visit_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Tourist_ID") REFERENCES "Visitors" ("Tourist_ID")
) |
CREATE TABLE "Features" (
"Feature_ID" INTEGER NOT NULL,
"Feature_Details" VARCHAR(255),
PRIMARY KEY ("Feature_ID")
)
/*
2 rows from Features table:
Feature_ID Feature_Details
523 cafe
528 park
*/
CREATE TABLE "Hotels" (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range REAL,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY(star_rating_code) REFERENCES "Ref_Hotel_Star_Ratings" (star_rating_code)
)
/*
2 rows from Hotels table:
hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details
123 5 1 2914989.571 None
144 4 None
*/
CREATE TABLE "Locations" (
"Location_ID" INTEGER NOT NULL,
"Location_Name" VARCHAR(255),
"Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Location_ID")
)
/*
2 rows from Locations table:
Location_ID Location_Name Address Other_Details
333 Astro Orbiter 660 Shea Crescent None
368 African Animals 254 Ottilie Junction None
*/
CREATE TABLE "Museums" (
"Museum_ID" INTEGER NOT NULL,
"Museum_Details" VARCHAR(255),
PRIMARY KEY ("Museum_ID"),
FOREIGN KEY("Museum_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Museums table:
Museum_ID Museum_Details
2113 Yale Center for British Art
2701 The Metropolitan Museum of Art
*/
CREATE TABLE "Photos" (
"Photo_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Filename" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Photo_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Photos table:
Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details
211 8449 game1 None 702 None
280 7067 game2 None 762 None
*/
CREATE TABLE "Ref_Attraction_Types" (
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Attraction_Type_Description" VARCHAR(255),
PRIMARY KEY ("Attraction_Type_Code"),
UNIQUE ("Attraction_Type_Code")
)
/*
2 rows from Ref_Attraction_Types table:
Attraction_Type_Code Attraction_Type_Description
2 park
3 garden
*/
CREATE TABLE "Ref_Hotel_Star_Ratings" (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
)
/*
2 rows from Ref_Hotel_Star_Ratings table:
star_rating_code star_rating_description
1 star
2 star
*/
CREATE TABLE "Royal_Family" (
"Royal_Family_ID" INTEGER NOT NULL,
"Royal_Family_Details" VARCHAR(255),
PRIMARY KEY ("Royal_Family_ID"),
FOREIGN KEY("Royal_Family_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Royal_Family table:
Royal_Family_ID Royal_Family_Details
9561 None
9919 None
*/
CREATE TABLE "Shops" (
"Shop_ID" INTEGER NOT NULL,
"Shop_Details" VARCHAR(255),
PRIMARY KEY ("Shop_ID"),
FOREIGN KEY("Shop_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Shops table:
Shop_ID Shop_Details
8429 soup
8449 coffee
*/
CREATE TABLE "Staff" (
"Staff_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(40),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Staff_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Staff table:
Staff_ID Tourist_Attraction_ID Name Other_Details
170 6476 Whitney None
219 6476 Kaela None
*/
CREATE TABLE "Street_Markets" (
"Market_ID" INTEGER NOT NULL,
"Market_Details" VARCHAR(255),
PRIMARY KEY ("Market_ID"),
FOREIGN KEY("Market_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Street_Markets table:
Market_ID Market_Details
6852 Broadway
7067 Fish Farm Market
*/
CREATE TABLE "Theme_Parks" (
"Theme_Park_ID" INTEGER NOT NULL,
"Theme_Park_Details" VARCHAR(255),
PRIMARY KEY ("Theme_Park_ID"),
FOREIGN KEY("Theme_Park_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Theme_Parks table:
Theme_Park_ID Theme_Park_Details
5265 Disney
6476 Sea World
*/
CREATE TABLE "Tourist_Attraction_Features" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Feature_ID" INTEGER NOT NULL,
PRIMARY KEY ("Tourist_Attraction_ID", "Feature_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Feature_ID") REFERENCES "Features" ("Feature_ID")
)
/*
2 rows from Tourist_Attraction_Features table:
Tourist_Attraction_ID Feature_ID
5076 528
5076 681
*/
CREATE TABLE "Tourist_Attractions" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Location_ID" INTEGER NOT NULL,
"How_to_Get_There" VARCHAR(255),
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Opening_Hours" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_Attraction_ID"),
FOREIGN KEY("Location_ID") REFERENCES "Locations" ("Location_ID"),
FOREIGN KEY("Attraction_Type_Code") REFERENCES "Ref_Attraction_Types" ("Attraction_Type_Code")
)
/*
2 rows from Tourist_Attractions table:
Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details
2113 2 579 bus art museum None None None
2701 6 417 walk UK gallery None None None
*/
CREATE TABLE "Visitors" (
"Tourist_ID" INTEGER NOT NULL,
"Tourist_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_ID"),
UNIQUE ("Tourist_ID")
)
/*
2 rows from Visitors table:
Tourist_ID Tourist_Details
164 Toney
189 Graciela
*/
CREATE TABLE "Visits" (
"Visit_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Tourist_ID" INTEGER NOT NULL,
"Visit_Date" DATETIME NOT NULL,
"Visit_Details" VARCHAR(40) NOT NULL,
PRIMARY KEY ("Visit_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Tourist_ID") REFERENCES "Visitors" ("Tourist_ID")
)
/*
2 rows from Visits table:
Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details
183 6653 377 2004-08-21 03:06:14
268 5076 204 2013-08-06 05:35:51
*/ | Find the details of the shops that can be reached by walk. | SELECT T1.Shop_Details FROM SHOPS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Shop_ID = T2.Tourist_Attraction_ID WHERE T2.How_to_Get_There = "walk" | [{'Shop_Details': 'soup'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]Find the number of shops in each location.[/QUESTION]
[SQL]SELECT count(*) , LOCATION FROM shop GROUP BY LOCATION[/SQL] | [QUESTION]Find the number of shops in each location.[/QUESTION]
[SQL]SELECT count(*) , LOCATION FROM shop GROUP BY LOCATION[/SQL] | [QUESTION]Find the number of shops in each location.[/QUESTION]
[SQL]SELECT count(*) , LOCATION FROM shop GROUP BY LOCATION[/SQL] | [QUESTION]Find the number of shops in each location.[/QUESTION]
[SQL]SELECT count(*) , LOCATION FROM shop GROUP BY LOCATION[/SQL] |
game_1 |
CREATE TABLE "Plays_Games" (
"StuID" INTEGER,
"GameID" INTEGER,
"Hours_Played" INTEGER,
FOREIGN KEY("GameID") REFERENCES "Video_Games" ("GameID"),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
CREATE TABLE "SportsInfo" (
"StuID" INTEGER,
"SportName" VARCHAR(32),
"HoursPerWeek" INTEGER,
"GamesPlayed" INTEGER,
"OnScholarship" VARCHAR(1),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
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 "Video_Games" (
"GameID" INTEGER,
"GName" VARCHAR(40),
"GType" VARCHAR(40),
PRIMARY KEY ("GameID")
) |
CREATE TABLE "Plays_Games" (
"StuID" INTEGER,
"GameID" INTEGER,
"Hours_Played" INTEGER,
FOREIGN KEY("GameID") REFERENCES "Video_Games" ("GameID"),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
/*
2 rows from Plays_Games table:
StuID GameID Hours_Played
1001 1 35
1001 2 15
*/
CREATE TABLE "SportsInfo" (
"StuID" INTEGER,
"SportName" VARCHAR(32),
"HoursPerWeek" INTEGER,
"GamesPlayed" INTEGER,
"OnScholarship" VARCHAR(1),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID")
)
/*
2 rows from SportsInfo table:
StuID SportName HoursPerWeek GamesPlayed OnScholarship
1001 Athletics 2 5 N
1002 Football 7 20 Y
*/
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
*/
CREATE TABLE "Video_Games" (
"GameID" INTEGER,
"GName" VARCHAR(40),
"GType" VARCHAR(40),
PRIMARY KEY ("GameID")
)
/*
2 rows from Video_Games table:
GameID GName GType
1 RNG Stone Collectible card game
2 The Vanishing of Eric Calder Walking Simulator
*/ | List ids for all student who are on scholarship. | SELECT StuID FROM Sportsinfo WHERE onscholarship = 'Y' | [{'StuID': 1002}, {'StuID': 1003}, {'StuID': 1015}, {'StuID': 1019}, {'StuID': 1023}, {'StuID': 1023}, {'StuID': 1026}, {'StuID': 1033}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id.[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id.[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id.[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Which student has enrolled for the most times in any program? List the id, first name, middle name, last name, the number of enrollments and student id.[/QUESTION]
[SQL]SELECT T1.student_id , T1.first_name , T1.middle_name , T1.last_name , count(*) , T1.student_id FROM Students AS T1 JOIN Student_Enrolment AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1[/SQL] |
concert_singer |
CREATE TABLE concert (
"concert_ID" INTEGER,
"concert_Name" TEXT,
"Theme" TEXT,
"Stadium_ID" TEXT,
"Year" TEXT,
PRIMARY KEY ("concert_ID"),
FOREIGN KEY("Stadium_ID") REFERENCES stadium ("Stadium_ID")
)
CREATE TABLE singer (
"Singer_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Song_Name" TEXT,
"Song_release_year" TEXT,
"Age" INTEGER,
"Is_male" BOOLEAN,
PRIMARY KEY ("Singer_ID")
)
CREATE TABLE singer_in_concert (
"concert_ID" INTEGER,
"Singer_ID" TEXT,
PRIMARY KEY ("concert_ID", "Singer_ID"),
FOREIGN KEY("concert_ID") REFERENCES concert ("concert_ID"),
FOREIGN KEY("Singer_ID") REFERENCES singer ("Singer_ID")
)
CREATE TABLE stadium (
"Stadium_ID" INTEGER,
"Location" TEXT,
"Name" TEXT,
"Capacity" INTEGER,
"Highest" INTEGER,
"Lowest" INTEGER,
"Average" INTEGER,
PRIMARY KEY ("Stadium_ID")
) |
CREATE TABLE concert (
"concert_ID" INTEGER,
"concert_Name" TEXT,
"Theme" TEXT,
"Stadium_ID" TEXT,
"Year" TEXT,
PRIMARY KEY ("concert_ID"),
FOREIGN KEY("Stadium_ID") REFERENCES stadium ("Stadium_ID")
)
/*
2 rows from concert table:
concert_ID concert_Name Theme Stadium_ID Year
1 Auditions Free choice 1 2014
2 Super bootcamp Free choice 2 2 2014
*/
CREATE TABLE singer (
"Singer_ID" INTEGER,
"Name" TEXT,
"Country" TEXT,
"Song_Name" TEXT,
"Song_release_year" TEXT,
"Age" INTEGER,
"Is_male" BOOLEAN,
PRIMARY KEY ("Singer_ID")
)
/*
2 rows from singer table:
Singer_ID Name Country Song_Name Song_release_year Age Is_male
1 Joe Sharp Netherlands You 1992 52 True
2 Timbaland United States Dangerous 2008 32 True
*/
CREATE TABLE singer_in_concert (
"concert_ID" INTEGER,
"Singer_ID" TEXT,
PRIMARY KEY ("concert_ID", "Singer_ID"),
FOREIGN KEY("concert_ID") REFERENCES concert ("concert_ID"),
FOREIGN KEY("Singer_ID") REFERENCES singer ("Singer_ID")
)
/*
2 rows from singer_in_concert table:
concert_ID Singer_ID
1 2
1 3
*/
CREATE TABLE stadium (
"Stadium_ID" INTEGER,
"Location" TEXT,
"Name" TEXT,
"Capacity" INTEGER,
"Highest" INTEGER,
"Lowest" INTEGER,
"Average" INTEGER,
PRIMARY KEY ("Stadium_ID")
)
/*
2 rows from stadium table:
Stadium_ID Location Name Capacity Highest Lowest Average
1 Raith Rovers Stark's Park 10104 4812 1294 2106
2 Ayr United Somerset Park 11998 2363 1057 1477
*/ | Show location and name for all stadiums with a capacity between 5000 and 10000. | SELECT LOCATION , name FROM stadium WHERE capacity BETWEEN 5000 AND 10000 | [{'Nenhum': 'Nenhum resultado encontrado'}] | Easy | false | false | true | false | false | false | false | false | false | false | false | false | false | [QUESTION]Show names for all stadiums except for stadiums having a concert in year 2014.[/QUESTION]
[SQL]SELECT name FROM stadium EXCEPT SELECT T2.name FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year = 2014[/SQL] | [QUESTION]Show names for all stadiums except for stadiums having a concert in year 2014.[/QUESTION]
[SQL]SELECT name FROM stadium EXCEPT SELECT T2.name FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year = 2014[/SQL] | [QUESTION]Show names for all stadiums except for stadiums having a concert in year 2014.[/QUESTION]
[SQL]SELECT name FROM stadium EXCEPT SELECT T2.name FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year = 2014[/SQL] | [QUESTION]Show names for all stadiums except for stadiums having a concert in year 2014.[/QUESTION]
[SQL]SELECT name FROM stadium EXCEPT SELECT T2.name FROM concert AS T1 JOIN stadium AS T2 ON T1.stadium_id = T2.stadium_id WHERE T1.year = 2014[/SQL] |
manufactory_1 |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
) |
CREATE TABLE "Manufacturers" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Headquarter" VARCHAR(255) NOT NULL,
"Founder" VARCHAR(255) NOT NULL,
"Revenue" REAL,
PRIMARY KEY ("Code")
)
/*
2 rows from Manufacturers table:
Code Name Headquarter Founder Revenue
1 Sony Tokyo Andy 120.0
2 Creative Labs Austin Owen 100.0
*/
CREATE TABLE "Products" (
"Code" INTEGER,
"Name" VARCHAR(255) NOT NULL,
"Price" DECIMAL NOT NULL,
"Manufacturer" INTEGER NOT NULL,
PRIMARY KEY ("Code"),
FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
)
/*
2 rows from Products table:
Code Name Price Manufacturer
1 Hard drive 240.0000000000 5
2 Memory 120.0000000000 6
*/ | Find the name of product that is produced by both companies Creative Labs and Sony. | SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Creative Labs' INTERSECT SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code WHERE T2.name = 'Sony' | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | false | false | false | false | false | false | false | false | true | false | true | false | false | ||||
small_bank_1 |
CREATE TABLE "ACCOUNTS" (
custid BIGINT NOT NULL,
name VARCHAR(64) NOT NULL,
PRIMARY KEY (custid)
)
CREATE TABLE "CHECKING" (
custid BIGINT NOT NULL,
balance FLOAT NOT NULL,
PRIMARY KEY (custid),
FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)
CREATE TABLE "SAVINGS" (
custid BIGINT NOT NULL,
balance FLOAT NOT NULL,
PRIMARY KEY (custid),
FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
) |
CREATE TABLE "ACCOUNTS" (
custid BIGINT NOT NULL,
name VARCHAR(64) NOT NULL,
PRIMARY KEY (custid)
)
/*
2 rows from ACCOUNTS table:
custid name
1 Brown
2 Wang
*/
CREATE TABLE "CHECKING" (
custid BIGINT NOT NULL,
balance FLOAT NOT NULL,
PRIMARY KEY (custid),
FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)
/*
2 rows from CHECKING table:
custid balance
1 10000.0
2 2000.0
*/
CREATE TABLE "SAVINGS" (
custid BIGINT NOT NULL,
balance FLOAT NOT NULL,
PRIMARY KEY (custid),
FOREIGN KEY(custid) REFERENCES "ACCOUNTS" (custid)
)
/*
2 rows from SAVINGS table:
custid balance
1 200000.0
2 999999999.0
*/ | What is the sum of checking and savings balances for all customers, ordered by the total balance? | SELECT T1.balance + T2.balance FROM checking AS T1 JOIN savings AS T2 ON T1.custid = T2.custid ORDER BY T1.balance + T2.balance | [{'T1.balance + T2.balance': 317.0}, {'T1.balance + T2.balance': 7060.0}, {'T1.balance + T2.balance': 90000.0}, {'T1.balance + T2.balance': 210000.0}, {'T1.balance + T2.balance': 233000.0}, {'T1.balance + T2.balance': 1000001999.0}] | Medium | false | false | false | true | false | false | false | true | false | false | false | false | false | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] | [QUESTION]What are the names of all customers, ordered by account balance?[/QUESTION]
[SQL]SELECT cust_name FROM customer ORDER BY acc_bal[/SQL] |
music_4 |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
) |
CREATE TABLE artist (
"Artist_ID" INTEGER,
"Artist" TEXT,
"Age" INTEGER,
"Famous_Title" TEXT,
"Famous_Release_date" TEXT,
PRIMARY KEY ("Artist_ID")
)
/*
2 rows from artist table:
Artist_ID Artist Age Famous_Title Famous_Release_date
1 Gorgoroth 34 Bergen 1996 November 2007
2 Ophiolatry 35 Transmutation January 21, 2008
*/
CREATE TABLE music_festival (
"ID" INTEGER,
"Music_Festival" TEXT,
"Date_of_ceremony" TEXT,
"Category" TEXT,
"Volume" INTEGER,
"Result" TEXT,
PRIMARY KEY ("ID"),
FOREIGN KEY("Volume") REFERENCES volume ("Volume_ID")
)
/*
2 rows from music_festival table:
ID Music_Festival Date_of_ceremony Category Volume Result
1 34th England Academy Prize 18 February 2011 Best Song 1 Nominated
2 34th Japan Academy Prize 18 February 2011 Best Lyrics 2 Nominated
*/
CREATE TABLE volume (
"Volume_ID" INTEGER,
"Volume_Issue" TEXT,
"Issue_Date" TEXT,
"Weeks_on_Top" REAL,
"Song" TEXT,
"Artist_ID" INTEGER,
PRIMARY KEY ("Volume_ID"),
FOREIGN KEY("Artist_ID") REFERENCES artist ("Artist_ID")
)
/*
2 rows from volume table:
Volume_ID Volume_Issue Issue_Date Weeks_on_Top Song Artist_ID
1 45:14 § 27 December 1986 - 10 January 3.0 The Way 1
2 45:15 17 January 1.0 Everybody Have Fun Tonight 2
*/ | Return the average number of weeks on top for volumes by artists that are at most 25 years old. | SELECT avg(T2.Weeks_on_Top) FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 25 | [{'avg(T2.Weeks_on_Top)': 1.0}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
department_store |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
date_to DATETIME,
PRIMARY KEY (customer_id, address_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status_code VARCHAR(10) NOT NULL,
order_date DATETIME NOT NULL,
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method_code VARCHAR(10) NOT NULL,
customer_code VARCHAR(20),
customer_name VARCHAR(80),
customer_address VARCHAR(255),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Department_Store_Chain" (
dept_store_chain_id INTEGER,
dept_store_chain_name VARCHAR(80),
PRIMARY KEY (dept_store_chain_id)
)
CREATE TABLE "Department_Stores" (
dept_store_id INTEGER,
dept_store_chain_id INTEGER,
store_name VARCHAR(80),
store_address VARCHAR(255),
store_phone VARCHAR(80),
store_email VARCHAR(80),
PRIMARY KEY (dept_store_id),
FOREIGN KEY(dept_store_chain_id) REFERENCES "Department_Store_Chain" (dept_store_chain_id)
)
CREATE TABLE "Departments" (
department_id INTEGER,
dept_store_id INTEGER NOT NULL,
department_name VARCHAR(80),
PRIMARY KEY (department_id),
FOREIGN KEY(dept_store_id) REFERENCES "Department_Stores" (dept_store_id)
)
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
PRIMARY KEY (order_item_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id)
)
CREATE TABLE "Product_Suppliers" (
product_id INTEGER NOT NULL,
supplier_id INTEGER NOT NULL,
date_supplied_from DATETIME NOT NULL,
date_supplied_to DATETIME,
total_amount_purchased VARCHAR(80),
total_value_purchased DECIMAL(19, 4),
PRIMARY KEY (product_id, supplier_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(supplier_id) REFERENCES "Suppliers" (supplier_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
product_type_code VARCHAR(10) NOT NULL,
product_name VARCHAR(80),
product_price DECIMAL(19, 4),
PRIMARY KEY (product_id)
)
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_gender VARCHAR(1),
staff_name VARCHAR(80),
PRIMARY KEY (staff_id)
)
CREATE TABLE "Staff_Department_Assignments" (
staff_id INTEGER NOT NULL,
department_id INTEGER NOT NULL,
date_assigned_from DATETIME NOT NULL,
job_title_code VARCHAR(10) NOT NULL,
date_assigned_to DATETIME,
PRIMARY KEY (staff_id, department_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(department_id) REFERENCES "Departments" (department_id)
)
CREATE TABLE "Supplier_Addresses" (
supplier_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
date_to DATETIME,
PRIMARY KEY (supplier_id, address_id),
FOREIGN KEY(supplier_id) REFERENCES "Suppliers" (supplier_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Suppliers" (
supplier_id INTEGER,
supplier_name VARCHAR(80),
supplier_phone VARCHAR(80),
PRIMARY KEY (supplier_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id address_details
1 28481 Crist Circle
East Burdettestad, IA 21232
2 0292 Mitchel Pike
Port Abefurt, IA 84402-4249
*/
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
date_to DATETIME,
PRIMARY KEY (customer_id, address_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Customer_Addresses table:
customer_id address_id date_from date_to
2 9 2017-12-11 05:00:22 2018-03-20 20:52:34
1 6 2017-10-07 23:00:26 2018-02-28 14:53:52
*/
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status_code VARCHAR(10) NOT NULL,
order_date DATETIME NOT NULL,
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Orders table:
order_id customer_id order_status_code order_date
1 12 Completed 2018-02-10 15:44:48
2 4 New 2018-01-31 17:49:18
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method_code VARCHAR(10) NOT NULL,
customer_code VARCHAR(20),
customer_name VARCHAR(80),
customer_address VARCHAR(255),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id payment_method_code customer_code customer_name customer_address customer_phone customer_email
1 Credit Card 401 Ahmed 75099 Tremblay Port Apt. 163
South Norrisland, SC 80546 254-072-4068x33935 [email protected]
2 Credit Card 665 Chauncey 8408 Lindsay Court
East Dasiabury, IL 72656-3552 +41(8)1897032009 [email protected]
*/
CREATE TABLE "Department_Store_Chain" (
dept_store_chain_id INTEGER,
dept_store_chain_name VARCHAR(80),
PRIMARY KEY (dept_store_chain_id)
)
/*
2 rows from Department_Store_Chain table:
dept_store_chain_id dept_store_chain_name
1 South
2 West
*/
CREATE TABLE "Department_Stores" (
dept_store_id INTEGER,
dept_store_chain_id INTEGER,
store_name VARCHAR(80),
store_address VARCHAR(255),
store_phone VARCHAR(80),
store_email VARCHAR(80),
PRIMARY KEY (dept_store_id),
FOREIGN KEY(dept_store_chain_id) REFERENCES "Department_Store_Chain" (dept_store_chain_id)
)
/*
2 rows from Department_Stores table:
dept_store_id dept_store_chain_id store_name store_address store_phone store_email
1 1 store_name 01290 Jeremie Parkway Suite 753
North Arielle, MS 51249 (948)944-5099x2027 [email protected]
2 3 store_name 082 Purdy Expressway
O'Connellshire, IL 31732 877-917-5029 [email protected]
*/
CREATE TABLE "Departments" (
department_id INTEGER,
dept_store_id INTEGER NOT NULL,
department_name VARCHAR(80),
PRIMARY KEY (department_id),
FOREIGN KEY(dept_store_id) REFERENCES "Department_Stores" (dept_store_id)
)
/*
2 rows from Departments table:
department_id dept_store_id department_name
1 5 human resource
2 11 purchasing
*/
CREATE TABLE "Order_Items" (
order_item_id INTEGER,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
PRIMARY KEY (order_item_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id)
)
/*
2 rows from Order_Items table:
order_item_id order_id product_id
1 9 7
2 1 3
*/
CREATE TABLE "Product_Suppliers" (
product_id INTEGER NOT NULL,
supplier_id INTEGER NOT NULL,
date_supplied_from DATETIME NOT NULL,
date_supplied_to DATETIME,
total_amount_purchased VARCHAR(80),
total_value_purchased DECIMAL(19, 4),
PRIMARY KEY (product_id, supplier_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(supplier_id) REFERENCES "Suppliers" (supplier_id)
)
/*
2 rows from Product_Suppliers table:
product_id supplier_id date_supplied_from date_supplied_to total_amount_purchased total_value_purchased
4 3 2017-06-19 00:49:05 2018-03-24 19:29:18 89366.05 36014.6000
8 4 2017-07-02 00:35:12 2018-03-25 07:30:49 25085.57 36274.5600
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_type_code VARCHAR(10) NOT NULL,
product_name VARCHAR(80),
product_price DECIMAL(19, 4),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_type_code product_name product_price
1 Clothes red jeans 734.7300
2 Clothes yellow jeans 687.2300
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_gender VARCHAR(1),
staff_name VARCHAR(80),
PRIMARY KEY (staff_id)
)
/*
2 rows from Staff table:
staff_id staff_gender staff_name
1 1 Tom
2 1 Malika
*/
CREATE TABLE "Staff_Department_Assignments" (
staff_id INTEGER NOT NULL,
department_id INTEGER NOT NULL,
date_assigned_from DATETIME NOT NULL,
job_title_code VARCHAR(10) NOT NULL,
date_assigned_to DATETIME,
PRIMARY KEY (staff_id, department_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(department_id) REFERENCES "Departments" (department_id)
)
/*
2 rows from Staff_Department_Assignments table:
staff_id department_id date_assigned_from job_title_code date_assigned_to
5 4 2017-06-11 22:55:20 Department Manager 2018-03-23 21:59:11
10 5 2017-12-18 19:12:15 Sales Person 2018-03-23 20:25:24
*/
CREATE TABLE "Supplier_Addresses" (
supplier_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
date_to DATETIME,
PRIMARY KEY (supplier_id, address_id),
FOREIGN KEY(supplier_id) REFERENCES "Suppliers" (supplier_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Supplier_Addresses table:
supplier_id address_id date_from date_to
4 5 2016-09-22 16:41:31 2018-03-14 20:06:37
3 9 2014-11-07 19:18:49 2018-03-16 16:39:58
*/
CREATE TABLE "Suppliers" (
supplier_id INTEGER,
supplier_name VARCHAR(80),
supplier_phone VARCHAR(80),
PRIMARY KEY (supplier_id)
)
/*
2 rows from Suppliers table:
supplier_id supplier_name supplier_phone
1 Lidl (692)009-5928
2 AB Store 1-483-283-4742
*/ | Return the name and gender of the staff who was assigned in 2016. | SELECT T1.staff_name , T1.staff_gender FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id WHERE T2.date_assigned_from LIKE "2016%" | [{'staff_name': 'Zakary', 'staff_gender': '1'}, {'staff_name': 'Katelynn', 'staff_gender': '1'}, {'staff_name': 'Tyson', 'staff_gender': '1'}, {'staff_name': 'Melody', 'staff_gender': '1'}, {'staff_name': 'Yolanda', 'staff_gender': '1'}, {'staff_name': 'Malika', 'staff_gender': '1'}] | Medium | false | true | false | false | false | false | false | true | false | false | false | false | false | ||||
activity_1 |
CREATE TABLE "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
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 "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
/*
2 rows from Activity table:
actid activity_name
770 Mountain Climbing
771 Canoeing
*/
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
/*
2 rows from Faculty table:
FacID Lname Fname Rank Sex Phone Room Building
1082 Giuliano Mark Instructor M 2424 224 NEB
1121 Goodrich Michael Professor M 3593 219 NEB
*/
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Faculty_Participates_in table:
FacID actid
1082 784
1082 785
*/
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Participates_in table:
stuid actid
1001 770
1001 771
*/
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
*/ | What is the first and last name of the faculty participating in the most activities? | SELECT T1.fname , T1.lname FROM Faculty AS T1 JOIN Faculty_participates_in AS T2 ON T1.facID = T2.facID GROUP BY T1.FacID ORDER BY count(*) DESC LIMIT 1 | [{'Fname': 'Yair', 'Lname': 'Amir'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | [QUESTION]What is the name of the department with the fewest professors?[/QUESTION]
[SQL]SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) LIMIT 1[/SQL] | [QUESTION]What is the name of the department with the fewest professors?[/QUESTION]
[SQL]SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) LIMIT 1[/SQL] | [QUESTION]What is the name of the department with the fewest professors?[/QUESTION]
[SQL]SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) LIMIT 1[/SQL] | [QUESTION]What is the name of the department with the fewest professors?[/QUESTION]
[SQL]SELECT T2.dept_name FROM professor AS T1 JOIN department AS T2 ON T1.dept_code = T2.dept_code GROUP BY T1.dept_code ORDER BY count(*) LIMIT 1[/SQL] |
gymnast |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE gymnast (
"Gymnast_ID" INTEGER,
"Floor_Exercise_Points" REAL,
"Pommel_Horse_Points" REAL,
"Rings_Points" REAL,
"Vault_Points" REAL,
"Parallel_Bars_Points" REAL,
"Horizontal_Bar_Points" REAL,
"Total_Points" REAL,
PRIMARY KEY ("Gymnast_ID"),
FOREIGN KEY("Gymnast_ID") REFERENCES people ("People_ID")
)
/*
2 rows from gymnast table:
Gymnast_ID Floor_Exercise_Points Pommel_Horse_Points Rings_Points Vault_Points Parallel_Bars_Points Horizontal_Bar_Points Total_Points
1 9.725 9.737 9.512 9.575 9.762 9.75 58.061
2 9.7 9.625 9.625 9.65 9.587 9.737 57.924
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
"Height" REAL,
"Hometown" TEXT,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Name Age Height Hometown
1 Paul Hamm 24.0 1.71 Santo Domingo
2 Lorraine Súarez Carmona 21.0 1.75 Bonao
*/ | How many gymnasts are from each hometown? | SELECT T2.Hometown , COUNT(*) FROM gymnast AS T1 JOIN people AS T2 ON T1.Gymnast_ID = T2.People_ID GROUP BY T2.Hometown | [{'Hometown': 'Bonao', 'COUNT(*)': 1}, {'Hometown': 'Los Alcarrizos', 'COUNT(*)': 1}, {'Hometown': 'Santiago de los Caballeros', 'COUNT(*)': 1}, {'Hometown': 'Santo Domingo', 'COUNT(*)': 4}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]For each hometown, how many teachers are there?[/QUESTION]
[SQL]SELECT Hometown , COUNT(*) FROM teacher GROUP BY Hometown[/SQL] |
|||
scientist_1 |
CREATE TABLE "AssignedTo" (
"Scientist" INTEGER NOT NULL,
"Project" CHAR(4) NOT NULL,
PRIMARY KEY ("Scientist", "Project"),
FOREIGN KEY("Scientist") REFERENCES "Scientists" ("SSN"),
FOREIGN KEY("Project") REFERENCES "Projects" ("Code")
)
CREATE TABLE "Projects" (
"Code" CHAR(4),
"Name" CHAR(50) NOT NULL,
"Hours" INTEGER,
PRIMARY KEY ("Code")
)
CREATE TABLE "Scientists" (
"SSN" INTEGER,
"Name" CHAR(30) NOT NULL,
PRIMARY KEY ("SSN")
) |
CREATE TABLE "AssignedTo" (
"Scientist" INTEGER NOT NULL,
"Project" CHAR(4) NOT NULL,
PRIMARY KEY ("Scientist", "Project"),
FOREIGN KEY("Scientist") REFERENCES "Scientists" ("SSN"),
FOREIGN KEY("Project") REFERENCES "Projects" ("Code")
)
/*
2 rows from AssignedTo table:
Scientist Project
123234877 AeH1
152934485 AeH3
*/
CREATE TABLE "Projects" (
"Code" CHAR(4),
"Name" CHAR(50) NOT NULL,
"Hours" INTEGER,
PRIMARY KEY ("Code")
)
/*
2 rows from Projects table:
Code Name Hours
AeH1 Winds: Studying Bernoullis Principle 156
AeH2 Aerodynamics and Bridge Design 189
*/
CREATE TABLE "Scientists" (
"SSN" INTEGER,
"Name" CHAR(30) NOT NULL,
PRIMARY KEY ("SSN")
)
/*
2 rows from Scientists table:
SSN Name
123234877 Michael Rogers
152934485 Anand Manikutty
*/ | What are the names of projects that have not been assigned? | SELECT Name FROM Projects WHERE Code NOT IN (SELECT Project FROM AssignedTo) | [{'Name': 'Aerodynamics and Bridge Design'}, {'Name': 'Aerodynamics of a Football'}, {'Name': 'Aerodynamics of Air Hockey'}, {'Name': 'A Magnetic Primer Designer'}, {'Name': 'Bacterial Transformation Efficiency'}, {'Name': 'A Soluble Separation Solution'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
farm |
CREATE TABLE city (
"City_ID" INTEGER,
"Official_Name" TEXT,
"Status" TEXT,
"Area_km_2" REAL,
"Population" REAL,
"Census_Ranking" TEXT,
PRIMARY KEY ("City_ID")
)
CREATE TABLE competition_record (
"Competition_ID" INTEGER,
"Farm_ID" INTEGER,
"Rank" INTEGER,
PRIMARY KEY ("Competition_ID", "Farm_ID"),
FOREIGN KEY("Farm_ID") REFERENCES farm ("Farm_ID"),
FOREIGN KEY("Competition_ID") REFERENCES farm_competition ("Competition_ID")
)
CREATE TABLE farm (
"Farm_ID" INTEGER,
"Year" INTEGER,
"Total_Horses" REAL,
"Working_Horses" REAL,
"Total_Cattle" REAL,
"Oxen" REAL,
"Bulls" REAL,
"Cows" REAL,
"Pigs" REAL,
"Sheep_and_Goats" REAL,
PRIMARY KEY ("Farm_ID")
)
CREATE TABLE farm_competition (
"Competition_ID" INTEGER,
"Year" INTEGER,
"Theme" TEXT,
"Host_city_ID" INTEGER,
"Hosts" TEXT,
PRIMARY KEY ("Competition_ID"),
FOREIGN KEY("Host_city_ID") REFERENCES city ("City_ID")
) |
CREATE TABLE city (
"City_ID" INTEGER,
"Official_Name" TEXT,
"Status" TEXT,
"Area_km_2" REAL,
"Population" REAL,
"Census_Ranking" TEXT,
PRIMARY KEY ("City_ID")
)
/*
2 rows from city table:
City_ID Official_Name Status Area_km_2 Population Census_Ranking
1 Grand Falls/Grand-Sault Town 18.06 5706.0 636 of 5008
2 Perth-Andover Village 8.89 1778.0 1442 of 5,008
*/
CREATE TABLE competition_record (
"Competition_ID" INTEGER,
"Farm_ID" INTEGER,
"Rank" INTEGER,
PRIMARY KEY ("Competition_ID", "Farm_ID"),
FOREIGN KEY("Farm_ID") REFERENCES farm ("Farm_ID"),
FOREIGN KEY("Competition_ID") REFERENCES farm_competition ("Competition_ID")
)
/*
2 rows from competition_record table:
Competition_ID Farm_ID Rank
1 8 1
1 2 2
*/
CREATE TABLE farm (
"Farm_ID" INTEGER,
"Year" INTEGER,
"Total_Horses" REAL,
"Working_Horses" REAL,
"Total_Cattle" REAL,
"Oxen" REAL,
"Bulls" REAL,
"Cows" REAL,
"Pigs" REAL,
"Sheep_and_Goats" REAL,
PRIMARY KEY ("Farm_ID")
)
/*
2 rows from farm table:
Farm_ID Year Total_Horses Working_Horses Total_Cattle Oxen Bulls Cows Pigs Sheep_and_Goats
1 1927 5056.5 3900.1 8374.5 805.5 31.6 3852.1 4412.4 7956.3
2 1928 5486.9 4090.5 8604.8 895.3 32.8 3987.0 6962.9 8112.2
*/
CREATE TABLE farm_competition (
"Competition_ID" INTEGER,
"Year" INTEGER,
"Theme" TEXT,
"Host_city_ID" INTEGER,
"Hosts" TEXT,
PRIMARY KEY ("Competition_ID"),
FOREIGN KEY("Host_city_ID") REFERENCES city ("City_ID")
)
/*
2 rows from farm_competition table:
Competition_ID Year Theme Host_city_ID Hosts
1 2013 Carnival M is back! 1 Miley Cyrus Jared Leto and Karen Mok
2 2006 Codehunters 2 Leehom Wang and Kelly Rowland
*/ | Show the census ranking of cities whose status are not "Village". | SELECT Census_Ranking FROM city WHERE Status != "Village" | [{'Census_Ranking': '636 of 5008'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Find all the distinct district names ordered by city area in descending.[/QUESTION]
[SQL]SELECT DISTINCT District_name FROM district ORDER BY city_area DESC[/SQL] | [QUESTION]Find all the distinct district names ordered by city area in descending.[/QUESTION]
[SQL]SELECT DISTINCT District_name FROM district ORDER BY city_area DESC[/SQL] | [QUESTION]Find all the distinct district names ordered by city area in descending.[/QUESTION]
[SQL]SELECT DISTINCT District_name FROM district ORDER BY city_area DESC[/SQL] |
|
film_rank |
CREATE TABLE film (
"Film_ID" INTEGER,
"Title" TEXT,
"Studio" TEXT,
"Director" TEXT,
"Gross_in_dollar" INTEGER,
PRIMARY KEY ("Film_ID")
)
CREATE TABLE film_market_estimation (
"Estimation_ID" INTEGER,
"Low_Estimate" REAL,
"High_Estimate" REAL,
"Film_ID" INTEGER,
"Type" TEXT,
"Market_ID" INTEGER,
"Year" INTEGER,
PRIMARY KEY ("Estimation_ID"),
FOREIGN KEY("Film_ID") REFERENCES film ("Film_ID"),
FOREIGN KEY("Market_ID") REFERENCES market ("Market_ID")
)
CREATE TABLE market (
"Market_ID" INTEGER,
"Country" TEXT,
"Number_cities" INTEGER,
PRIMARY KEY ("Market_ID")
) |
CREATE TABLE film (
"Film_ID" INTEGER,
"Title" TEXT,
"Studio" TEXT,
"Director" TEXT,
"Gross_in_dollar" INTEGER,
PRIMARY KEY ("Film_ID")
)
/*
2 rows from film table:
Film_ID Title Studio Director Gross_in_dollar
1 ET the Extra-Terrestrial Universal Steven Spielberg 435110554
2 Tootsie Columbia Sydney Pollack 177200000
*/
CREATE TABLE film_market_estimation (
"Estimation_ID" INTEGER,
"Low_Estimate" REAL,
"High_Estimate" REAL,
"Film_ID" INTEGER,
"Type" TEXT,
"Market_ID" INTEGER,
"Year" INTEGER,
PRIMARY KEY ("Estimation_ID"),
FOREIGN KEY("Film_ID") REFERENCES film ("Film_ID"),
FOREIGN KEY("Market_ID") REFERENCES market ("Market_ID")
)
/*
2 rows from film_market_estimation table:
Estimation_ID Low_Estimate High_Estimate Film_ID Type Market_ID Year
1 80000.0 80400.0 1 Mass suicide murder 1 1945
2 8000.0 8000.0 2 Mass suicide 2 1944
*/
CREATE TABLE market (
"Market_ID" INTEGER,
"Country" TEXT,
"Number_cities" INTEGER,
PRIMARY KEY ("Market_ID")
)
/*
2 rows from market table:
Market_ID Country Number_cities
1 Japan 209
2 China 540
*/ | Return the average gross sales in dollars across all films. | SELECT avg(Gross_in_dollar) FROM film | [{'avg(Gross_in_dollar)': 114827242.38461539}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
activity_1 |
CREATE TABLE "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
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 "Activity" (
actid INTEGER,
activity_name VARCHAR(25),
PRIMARY KEY (actid)
)
/*
2 rows from Activity table:
actid activity_name
770 Mountain Climbing
771 Canoeing
*/
CREATE TABLE "Faculty" (
"FacID" INTEGER,
"Lname" VARCHAR(15),
"Fname" VARCHAR(15),
"Rank" VARCHAR(15),
"Sex" VARCHAR(1),
"Phone" INTEGER,
"Room" VARCHAR(5),
"Building" VARCHAR(13),
PRIMARY KEY ("FacID")
)
/*
2 rows from Faculty table:
FacID Lname Fname Rank Sex Phone Room Building
1082 Giuliano Mark Instructor M 2424 224 NEB
1121 Goodrich Michael Professor M 3593 219 NEB
*/
CREATE TABLE "Faculty_Participates_in" (
"FacID" INTEGER,
actid INTEGER,
FOREIGN KEY("FacID") REFERENCES "Faculty" ("FacID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Faculty_Participates_in table:
FacID actid
1082 784
1082 785
*/
CREATE TABLE "Participates_in" (
stuid INTEGER,
actid INTEGER,
FOREIGN KEY(stuid) REFERENCES "Student" ("StuID"),
FOREIGN KEY(actid) REFERENCES "Activity" (actid)
)
/*
2 rows from Participates_in table:
stuid actid
1001 770
1001 771
*/
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
*/ | What are the rank, first name, and last name of the faculty members? | SELECT rank , Fname , Lname FROM Faculty | [{'Rank': 'Instructor', 'Fname': 'Mark', 'Lname': 'Giuliano'}, {'Rank': 'Professor', 'Fname': 'Michael', 'Lname': 'Goodrich'}, {'Rank': 'Professor', 'Fname': 'Gerald', 'Lname': 'Masson'}, {'Rank': 'AssocProf', 'Fname': 'Thordur', 'Lname': 'Runolfsson'}, {'Rank': 'Professor', 'Fname': 'Daniel', 'Lname': 'Naiman'}, {'Rank': 'Instructor', 'Fname': 'Stacey', 'Lname': 'Jones'}, {'Rank': 'Professor', 'Fname': 'Frederic', 'Lname': 'Davidson'}, {'Rank': 'Professor', 'Fname': 'William', 'Lname': 'Brody'}, {'Rank': 'Professor', 'Fname': 'Gerard', 'Lname': 'Meyer'}, {'Rank': 'AsstProf', 'Fname': 'David', 'Lname': 'Yarowsky'}, {'Rank': 'Professor', 'Fname': 'Edward', 'Lname': 'Scheinerman'}, {'Rank': 'AsstProf', 'Fname': 'Carey', 'Lname': 'Priebe'}, {'Rank': 'Professor', 'Fname': 'James', 'Lname': 'Fill'}, {'Rank': 'Professor', 'Fname': 'Alan', 'Lname': 'Goldman'}, {'Rank': 'AssocProf', 'Fname': 'Scott', 'Lname': 'Smith'}, {'Rank': 'Instructor', 'Fname': 'Joanne', 'Lname': 'Houlahan'}, {'Rank': 'Professor', 'Fname': 'Luigi', 'Lname': 'Burzio'}, {'Rank': 'AsstProf', 'Fname': 'Robert', 'Lname': 'Frank'}, {'Rank': 'Instructor', 'Fname': 'Louis', 'Lname': 'Beach'}, {'Rank': 'AsstProf', 'Fname': 'Cheng', 'Lname': 'Cheng'}, {'Rank': 'Professor', 'Fname': 'Alexander', 'Lname': 'Kaplan'}, {'Rank': 'Instructor', 'Fname': 'William', 'Lname': 'Byrne'}, {'Rank': 'Professor', 'Fname': 'Shih-Ping', 'Lname': 'Han'}, {'Rank': 'Professor', 'Fname': 'Paul', 'Lname': 'Smolensky'}, {'Rank': 'AsstProf', 'Fname': 'Pablo', 'Lname': 'Iglesias'}, {'Rank': 'Professor', 'Fname': 'John', 'Lname': 'Goutsias'}, {'Rank': 'Professor', 'Fname': 'Wilson', 'Lname': 'Rugh'}, {'Rank': 'Professor', 'Fname': 'Frederick', 'Lname': 'Jelinek'}, {'Rank': 'Professor', 'Fname': 'Charles', 'Lname': 'Westgate'}, {'Rank': 'Professor', 'Fname': 'Baruch', 'Lname': 'Awerbuch'}, {'Rank': 'Professor', 'Fname': 'Russell', 'Lname': 'Taylor'}, {'Rank': 'AsstProf', 'Fname': 'Eric', 'Lname': 'Brill'}, {'Rank': 'AsstProf', 'Fname': 'Lancelot', 'Lname': 'James'}, {'Rank': 'Instructor', 'Fname': 'Ellie', 'Lname': 'Angelopoulou'}, {'Rank': 'Professor', 'Fname': 'Howard', 'Lname': 'Weinert'}, {'Rank': 'Professor', 'Fname': 'John', 'Lname': 'Wierman'}, {'Rank': 'AsstProf', 'Fname': 'Subodh', 'Lname': 'Kumar'}, {'Rank': 'AssocProf', 'Fname': 'Lawrence', 'Lname': 'Wolff'}, {'Rank': 'AsstProf', 'Fname': 'Gert', 'Lname': 'Cauwenberghs'}, {'Rank': 'Professor', 'Fname': 'Andreas', 'Lname': 'Andreou'}, {'Rank': 'AssocProf', 'Fname': 'Steven', 'Lname': 'Salzberg'}, {'Rank': 'AsstProf', 'Fname': 'Lenore', 'Lname': 'Cowen'}, {'Rank': 'Professor', 'Fname': 'Michael', 'Lname': 'McCloskey'}, {'Rank': 'AsstProf', 'Fname': 'Yair', 'Lname': 'Amir'}, {'Rank': 'AsstProf', 'Fname': 'Michael', 'Lname': 'Brent'}, {'Rank': 'AsstProf', 'Fname': 'Brenda', 'Lname': 'Rapp'}, {'Rank': 'Professor', 'Fname': 'Rao', 'Lname': 'Kosaraju'}, {'Rank': 'AssocProf', 'Fname': 'Oliver', 'Lname': 'Collins'}, {'Rank': 'AssocProf', 'Fname': 'Brian', 'Lname': 'Hughes'}, {'Rank': 'Professor', 'Fname': 'Richard', 'Lname': 'Joseph'}, {'Rank': 'Professor', 'Fname': 'Jacob', 'Lname': 'Khurgin'}, {'Rank': 'AssocProf', 'Fname': 'Jerry', 'Lname': 'Prince'}, {'Rank': 'AssocProf', 'Fname': 'Geraldine', 'Lname': 'Legendre'}, {'Rank': 'AsstProf', 'Fname': 'Colin', 'Lname': 'Wu'}, {'Rank': 'Professor', 'Fname': 'Jong-Shi', 'Lname': 'Pang'}, {'Rank': 'Instructor', 'Fname': 'Robert', 'Lname': 'Glaser'}, {'Rank': 'Instructor', 'Fname': 'Arthur', 'Lname': 'Delcher'}, {'Rank': 'AsstProf', 'Fname': 'Leslie', 'Lname': 'Hall'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the first names of all employees that are professors ordered by date of birth?[/QUESTION]
[SQL]SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob[/SQL] | [QUESTION]What are the first names of all employees that are professors ordered by date of birth?[/QUESTION]
[SQL]SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob[/SQL] | [QUESTION]What are the first names of all employees that are professors ordered by date of birth?[/QUESTION]
[SQL]SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob[/SQL] | [QUESTION]What are the first names of all employees that are professors ordered by date of birth?[/QUESTION]
[SQL]SELECT emp_fname FROM employee WHERE emp_jobcode = 'PROF' ORDER BY emp_dob[/SQL] |
wine_1 |
CREATE TABLE appellations (
"No" INTEGER,
"Appelation" TEXT,
"County" TEXT,
"State" TEXT,
"Area" TEXT,
"isAVA" TEXT,
PRIMARY KEY ("No"),
UNIQUE ("Appelation")
)
CREATE TABLE grapes (
"ID" INTEGER,
"Grape" TEXT,
"Color" TEXT,
PRIMARY KEY ("ID"),
UNIQUE ("Grape")
)
CREATE TABLE wine (
"No" INTEGER,
"Grape" TEXT,
"Winery" TEXT,
"Appelation" TEXT,
"State" TEXT,
"Name" TEXT,
"Year" INTEGER,
"Price" INTEGER,
"Score" INTEGER,
"Cases" INTEGER,
"Drink" TEXT,
FOREIGN KEY("Grape") REFERENCES grapes ("Grape"),
FOREIGN KEY("Appelation") REFERENCES appellations ("Appelation")
) |
CREATE TABLE appellations (
"No" INTEGER,
"Appelation" TEXT,
"County" TEXT,
"State" TEXT,
"Area" TEXT,
"isAVA" TEXT,
PRIMARY KEY ("No"),
UNIQUE ("Appelation")
)
/*
2 rows from appellations table:
No Appelation County State Area isAVA
1 Alexander Valley Sonoma California North Coast Yes
2 Amador County Amador California Sierra Foothills No
*/
CREATE TABLE grapes (
"ID" INTEGER,
"Grape" TEXT,
"Color" TEXT,
PRIMARY KEY ("ID"),
UNIQUE ("Grape")
)
/*
2 rows from grapes table:
ID Grape Color
1 Barbera Red
2 Cabernet Franc Red
*/
CREATE TABLE wine (
"No" INTEGER,
"Grape" TEXT,
"Winery" TEXT,
"Appelation" TEXT,
"State" TEXT,
"Name" TEXT,
"Year" INTEGER,
"Price" INTEGER,
"Score" INTEGER,
"Cases" INTEGER,
"Drink" TEXT,
FOREIGN KEY("Grape") REFERENCES grapes ("Grape"),
FOREIGN KEY("Appelation") REFERENCES appellations ("Appelation")
)
/*
2 rows from wine table:
No Grape Winery Appelation State Name Year Price Score Cases Drink
1 Zinfandel Robert Biale St. Helena California Old Kraft Vineyard 2008 44 93 275 now
2 Zinfandel Chiarello Family Napa Valley California Giana 2008 35 93 480 now
*/ | Find the average price of wines that are not produced from Sonoma county. | SELECT avg(price) FROM wine WHERE Appelation NOT IN (SELECT T1.Appelation FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = 'Sonoma') | [{'avg(price)': 46.53503184713376}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
school_bus |
CREATE TABLE driver (
"Driver_ID" INTEGER,
"Name" TEXT,
"Party" TEXT,
"Home_city" TEXT,
"Age" INTEGER,
PRIMARY KEY ("Driver_ID")
)
CREATE TABLE school (
"School_ID" INTEGER,
"Grade" TEXT,
"School" TEXT,
"Location" TEXT,
"Type" TEXT,
PRIMARY KEY ("School_ID")
)
CREATE TABLE school_bus (
"School_ID" INTEGER,
"Driver_ID" INTEGER,
"Years_Working" INTEGER,
"If_full_time" BOOLEAN,
PRIMARY KEY ("School_ID", "Driver_ID"),
FOREIGN KEY("Driver_ID") REFERENCES driver ("Driver_ID"),
FOREIGN KEY("School_ID") REFERENCES school ("School_ID")
) |
CREATE TABLE driver (
"Driver_ID" INTEGER,
"Name" TEXT,
"Party" TEXT,
"Home_city" TEXT,
"Age" INTEGER,
PRIMARY KEY ("Driver_ID")
)
/*
2 rows from driver table:
Driver_ID Name Party Home_city Age
1 Matthew Ritter Dem Hartford 40
2 Dan Carter Rep Bethel 30
*/
CREATE TABLE school (
"School_ID" INTEGER,
"Grade" TEXT,
"School" TEXT,
"Location" TEXT,
"Type" TEXT,
PRIMARY KEY ("School_ID")
)
/*
2 rows from school table:
School_ID Grade School Location Type
1 Kindergarten Noelani Elementary School Honolulu, Hawaii Public
2 1st-3rd grade St. Francis Assisi Jakarta, Indonesia Private Catholic
*/
CREATE TABLE school_bus (
"School_ID" INTEGER,
"Driver_ID" INTEGER,
"Years_Working" INTEGER,
"If_full_time" BOOLEAN,
PRIMARY KEY ("School_ID", "Driver_ID"),
FOREIGN KEY("Driver_ID") REFERENCES driver ("Driver_ID"),
FOREIGN KEY("School_ID") REFERENCES school ("School_ID")
)
/*
2 rows from school_bus table:
School_ID Driver_ID Years_Working If_full_time
1 10 10 True
5 7 8 True
*/ | find the name of driver who is driving the school bus with the longest working history. | SELECT t1.name FROM driver AS t1 JOIN school_bus AS t2 ON t1.driver_id = t2.driver_id ORDER BY years_working DESC LIMIT 1 | [{'Name': 'Henry Genga'}] | Medium | false | false | false | true | true | false | false | true | false | false | false | false | false | ||||
mountain_photos |
CREATE TABLE camera_lens (
id INTEGER,
brand TEXT,
name TEXT,
focal_length_mm REAL,
max_aperture REAL,
PRIMARY KEY (id)
)
CREATE TABLE mountain (
id INTEGER,
name TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY (id)
)
CREATE TABLE photos (
id INTEGER,
camera_lens_id INTEGER,
mountain_id INTEGER,
color TEXT,
name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(mountain_id) REFERENCES mountain (id),
FOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)
) |
CREATE TABLE camera_lens (
id INTEGER,
brand TEXT,
name TEXT,
focal_length_mm REAL,
max_aperture REAL,
PRIMARY KEY (id)
)
/*
2 rows from camera_lens table:
id brand name focal_length_mm max_aperture
1 Olympus Olympus 15mm f/8.0 Body Cap 15.0 8.0
2 Olympus Olympus M.Zuiko Digital ED 45mm f/1.8 45.0 1.8
*/
CREATE TABLE mountain (
id INTEGER,
name TEXT,
"Height" REAL,
"Prominence" REAL,
"Range" TEXT,
"Country" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from mountain table:
id name Height Prominence Range Country
1 Abune Yosef / Guliba Amba 4260.0 1909.0 Lasta Massif Ethiopia
2 Ioll / Yoll 4220.0 350.0 Kollo Massif Ethiopia
*/
CREATE TABLE photos (
id INTEGER,
camera_lens_id INTEGER,
mountain_id INTEGER,
color TEXT,
name TEXT,
PRIMARY KEY (id),
FOREIGN KEY(mountain_id) REFERENCES mountain (id),
FOREIGN KEY(camera_lens_id) REFERENCES camera_lens (id)
)
/*
2 rows from photos table:
id camera_lens_id mountain_id color name
1 1 20 RBG monkey
2 10 2 RBG rabbits
*/ | List the brands of lenses that took both a picture of mountains with range 'Toubkal Atlas' and a picture of mountains with range 'Lasta Massif' | SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Toubkal Atlas' INTERSECT SELECT T3.brand FROM mountain AS T1 JOIN photos AS T2 ON T1.id = T2.mountain_id JOIN camera_lens AS T3 ON T2.camera_lens_id = T3.id WHERE T1.range = 'Lasta Massif' | [{'brand': 'Sigma'}] | Hard | false | false | false | false | false | false | false | false | true | false | true | false | false | ||||
allergy_1 |
CREATE TABLE "Allergy_Type" (
"Allergy" VARCHAR(20),
"AllergyType" VARCHAR(20),
PRIMARY KEY ("Allergy")
)
CREATE TABLE "Has_Allergy" (
"StuID" INTEGER,
"Allergy" VARCHAR(20),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("Allergy") REFERENCES "Allergy_Type" ("Allergy")
)
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 "Allergy_Type" (
"Allergy" VARCHAR(20),
"AllergyType" VARCHAR(20),
PRIMARY KEY ("Allergy")
)
/*
2 rows from Allergy_Type table:
Allergy AllergyType
Eggs food
Nuts food
*/
CREATE TABLE "Has_Allergy" (
"StuID" INTEGER,
"Allergy" VARCHAR(20),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("Allergy") REFERENCES "Allergy_Type" ("Allergy")
)
/*
2 rows from Has_Allergy table:
StuID Allergy
1001 Cat
1002 Shellfish
*/
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 male (sex is 'M') students who have some food type allery. | SELECT count(*) FROM Student WHERE sex = "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy = T2.Allergy WHERE T2.allergytype = "food") | [{'count(*)': 10}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]Find the number of dog pets that are raised by female students (with sex F).[/QUESTION]
[SQL]SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'[/SQL] | [QUESTION]Find the number of dog pets that are raised by female students (with sex F).[/QUESTION]
[SQL]SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'[/SQL] | [QUESTION]Find the number of dog pets that are raised by female students (with sex F).[/QUESTION]
[SQL]SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'[/SQL] | [QUESTION]Find the number of dog pets that are raised by female students (with sex F).[/QUESTION]
[SQL]SELECT count(*) FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T2.petid = T3.petid WHERE T1.sex = 'F' AND T3.pettype = 'dog'[/SQL] |
cre_Theme_park |
CREATE TABLE "Features" (
"Feature_ID" INTEGER NOT NULL,
"Feature_Details" VARCHAR(255),
PRIMARY KEY ("Feature_ID")
)
CREATE TABLE "Hotels" (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range REAL,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY(star_rating_code) REFERENCES "Ref_Hotel_Star_Ratings" (star_rating_code)
)
CREATE TABLE "Locations" (
"Location_ID" INTEGER NOT NULL,
"Location_Name" VARCHAR(255),
"Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Location_ID")
)
CREATE TABLE "Museums" (
"Museum_ID" INTEGER NOT NULL,
"Museum_Details" VARCHAR(255),
PRIMARY KEY ("Museum_ID"),
FOREIGN KEY("Museum_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Photos" (
"Photo_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Filename" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Photo_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Ref_Attraction_Types" (
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Attraction_Type_Description" VARCHAR(255),
PRIMARY KEY ("Attraction_Type_Code"),
UNIQUE ("Attraction_Type_Code")
)
CREATE TABLE "Ref_Hotel_Star_Ratings" (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
)
CREATE TABLE "Royal_Family" (
"Royal_Family_ID" INTEGER NOT NULL,
"Royal_Family_Details" VARCHAR(255),
PRIMARY KEY ("Royal_Family_ID"),
FOREIGN KEY("Royal_Family_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Shops" (
"Shop_ID" INTEGER NOT NULL,
"Shop_Details" VARCHAR(255),
PRIMARY KEY ("Shop_ID"),
FOREIGN KEY("Shop_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Staff" (
"Staff_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(40),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Staff_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Street_Markets" (
"Market_ID" INTEGER NOT NULL,
"Market_Details" VARCHAR(255),
PRIMARY KEY ("Market_ID"),
FOREIGN KEY("Market_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Theme_Parks" (
"Theme_Park_ID" INTEGER NOT NULL,
"Theme_Park_Details" VARCHAR(255),
PRIMARY KEY ("Theme_Park_ID"),
FOREIGN KEY("Theme_Park_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
CREATE TABLE "Tourist_Attraction_Features" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Feature_ID" INTEGER NOT NULL,
PRIMARY KEY ("Tourist_Attraction_ID", "Feature_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Feature_ID") REFERENCES "Features" ("Feature_ID")
)
CREATE TABLE "Tourist_Attractions" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Location_ID" INTEGER NOT NULL,
"How_to_Get_There" VARCHAR(255),
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Opening_Hours" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_Attraction_ID"),
FOREIGN KEY("Location_ID") REFERENCES "Locations" ("Location_ID"),
FOREIGN KEY("Attraction_Type_Code") REFERENCES "Ref_Attraction_Types" ("Attraction_Type_Code")
)
CREATE TABLE "Visitors" (
"Tourist_ID" INTEGER NOT NULL,
"Tourist_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_ID"),
UNIQUE ("Tourist_ID")
)
CREATE TABLE "Visits" (
"Visit_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Tourist_ID" INTEGER NOT NULL,
"Visit_Date" DATETIME NOT NULL,
"Visit_Details" VARCHAR(40) NOT NULL,
PRIMARY KEY ("Visit_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Tourist_ID") REFERENCES "Visitors" ("Tourist_ID")
) |
CREATE TABLE "Features" (
"Feature_ID" INTEGER NOT NULL,
"Feature_Details" VARCHAR(255),
PRIMARY KEY ("Feature_ID")
)
/*
2 rows from Features table:
Feature_ID Feature_Details
523 cafe
528 park
*/
CREATE TABLE "Hotels" (
hotel_id INTEGER NOT NULL,
star_rating_code CHAR(15) NOT NULL,
pets_allowed_yn CHAR(1),
price_range REAL,
other_hotel_details VARCHAR(255),
PRIMARY KEY (hotel_id),
FOREIGN KEY(star_rating_code) REFERENCES "Ref_Hotel_Star_Ratings" (star_rating_code)
)
/*
2 rows from Hotels table:
hotel_id star_rating_code pets_allowed_yn price_range other_hotel_details
123 5 1 2914989.571 None
144 4 None
*/
CREATE TABLE "Locations" (
"Location_ID" INTEGER NOT NULL,
"Location_Name" VARCHAR(255),
"Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Location_ID")
)
/*
2 rows from Locations table:
Location_ID Location_Name Address Other_Details
333 Astro Orbiter 660 Shea Crescent None
368 African Animals 254 Ottilie Junction None
*/
CREATE TABLE "Museums" (
"Museum_ID" INTEGER NOT NULL,
"Museum_Details" VARCHAR(255),
PRIMARY KEY ("Museum_ID"),
FOREIGN KEY("Museum_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Museums table:
Museum_ID Museum_Details
2113 Yale Center for British Art
2701 The Metropolitan Museum of Art
*/
CREATE TABLE "Photos" (
"Photo_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Filename" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Photo_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Photos table:
Photo_ID Tourist_Attraction_ID Name Description Filename Other_Details
211 8449 game1 None 702 None
280 7067 game2 None 762 None
*/
CREATE TABLE "Ref_Attraction_Types" (
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Attraction_Type_Description" VARCHAR(255),
PRIMARY KEY ("Attraction_Type_Code"),
UNIQUE ("Attraction_Type_Code")
)
/*
2 rows from Ref_Attraction_Types table:
Attraction_Type_Code Attraction_Type_Description
2 park
3 garden
*/
CREATE TABLE "Ref_Hotel_Star_Ratings" (
star_rating_code CHAR(15) NOT NULL,
star_rating_description VARCHAR(80),
PRIMARY KEY (star_rating_code),
UNIQUE (star_rating_code)
)
/*
2 rows from Ref_Hotel_Star_Ratings table:
star_rating_code star_rating_description
1 star
2 star
*/
CREATE TABLE "Royal_Family" (
"Royal_Family_ID" INTEGER NOT NULL,
"Royal_Family_Details" VARCHAR(255),
PRIMARY KEY ("Royal_Family_ID"),
FOREIGN KEY("Royal_Family_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Royal_Family table:
Royal_Family_ID Royal_Family_Details
9561 None
9919 None
*/
CREATE TABLE "Shops" (
"Shop_ID" INTEGER NOT NULL,
"Shop_Details" VARCHAR(255),
PRIMARY KEY ("Shop_ID"),
FOREIGN KEY("Shop_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Shops table:
Shop_ID Shop_Details
8429 soup
8449 coffee
*/
CREATE TABLE "Staff" (
"Staff_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Name" VARCHAR(40),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Staff_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Staff table:
Staff_ID Tourist_Attraction_ID Name Other_Details
170 6476 Whitney None
219 6476 Kaela None
*/
CREATE TABLE "Street_Markets" (
"Market_ID" INTEGER NOT NULL,
"Market_Details" VARCHAR(255),
PRIMARY KEY ("Market_ID"),
FOREIGN KEY("Market_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Street_Markets table:
Market_ID Market_Details
6852 Broadway
7067 Fish Farm Market
*/
CREATE TABLE "Theme_Parks" (
"Theme_Park_ID" INTEGER NOT NULL,
"Theme_Park_Details" VARCHAR(255),
PRIMARY KEY ("Theme_Park_ID"),
FOREIGN KEY("Theme_Park_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID")
)
/*
2 rows from Theme_Parks table:
Theme_Park_ID Theme_Park_Details
5265 Disney
6476 Sea World
*/
CREATE TABLE "Tourist_Attraction_Features" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Feature_ID" INTEGER NOT NULL,
PRIMARY KEY ("Tourist_Attraction_ID", "Feature_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Feature_ID") REFERENCES "Features" ("Feature_ID")
)
/*
2 rows from Tourist_Attraction_Features table:
Tourist_Attraction_ID Feature_ID
5076 528
5076 681
*/
CREATE TABLE "Tourist_Attractions" (
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Attraction_Type_Code" CHAR(15) NOT NULL,
"Location_ID" INTEGER NOT NULL,
"How_to_Get_There" VARCHAR(255),
"Name" VARCHAR(255),
"Description" VARCHAR(255),
"Opening_Hours" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_Attraction_ID"),
FOREIGN KEY("Location_ID") REFERENCES "Locations" ("Location_ID"),
FOREIGN KEY("Attraction_Type_Code") REFERENCES "Ref_Attraction_Types" ("Attraction_Type_Code")
)
/*
2 rows from Tourist_Attractions table:
Tourist_Attraction_ID Attraction_Type_Code Location_ID How_to_Get_There Name Description Opening_Hours Other_Details
2113 2 579 bus art museum None None None
2701 6 417 walk UK gallery None None None
*/
CREATE TABLE "Visitors" (
"Tourist_ID" INTEGER NOT NULL,
"Tourist_Details" VARCHAR(255),
PRIMARY KEY ("Tourist_ID"),
UNIQUE ("Tourist_ID")
)
/*
2 rows from Visitors table:
Tourist_ID Tourist_Details
164 Toney
189 Graciela
*/
CREATE TABLE "Visits" (
"Visit_ID" INTEGER NOT NULL,
"Tourist_Attraction_ID" INTEGER NOT NULL,
"Tourist_ID" INTEGER NOT NULL,
"Visit_Date" DATETIME NOT NULL,
"Visit_Details" VARCHAR(40) NOT NULL,
PRIMARY KEY ("Visit_ID"),
FOREIGN KEY("Tourist_Attraction_ID") REFERENCES "Tourist_Attractions" ("Tourist_Attraction_ID"),
FOREIGN KEY("Tourist_ID") REFERENCES "Visitors" ("Tourist_ID")
)
/*
2 rows from Visits table:
Visit_ID Tourist_Attraction_ID Tourist_ID Visit_Date Visit_Details
183 6653 377 2004-08-21 03:06:14
268 5076 204 2013-08-06 05:35:51
*/ | What is the name of the tourist attraction that is associated with the photo "game1"? | SELECT T2.Name FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T1.Name = "game1" | [{'Name': 'impressions de France'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
flight_4 |
CREATE TABLE airlines (
alid INTEGER,
name TEXT,
iata VARCHAR(2),
icao VARCHAR(3),
callsign TEXT,
country TEXT,
active VARCHAR(2),
PRIMARY KEY (alid)
)
CREATE TABLE airports (
apid INTEGER,
name TEXT NOT NULL,
city TEXT,
country TEXT,
x REAL,
y REAL,
elevation BIGINT,
iata TEXT(3),
icao TEXT(4),
PRIMARY KEY (apid)
)
CREATE TABLE routes (
rid INTEGER,
dst_apid INTEGER,
dst_ap VARCHAR(4),
src_apid BIGINT,
src_ap VARCHAR(4),
alid BIGINT,
airline VARCHAR(4),
codeshare TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(dst_apid) REFERENCES airports (apid),
FOREIGN KEY(src_apid) REFERENCES airports (apid),
FOREIGN KEY(alid) REFERENCES airlines (alid)
) |
CREATE TABLE airlines (
alid INTEGER,
name TEXT,
iata VARCHAR(2),
icao VARCHAR(3),
callsign TEXT,
country TEXT,
active VARCHAR(2),
PRIMARY KEY (alid)
)
/*
2 rows from airlines table:
alid name iata icao callsign country active
-1 Unknown - N/A None None Y
1 Private flight - N/A Y
*/
CREATE TABLE airports (
apid INTEGER,
name TEXT NOT NULL,
city TEXT,
country TEXT,
x REAL,
y REAL,
elevation BIGINT,
iata TEXT(3),
icao TEXT(4),
PRIMARY KEY (apid)
)
/*
2 rows from airports table:
apid name city country x y elevation iata icao
1 Goroka Airport Goroka Papua New Guinea 145.391998291 -6.081689834590001 5282 GKA AYGA
2 Madang Airport Madang Papua New Guinea 145.789001465 -5.20707988739 20 MAG AYMD
*/
CREATE TABLE routes (
rid INTEGER,
dst_apid INTEGER,
dst_ap VARCHAR(4),
src_apid BIGINT,
src_ap VARCHAR(4),
alid BIGINT,
airline VARCHAR(4),
codeshare TEXT,
PRIMARY KEY (rid),
FOREIGN KEY(dst_apid) REFERENCES airports (apid),
FOREIGN KEY(src_apid) REFERENCES airports (apid),
FOREIGN KEY(alid) REFERENCES airlines (alid)
)
/*
2 rows from routes table:
rid dst_apid dst_ap src_apid src_ap alid airline codeshare
37 2990 KZ 2965 AER 410 2B None
38 2990 KZ 2966 ASF 410 2B None
*/ | How many routes go from the United States to Canada? | SELECT count(*) FROM routes WHERE dst_apid IN (SELECT apid FROM airports WHERE country = 'Canada') AND src_apid IN (SELECT apid FROM airports WHERE country = 'United States') | [{'count(*)': 364}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the destinations and number of flights to each one?[/QUESTION]
[SQL]SELECT destination , count(*) FROM Flight GROUP BY destination[/SQL] | [QUESTION]What are the destinations and number of flights to each one?[/QUESTION]
[SQL]SELECT destination , count(*) FROM Flight GROUP BY destination[/SQL] |
||
customers_campaigns_ecommerce |
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
premise_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type_code VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(premise_id) REFERENCES "Premises" (premise_id)
)
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status_code VARCHAR(15) NOT NULL,
shipping_method_code VARCHAR(15) NOT NULL,
order_placed_datetime DATETIME NOT NULL,
order_delivered_datetime DATETIME,
order_shipping_charges VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
customer_address VARCHAR(255),
customer_login VARCHAR(80),
customer_password VARCHAR(10),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Mailshot_Campaigns" (
mailshot_id INTEGER,
product_category VARCHAR(15),
mailshot_name VARCHAR(80),
mailshot_start_date DATETIME,
mailshot_end_date DATETIME,
PRIMARY KEY (mailshot_id)
)
CREATE TABLE "Mailshot_Customers" (
mailshot_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
outcome_code VARCHAR(15) NOT NULL,
mailshot_customer_date DATETIME,
FOREIGN KEY(mailshot_id) REFERENCES "Mailshot_Campaigns" (mailshot_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Order_Items" (
item_id INTEGER NOT NULL,
order_item_status_code VARCHAR(15) NOT NULL,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
item_status_code VARCHAR(15),
item_delivered_datetime DATETIME,
item_order_quantity VARCHAR(80),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Premises" (
premise_id INTEGER,
premises_type VARCHAR(15) NOT NULL,
premise_details VARCHAR(255),
PRIMARY KEY (premise_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
product_category VARCHAR(15) NOT NULL,
product_name VARCHAR(80),
PRIMARY KEY (product_id)
) |
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
premise_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
address_type_code VARCHAR(15) NOT NULL,
date_address_to DATETIME,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(premise_id) REFERENCES "Premises" (premise_id)
)
/*
2 rows from Customer_Addresses table:
customer_id premise_id date_address_from address_type_code date_address_to
15 1 1992-08-23 21:17:38 Billing 2018-02-28 20:54:58
2 2 2010-02-23 02:49:50 Billing 2018-03-15 18:34:41
*/
CREATE TABLE "Customer_Orders" (
order_id INTEGER,
customer_id INTEGER NOT NULL,
order_status_code VARCHAR(15) NOT NULL,
shipping_method_code VARCHAR(15) NOT NULL,
order_placed_datetime DATETIME NOT NULL,
order_delivered_datetime DATETIME,
order_shipping_charges VARCHAR(255),
PRIMARY KEY (order_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Orders table:
order_id customer_id order_status_code shipping_method_code order_placed_datetime order_delivered_datetime order_shipping_charges
1 2 Cancelled Unspecified 2015-06-15 18:19:26 2018-03-20 12:00:00 85.79
2 8 Cancelled Unspecified 2009-07-05 20:02:55 2018-03-20 12:00:00 98.4
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(15) NOT NULL,
customer_name VARCHAR(80),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
customer_address VARCHAR(255),
customer_login VARCHAR(80),
customer_password VARCHAR(10),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id payment_method customer_name customer_phone customer_email customer_address customer_login customer_password
1 Credit Card Wendell (773)971-9411x759 [email protected] 618 Webster Stream Apt. 161 None b4459ad261
2 Direct Debit Gage (402)890-2603x6005 [email protected] 0260 Walker Trace None 7905d7f1b1
*/
CREATE TABLE "Mailshot_Campaigns" (
mailshot_id INTEGER,
product_category VARCHAR(15),
mailshot_name VARCHAR(80),
mailshot_start_date DATETIME,
mailshot_end_date DATETIME,
PRIMARY KEY (mailshot_id)
)
/*
2 rows from Mailshot_Campaigns table:
mailshot_id product_category mailshot_name mailshot_start_date mailshot_end_date
1 food US 2018-02-15 09:52:17 2018-03-08 14:40:20
2 clothes US 2017-09-14 12:05:30 2018-03-15 01:06:16
*/
CREATE TABLE "Mailshot_Customers" (
mailshot_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
outcome_code VARCHAR(15) NOT NULL,
mailshot_customer_date DATETIME,
FOREIGN KEY(mailshot_id) REFERENCES "Mailshot_Campaigns" (mailshot_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Mailshot_Customers table:
mailshot_id customer_id outcome_code mailshot_customer_date
4 3 Order 2018-03-15 15:43:14
10 1 No Response 2018-03-04 13:06:55
*/
CREATE TABLE "Order_Items" (
item_id INTEGER NOT NULL,
order_item_status_code VARCHAR(15) NOT NULL,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
item_status_code VARCHAR(15),
item_delivered_datetime DATETIME,
item_order_quantity VARCHAR(80),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
item_id order_item_status_code order_id product_id item_status_code item_delivered_datetime item_order_quantity
1 Delivered 10 13 good 2018-02-25 18:22:10 6
2 Paid 6 7 good 2018-02-27 18:04:55 7
*/
CREATE TABLE "Premises" (
premise_id INTEGER,
premises_type VARCHAR(15) NOT NULL,
premise_details VARCHAR(255),
PRIMARY KEY (premise_id)
)
/*
2 rows from Premises table:
premise_id premises_type premise_details
1 Warehouse 036 Lueilwitz Harbor
2 Warehouse 676 Kelly Spur
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_category VARCHAR(15) NOT NULL,
product_name VARCHAR(80),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_category product_name
1 Food Coffee Bean
2 Electronics Keyboard
*/ | Show the name and phone for customers with a mailshot with outcome code 'No Response'. | SELECT T1.customer_name , T1.customer_phone FROM customers AS T1 JOIN mailshot_customers AS T2 ON T1.customer_id = T2.customer_id WHERE T2.outcome_code = 'No Response' | [{'customer_name': 'Wendell', 'customer_phone': '(773)971-9411x759'}, {'customer_name': 'Donnie', 'customer_phone': '(030)521-0681x0191'}, {'customer_name': 'Stella', 'customer_phone': '+43(3)1861877192'}, {'customer_name': 'Wendell', 'customer_phone': '(773)971-9411x759'}, {'customer_name': 'Carlotta', 'customer_phone': '+66(7)1491041398'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
student_assessment |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
line_1 VARCHAR(80),
line_2 VARCHAR(80),
city VARCHAR(50),
zip_postcode CHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id line_1 line_2 city zip_postcode state_province_county country
5 0900 Roderick Oval
New Albina, WA 19200-7914 Suite 096 Linnealand 862 Montana USA
9 966 Dach Ports Apt. 322
Lake Harmonyhaven, VA 65235 Apt. 163 South Minnie 716 Texas USA
*/
CREATE TABLE "Candidate_Assessments" (
candidate_id INTEGER NOT NULL,
qualification CHAR(15) NOT NULL,
assessment_date DATETIME NOT NULL,
asessment_outcome_code CHAR(15) NOT NULL,
PRIMARY KEY (candidate_id, qualification),
FOREIGN KEY(candidate_id) REFERENCES "Candidates" (candidate_id)
)
/*
2 rows from Candidate_Assessments table:
candidate_id qualification assessment_date asessment_outcome_code
111 A 2010-04-07 11:44:34 Pass
121 B 2010-04-17 11:44:34 Pass
*/
CREATE TABLE "Candidates" (
candidate_id INTEGER NOT NULL,
candidate_details VARCHAR(255),
PRIMARY KEY (candidate_id),
FOREIGN KEY(candidate_id) REFERENCES "People" (person_id)
)
/*
2 rows from Candidates table:
candidate_id candidate_details
111 Jane
121 Robert
*/
CREATE TABLE "Courses" (
course_id VARCHAR(100) NOT NULL,
course_name VARCHAR(120),
course_description VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (course_id)
)
/*
2 rows from Courses table:
course_id course_name course_description other_details
301 statistics statistics None
302 English English None
*/
CREATE TABLE "People" (
person_id INTEGER NOT NULL,
first_name VARCHAR(255),
middle_name VARCHAR(255),
last_name VARCHAR(255),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
login_name VARCHAR(40),
password VARCHAR(40),
PRIMARY KEY (person_id)
)
/*
2 rows from People table:
person_id first_name middle_name last_name cell_mobile_number email_address login_name password
111 Shannon Elissa Senger 01955267735 [email protected] pgub 5e4ff49a61b3544da3ad7dc7e2cf28847564c64c
121 Virginie Jasmin Hartmann (508)319-2970x043 [email protected] bkkv b063331ea8116befaa7b84c59c6a22200f5f8caa
*/
CREATE TABLE "People_Addresses" (
person_address_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME,
date_to DATETIME,
PRIMARY KEY (person_address_id),
FOREIGN KEY(person_id) REFERENCES "People" (person_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from People_Addresses table:
person_address_id person_id address_id date_from date_to
122 111 9 2012-09-26 13:21:00 2018-03-21 09:46:30
257 121 5 2008-07-31 02:17:25 2018-03-09 02:11:12
*/
CREATE TABLE "Student_Course_Attendance" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
date_of_attendance DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id, course_id) REFERENCES "Student_Course_Registrations" (student_id, course_id)
)
/*
2 rows from Student_Course_Attendance table:
student_id course_id date_of_attendance
111 301 2008-11-04 10:35:13
121 301 2012-04-09 11:44:34
*/
CREATE TABLE "Student_Course_Registrations" (
student_id INTEGER NOT NULL,
course_id INTEGER NOT NULL,
registration_date DATETIME NOT NULL,
PRIMARY KEY (student_id, course_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(course_id) REFERENCES "Courses" (course_id)
)
/*
2 rows from Student_Course_Registrations table:
student_id course_id registration_date
111 301 2008-11-04 10:35:13
121 301 2008-10-04 10:35:13
*/
CREATE TABLE "Students" (
student_id INTEGER NOT NULL,
student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(student_id) REFERENCES "People" (person_id)
)
/*
2 rows from Students table:
student_id student_details
111 Marry
121 Martin
*/ | For every student who is registered for some course, how many courses are they registered for? | SELECT T1.student_id , count(*) FROM students AS T1 JOIN student_course_registrations AS T2 ON T1.student_id = T2.student_id GROUP BY T1.student_id | [{'student_id': 111, 'count(*)': 1}, {'student_id': 121, 'count(*)': 2}, {'student_id': 131, 'count(*)': 1}, {'student_id': 141, 'count(*)': 2}, {'student_id': 151, 'count(*)': 1}, {'student_id': 161, 'count(*)': 1}, {'student_id': 171, 'count(*)': 1}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] | [QUESTION]How many courses in total are listed?[/QUESTION]
[SQL]SELECT count(*) FROM Courses[/SQL] |
allergy_1 |
CREATE TABLE "Allergy_Type" (
"Allergy" VARCHAR(20),
"AllergyType" VARCHAR(20),
PRIMARY KEY ("Allergy")
)
CREATE TABLE "Has_Allergy" (
"StuID" INTEGER,
"Allergy" VARCHAR(20),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("Allergy") REFERENCES "Allergy_Type" ("Allergy")
)
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 "Allergy_Type" (
"Allergy" VARCHAR(20),
"AllergyType" VARCHAR(20),
PRIMARY KEY ("Allergy")
)
/*
2 rows from Allergy_Type table:
Allergy AllergyType
Eggs food
Nuts food
*/
CREATE TABLE "Has_Allergy" (
"StuID" INTEGER,
"Allergy" VARCHAR(20),
FOREIGN KEY("StuID") REFERENCES "Student" ("StuID"),
FOREIGN KEY("Allergy") REFERENCES "Allergy_Type" ("Allergy")
)
/*
2 rows from Has_Allergy table:
StuID Allergy
1001 Cat
1002 Shellfish
*/
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
*/ | How many students have cat allergies? | SELECT count(*) FROM Has_allergy WHERE Allergy = "Cat" | [{'count(*)': 4}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What major is every student who does not own a cat as a pet, and also how old are they?[/QUESTION]
[SQL]SELECT major , age FROM student WHERE stuid NOT IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')[/SQL] | [QUESTION]What major is every student who does not own a cat as a pet, and also how old are they?[/QUESTION]
[SQL]SELECT major , age FROM student WHERE stuid NOT IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')[/SQL] | [QUESTION]What major is every student who does not own a cat as a pet, and also how old are they?[/QUESTION]
[SQL]SELECT major , age FROM student WHERE stuid NOT IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')[/SQL] | [QUESTION]What major is every student who does not own a cat as a pet, and also how old are they?[/QUESTION]
[SQL]SELECT major , age FROM student WHERE stuid NOT IN (SELECT T1.stuid FROM student AS T1 JOIN has_pet AS T2 ON T1.stuid = T2.stuid JOIN pets AS T3 ON T3.petid = T2.petid WHERE T3.pettype = 'cat')[/SQL] |