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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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
*/ | display the employee ID for each employee and the date on which he ended his previous job. | SELECT employee_id , MAX(end_date) FROM job_history GROUP BY employee_id | [{'EMPLOYEE_ID': 0, 'MAX(end_date)': '0000-00-00'}, {'EMPLOYEE_ID': 101, 'MAX(end_date)': '1997-03-15'}, {'EMPLOYEE_ID': 102, 'MAX(end_date)': '1998-07-24'}, {'EMPLOYEE_ID': 114, 'MAX(end_date)': '1999-12-31'}, {'EMPLOYEE_ID': 122, 'MAX(end_date)': '1999-12-31'}, {'EMPLOYEE_ID': 176, 'MAX(end_date)': '1999-12-31'}, {'EMPLOYEE_ID': 200, 'MAX(end_date)': '1998-12-31'}, {'EMPLOYEE_ID': 201, 'MAX(end_date)': '1999-12-19'}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/SQL] | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/SQL] | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/SQL] | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/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.
*/ | Find the code of the role that have the most employees. | SELECT role_code FROM Employees GROUP BY role_code ORDER BY count(*) DESC LIMIT 1 | [{'Role_Code': 'ED'}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | [QUESTION]Find the count and code of the job has most employees.[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the count and code of the job has most employees.[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the count and code of the job has most employees.[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/SQL] | [QUESTION]Find the count and code of the job has most employees.[/QUESTION]
[SQL]SELECT emp_jobcode , count(*) FROM employee GROUP BY emp_jobcode ORDER BY count(*) DESC LIMIT 1[/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
*/ | Give me the average prices of wines that are produced by appelations in Sonoma County. | SELECT AVG(T2.Price) FROM APPELLATIONS AS T1 JOIN WINE AS T2 ON T1.Appelation = T2.Appelation WHERE T1.County = "Sonoma" | [{'AVG(T2.Price)': 43.5}] | Medium | false | false | false | false | false | false | false | true | 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 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 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 andrew@chinookcorp.com
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 nancy@chinookcorp.com
*/
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
*/ | How many customers does Steve Johnson support? | SELECT count(*) FROM employees AS T1 JOIN customers AS T2 ON T2.support_rep_id = T1.id WHERE T1.first_name = "Steve" AND T1.last_name = "Johnson"; | [{'count(*)': 18}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]How many customers are there?[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank[/SQL] | [QUESTION]How many customers are there?[/QUESTION]
[SQL]SELECT sum(no_of_customers) FROM bank[/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 rodriguez.nathanael@example.net 618 Webster Stream Apt. 161 None b4459ad261
2 Direct Debit Gage (402)890-2603x6005 stark.elna@example.net 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
*/ | What are the name and payment method of customers who have both mailshots in 'Order' outcome and mailshots in 'No Response' outcome. | SELECT T2.customer_name , T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'Order' INTERSECT SELECT T2.customer_name , T2.payment_method FROM mailshot_customers AS T1 JOIN customers AS T2 ON T1.customer_id = T2.customer_id WHERE T1.outcome_code = 'No Response' | [{'customer_name': 'Carlotta', 'payment_method': 'Direct Debit'}, {'customer_name': 'Wendell', 'payment_method': 'Credit Card'}] | Hard | false | false | false | false | false | false | false | false | true | 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
*/ | papers published at pldi 2015 | SELECT DISTINCT t1.paperid FROM venue AS t2 JOIN paper AS t1 ON t2.venueid = t1.venueid WHERE t1.year = 2015 AND t2.venuename = "pldi"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Medium | true | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]papers published in the last year[/QUESTION]
[SQL]SELECT DISTINCT paperid FROM paper WHERE YEAR = ( SELECT MAX ( YEAR ) FROM paper );[/SQL] | [QUESTION]papers published in the last year[/QUESTION]
[SQL]SELECT DISTINCT paperid FROM paper WHERE YEAR = ( SELECT MAX ( YEAR ) FROM paper );[/SQL] | [QUESTION]papers published in the last year[/QUESTION]
[SQL]SELECT DISTINCT paperid FROM paper WHERE YEAR = ( SELECT MAX ( YEAR ) FROM paper );[/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
*/ | How many total credits are offered by each department? | SELECT sum(credits) , dept_name FROM course GROUP BY dept_name | [{'sum(credits)': 40, 'dept_name': 'Accounting'}, {'sum(credits)': 37, 'dept_name': 'Astronomy'}, {'sum(credits)': 30, 'dept_name': 'Athletics'}, {'sum(credits)': 23, 'dept_name': 'Biology'}, {'sum(credits)': 34, 'dept_name': 'Civil Eng.'}, {'sum(credits)': 37, 'dept_name': 'Comp. Sci.'}, {'sum(credits)': 67, 'dept_name': 'Cybernetics'}, {'sum(credits)': 28, 'dept_name': 'Elec. Eng.'}, {'sum(credits)': 28, 'dept_name': 'English'}, {'sum(credits)': 49, 'dept_name': 'Finance'}, {'sum(credits)': 33, 'dept_name': 'Geology'}, {'sum(credits)': 29, 'dept_name': 'History'}, {'sum(credits)': 37, 'dept_name': 'Languages'}, {'sum(credits)': 20, 'dept_name': 'Marketing'}, {'sum(credits)': 34, 'dept_name': 'Math'}, {'sum(credits)': 40, 'dept_name': 'Mech. Eng.'}, {'sum(credits)': 38, 'dept_name': 'Physics'}, {'sum(credits)': 23, 'dept_name': 'Pol. Sci.'}, {'sum(credits)': 44, 'dept_name': 'Psychology'}, {'sum(credits)': 21, 'dept_name': 'Statistics'}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | [QUESTION]What are the total number of credits offered by each department?[/QUESTION]
[SQL]SELECT sum(T1.crs_credit) , T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code[/SQL] | [QUESTION]What are the total number of credits offered by each department?[/QUESTION]
[SQL]SELECT sum(T1.crs_credit) , T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code[/SQL] | [QUESTION]What are the total number of credits offered by each department?[/QUESTION]
[SQL]SELECT sum(T1.crs_credit) , T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code[/SQL] | [QUESTION]What are the total number of credits offered by each department?[/QUESTION]
[SQL]SELECT sum(T1.crs_credit) , T1.dept_code FROM course AS T1 JOIN CLASS AS T2 ON T1.crs_code = T2.crs_code GROUP BY T1.dept_code[/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
*/ | keyphrases Christof Dallermassl used in papers written last year | SELECT DISTINCT t2.keyphraseid FROM paper AS t3 JOIN paperkeyphrase AS t2 ON t3.paperid = t2.paperid JOIN writes AS t4 ON t4.paperid = t3.paperid JOIN author AS t1 ON t4.authorid = t1.authorid WHERE t1.authorname = "Christof Dallermassl" AND t3.year = 2000; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
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
*/ | name the rivers in illinois | SELECT river_name FROM river WHERE traverse = "illinois"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]what is the biggest american city in a state with a river[/QUESTION]
[SQL]SELECT DISTINCT t1.city_name FROM city AS t1 JOIN river AS t2 ON t2.traverse = t1.state_name WHERE t1.population = ( SELECT MAX ( t1.population ) FROM river AS t2 JOIN city AS t1 ON t2.traverse = t1.state_name );[/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
*/ | What is the most common result of the music festival? | SELECT RESULT FROM music_festival GROUP BY RESULT ORDER BY COUNT(*) DESC LIMIT 1 | [{'Result': 'Nominated'}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | ||||
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 people live in boulder | SELECT population FROM city WHERE city_name = "boulder"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | 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
*/ | Return the top 3 greatest support rates. | SELECT support_rate FROM candidate ORDER BY support_rate DESC LIMIT 3 | [{'Support_rate': 0.33}, {'Support_rate': 0.25}, {'Support_rate': 0.24}] | Easy | false | false | false | true | true | false | false | false | 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
*/ | recent papers by sanjeev arora | SELECT DISTINCT t1.keyphrasename , t3.year FROM paperkeyphrase AS t2 JOIN keyphrase AS t1 ON t2.keyphraseid = t1.keyphraseid JOIN paper AS t3 ON t3.paperid = t2.paperid JOIN writes AS t4 ON t4.paperid = t3.paperid JOIN author AS t5 ON t4.authorid = t5.authorid WHERE t5.authorname = "sanjeev arora" ORDER BY t3.year DESC; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | true | false | false | false | false | true | false | false | false | false | [QUESTION]return me the papers written by " H. V. Jagadish " and " Yunyao Li " on PVLDB after 2005 .[/QUESTION]
[SQL]SELECT t6.title FROM publication AS t6 JOIN journal AS t4 ON t6.jid = t4.jid JOIN writes AS t3 ON t3.pid = t6.pid JOIN writes AS t5 ON t5.pid = t6.pid JOIN author AS t1 ON t5.aid = t1.aid JOIN author AS t2 ON t3.aid = t2.aid WHERE t2.name = "H. V. Jagadish" AND t1.name = "Yunyao Li" AND t4.name = "PVLDB" AND t6.year > 2005;[/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
*/ | Show the name of the party that has the most delegates. | SELECT T2.Party FROM election AS T1 JOIN party AS T2 ON T1.Party = T2.Party_ID GROUP BY T1.Party ORDER BY COUNT(*) DESC LIMIT 1 | [{'Party': 'Democratic'}] | Medium | false | false | false | true | true | 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
*/ | How many members are there? | SELECT count(*) FROM member | [{'count(*)': 10}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many players are there?[/QUESTION]
[SQL]SELECT count(*) FROM players[/SQL] | [QUESTION]How many players are there?[/QUESTION]
[SQL]SELECT count(*) FROM players[/SQL] | [QUESTION]How many players are there?[/QUESTION]
[SQL]SELECT count(*) FROM players[/SQL] | [QUESTION]How many players are there?[/QUESTION]
[SQL]SELECT count(*) FROM players[/SQL] |
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 airlines does Russia has? | SELECT count(*) FROM airlines WHERE country = 'Russia' | [{'count(*)': 238}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the total number of airlines?[/QUESTION]
[SQL]SELECT count(*) FROM AIRLINES[/SQL] | [QUESTION]What is the total number of airlines?[/QUESTION]
[SQL]SELECT count(*) FROM AIRLINES[/SQL] | [QUESTION]What is the total number of airlines?[/QUESTION]
[SQL]SELECT count(*) FROM AIRLINES[/SQL] | [QUESTION]What is the total number of airlines?[/QUESTION]
[SQL]SELECT count(*) FROM AIRLINES[/SQL] |
behavior_monitoring |
CREATE TABLE "Addresses" (
address_id INTEGER,
line_1 VARCHAR(120),
line_2 VARCHAR(120),
line_3 VARCHAR(120),
city VARCHAR(80),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
other_address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
CREATE TABLE "Assessment_Notes" (
notes_id INTEGER NOT NULL,
student_id INTEGER,
teacher_id INTEGER NOT NULL,
date_of_notes DATETIME,
text_of_notes VARCHAR(255),
other_details VARCHAR(255),
FOREIGN KEY(teacher_id) REFERENCES "Teachers" (teacher_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id)
)
CREATE TABLE "Behavior_Incident" (
incident_id INTEGER,
incident_type_code VARCHAR(10) NOT NULL,
student_id INTEGER NOT NULL,
date_incident_start DATETIME,
date_incident_end DATETIME,
incident_summary VARCHAR(255),
recommendations VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (incident_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(incident_type_code) REFERENCES "Ref_Incident_Type" (incident_type_code)
)
CREATE TABLE "Detention" (
detention_id INTEGER,
detention_type_code VARCHAR(10) NOT NULL,
teacher_id INTEGER,
datetime_detention_start DATETIME,
datetime_detention_end DATETIME,
detention_summary VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (detention_id),
FOREIGN KEY(teacher_id) REFERENCES "Teachers" (teacher_id),
FOREIGN KEY(detention_type_code) REFERENCES "Ref_Detention_Type" (detention_type_code)
)
CREATE TABLE "Ref_Address_Types" (
address_type_code VARCHAR(15),
address_type_description VARCHAR(80),
PRIMARY KEY (address_type_code)
)
CREATE TABLE "Ref_Detention_Type" (
detention_type_code VARCHAR(10),
detention_type_description VARCHAR(80),
PRIMARY KEY (detention_type_code)
)
CREATE TABLE "Ref_Incident_Type" (
incident_type_code VARCHAR(10),
incident_type_description VARCHAR(80),
PRIMARY KEY (incident_type_code)
)
CREATE TABLE "Student_Addresses" (
student_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
date_address_to DATETIME,
monthly_rental DECIMAL(19, 4),
other_details VARCHAR(255),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Students" (
student_id INTEGER,
address_id INTEGER NOT NULL,
first_name VARCHAR(80),
middle_name VARCHAR(40),
last_name VARCHAR(40),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
date_first_rental DATETIME,
date_left_university DATETIME,
other_student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Students_in_Detention" (
student_id INTEGER NOT NULL,
detention_id INTEGER NOT NULL,
incident_id INTEGER NOT NULL,
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(detention_id) REFERENCES "Detention" (detention_id),
FOREIGN KEY(incident_id) REFERENCES "Behavior_Incident" (incident_id)
)
CREATE TABLE "Teachers" (
teacher_id INTEGER,
address_id INTEGER NOT NULL,
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
gender VARCHAR(1),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
other_details VARCHAR(255),
PRIMARY KEY (teacher_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
) |
CREATE TABLE "Addresses" (
address_id INTEGER,
line_1 VARCHAR(120),
line_2 VARCHAR(120),
line_3 VARCHAR(120),
city VARCHAR(80),
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 line_1 line_2 line_3 city zip_postcode state_province_county country other_address_details
1 020 Orie Canyon None None North Loyceville 197 Hawaii USA None
2 1333 Boyle Lane None None West Sean 937 Illinois USA None
*/
CREATE TABLE "Assessment_Notes" (
notes_id INTEGER NOT NULL,
student_id INTEGER,
teacher_id INTEGER NOT NULL,
date_of_notes DATETIME,
text_of_notes VARCHAR(255),
other_details VARCHAR(255),
FOREIGN KEY(teacher_id) REFERENCES "Teachers" (teacher_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id)
)
/*
2 rows from Assessment_Notes table:
notes_id student_id teacher_id date_of_notes text_of_notes other_details
1 7 3 1978-04-15 04:49:18 None None
2 11 10 2005-06-30 02:48:35 None None
*/
CREATE TABLE "Behavior_Incident" (
incident_id INTEGER,
incident_type_code VARCHAR(10) NOT NULL,
student_id INTEGER NOT NULL,
date_incident_start DATETIME,
date_incident_end DATETIME,
incident_summary VARCHAR(255),
recommendations VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (incident_id),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(incident_type_code) REFERENCES "Ref_Incident_Type" (incident_type_code)
)
/*
2 rows from Behavior_Incident table:
incident_id incident_type_code student_id date_incident_start date_incident_end incident_summary recommendations other_details
1 NOISE 6 2017-07-09 10:04:13 2018-03-08 14:08:54 None None None
2 DISTURB 13 2018-01-31 10:51:13 2018-03-18 18:40:05 None None None
*/
CREATE TABLE "Detention" (
detention_id INTEGER,
detention_type_code VARCHAR(10) NOT NULL,
teacher_id INTEGER,
datetime_detention_start DATETIME,
datetime_detention_end DATETIME,
detention_summary VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (detention_id),
FOREIGN KEY(teacher_id) REFERENCES "Teachers" (teacher_id),
FOREIGN KEY(detention_type_code) REFERENCES "Ref_Detention_Type" (detention_type_code)
)
/*
2 rows from Detention table:
detention_id detention_type_code teacher_id datetime_detention_start datetime_detention_end detention_summary other_details
1 AFTER 7 2017-09-05 00:38:25 2018-03-08 02:08:32 None None
2 AFTER 14 2018-01-10 08:09:02 2018-03-07 04:24:48 None None
*/
CREATE TABLE "Ref_Address_Types" (
address_type_code VARCHAR(15),
address_type_description VARCHAR(80),
PRIMARY KEY (address_type_code)
)
/*
2 rows from Ref_Address_Types table:
address_type_code address_type_description
BILL Billing
HOME Home or Residence
*/
CREATE TABLE "Ref_Detention_Type" (
detention_type_code VARCHAR(10),
detention_type_description VARCHAR(80),
PRIMARY KEY (detention_type_code)
)
/*
2 rows from Ref_Detention_Type table:
detention_type_code detention_type_description
BREAK During Break time
AFTER After School
*/
CREATE TABLE "Ref_Incident_Type" (
incident_type_code VARCHAR(10),
incident_type_description VARCHAR(80),
PRIMARY KEY (incident_type_code)
)
/*
2 rows from Ref_Incident_Type table:
incident_type_code incident_type_description
NOISE Noise
VIOLENCE Violence
*/
CREATE TABLE "Student_Addresses" (
student_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_address_from DATETIME NOT NULL,
date_address_to DATETIME,
monthly_rental DECIMAL(19, 4),
other_details VARCHAR(255),
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Student_Addresses table:
student_id address_id date_address_from date_address_to monthly_rental other_details
6 12 2017-10-16 13:56:34 2018-03-15 10:37:19 826.4319 house
3 18 2017-06-19 12:39:39 2018-03-02 00:19:57 1113.0996 house
*/
CREATE TABLE "Students" (
student_id INTEGER,
address_id INTEGER NOT NULL,
first_name VARCHAR(80),
middle_name VARCHAR(40),
last_name VARCHAR(40),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
date_first_rental DATETIME,
date_left_university DATETIME,
other_student_details VARCHAR(255),
PRIMARY KEY (student_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Students table:
student_id address_id first_name middle_name last_name cell_mobile_number email_address date_first_rental date_left_university other_student_details
1 19 Emma Frederic Rohan 235.899.9744 derrick.jenkins@example.com 2017-12-05 15:20:04 2018-03-03 03:33:05 None
2 9 Louvenia Fatima Hansen 1-247-673-8446 rohan.clarabelle@example.org 2017-08-08 22:30:36 2018-02-24 11:12:11 None
*/
CREATE TABLE "Students_in_Detention" (
student_id INTEGER NOT NULL,
detention_id INTEGER NOT NULL,
incident_id INTEGER NOT NULL,
FOREIGN KEY(student_id) REFERENCES "Students" (student_id),
FOREIGN KEY(detention_id) REFERENCES "Detention" (detention_id),
FOREIGN KEY(incident_id) REFERENCES "Behavior_Incident" (incident_id)
)
/*
2 rows from Students_in_Detention table:
student_id detention_id incident_id
3 15 1
8 13 3
*/
CREATE TABLE "Teachers" (
teacher_id INTEGER,
address_id INTEGER NOT NULL,
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
gender VARCHAR(1),
cell_mobile_number VARCHAR(40),
email_address VARCHAR(40),
other_details VARCHAR(255),
PRIMARY KEY (teacher_id),
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Teachers table:
teacher_id address_id first_name middle_name last_name gender cell_mobile_number email_address other_details
1 15 Lyla Wilson Medhurst 1 792.333.7714 ohammes@example.com None
2 7 Sid Tremayne Brakus 1 202.626.1698x9242 deborah37@example.com None
*/ | Return all detention summaries. | SELECT detention_summary FROM Detention | [{'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}, {'detention_summary': None}] | Easy | false | false | false | false | false | false | false | false | 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
*/ | In 2010 what journal published an article about Trophic Cascade ? | SELECT DISTINCT t3.journalid 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 = "Trophic Cascade" AND t3.year = 2010 GROUP BY t3.journalid; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | true | false | false | true | false | false | false | false | ||||
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 has the largest density | SELECT state_name FROM state WHERE density = ( SELECT MAX ( density ) FROM state ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] |
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 everette.goyette@example.org 07278206718 861-638-9797
2 10 Bad Customer 2015-11-16 22:52:14 1995-07-17 12:13:16 Genevieve Terry 7256.0 huel.jana@example.org +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
*/ | Which last names are both used by customers and by staff? | SELECT last_name FROM Customers INTERSECT SELECT last_name FROM Staff | [{'last_name': 'Mertz'}] | Hard | false | false | false | false | false | false | false | false | false | false | true | false | false | [QUESTION]What are the names and account balances of customers with the letter a in their names?[/QUESTION]
[SQL]SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'[/SQL] | [QUESTION]What are the names and account balances of customers with the letter a in their names?[/QUESTION]
[SQL]SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'[/SQL] | [QUESTION]What are the names and account balances of customers with the letter a in their names?[/QUESTION]
[SQL]SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'[/SQL] | [QUESTION]What are the names and account balances of customers with the letter a in their names?[/QUESTION]
[SQL]SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'[/SQL] |
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
*/ | List the names of all distinct medications, ordered in an alphabetical order. | SELECT DISTINCT name FROM medication ORDER BY name | [{'Name': 'Awakin'}, {'Name': 'Crescavitin'}, {'Name': 'Melioraurin'}, {'Name': 'Procrastin-X'}, {'Name': 'Thesisin'}] | Easy | true | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of all departments in alphabetical order?[/QUESTION]
[SQL]SELECT dept_name FROM department ORDER BY dept_name[/SQL] | [QUESTION]What are the names of all departments in alphabetical order?[/QUESTION]
[SQL]SELECT dept_name FROM department ORDER BY dept_name[/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 rivers are called colorado | SELECT COUNT ( river_name ) FROM river WHERE river_name = "colorado"; | [{'COUNT ( river_name )': 0}] | Easy | false | false | false | false | false | 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 everette.goyette@example.org 07278206718 861-638-9797
2 10 Bad Customer 2015-11-16 22:52:14 1995-07-17 12:13:16 Genevieve Terry 7256.0 huel.jana@example.org +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 are the phone numbers and email addresses of all customers who have an outstanding balance of more than 2000? | SELECT phone_number , email_address FROM Customers WHERE amount_outstanding > 2000; | [{'phone_number': '+14(5)2351480248', 'email_address': 'huel.jana@example.org'}, {'phone_number': '374-483-2758x85087', 'email_address': 'hilario.sporer@example.org'}, {'phone_number': '218.550.1362', 'email_address': 'afranecki@example.com'}, {'phone_number': '1-618-535-9750', 'email_address': 'asha.kilback@example.org'}, {'phone_number': '1-673-962-8158x7646', 'email_address': 'kozey.citlalli@example.org'}, {'phone_number': '(662)490-3108', 'email_address': 'mayert.judy@example.com'}, {'phone_number': '206-054-0689x05861', 'email_address': 'kroberts@example.org'}, {'phone_number': '753.921.0871', 'email_address': 'mariela28@example.org'}, {'phone_number': '(297)122-0086', 'email_address': 'karina.carroll@example.net'}, {'phone_number': '417.136.2900x672', 'email_address': 'myrl.lind@example.net'}, {'phone_number': '192-395-2411', 'email_address': 'wehner.harold@example.com'}, {'phone_number': '1-875-045-0806', 'email_address': 'ehowell@example.com'}, {'phone_number': '(729)396-4354x3576', 'email_address': 'kitty.hand@example.net'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?[/QUESTION]
[SQL]SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000[/SQL] | [QUESTION]What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?[/QUESTION]
[SQL]SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000[/SQL] | [QUESTION]What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?[/QUESTION]
[SQL]SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000[/SQL] | [QUESTION]What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?[/QUESTION]
[SQL]SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000[/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
*/ | which neighbourhood has the most number of businesses in Madison | SELECT t1.neighbourhood_name FROM neighbourhood AS t1 JOIN business AS t2 ON t1.business_id = t2.business_id WHERE t2.city = "Madison" GROUP BY t1.neighbourhood_name ORDER BY COUNT ( DISTINCT t2.name ) DESC LIMIT 1; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Medium | true | false | false | true | true | true | false | true | false | false | false | false | false | ||||
cre_Doc_Control_Systems |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
CREATE TABLE "Circulation_History" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
employee_id INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number, employee_id),
FOREIGN KEY(document_id, draft_number, copy_number) REFERENCES "Draft_Copies" (document_id, draft_number, copy_number),
FOREIGN KEY(employee_id) REFERENCES "Employees" (employee_id)
)
CREATE TABLE "Document_Drafts" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
draft_details VARCHAR(255),
PRIMARY KEY (document_id, draft_number),
FOREIGN KEY(document_id) REFERENCES "Documents" (document_id)
)
CREATE TABLE "Documents" (
document_id INTEGER NOT NULL,
document_status_code CHAR(15) NOT NULL,
document_type_code CHAR(15) NOT NULL,
shipping_agent_code CHAR(15),
receipt_date DATETIME,
receipt_number VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (document_id),
FOREIGN KEY(document_type_code) REFERENCES "Ref_Document_Types" (document_type_code),
FOREIGN KEY(document_status_code) REFERENCES "Ref_Document_Status" (document_status_code),
FOREIGN KEY(shipping_agent_code) REFERENCES "Ref_Shipping_Agents" (shipping_agent_code)
)
CREATE TABLE "Documents_Mailed" (
document_id INTEGER NOT NULL,
mailed_to_address_id INTEGER NOT NULL,
mailing_date DATETIME,
PRIMARY KEY (document_id, mailed_to_address_id),
FOREIGN KEY(document_id) REFERENCES "Documents" (document_id),
FOREIGN KEY(mailed_to_address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Draft_Copies" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number),
FOREIGN KEY(document_id, draft_number) REFERENCES "Document_Drafts" (document_id, draft_number)
)
CREATE TABLE "Employees" (
employee_id INTEGER NOT NULL,
role_code CHAR(15) NOT NULL,
employee_name VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (employee_id),
FOREIGN KEY(role_code) REFERENCES "Roles" (role_code)
)
CREATE TABLE "Ref_Document_Status" (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
CREATE TABLE "Ref_Document_Types" (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
CREATE TABLE "Ref_Shipping_Agents" (
shipping_agent_code CHAR(15) NOT NULL,
shipping_agent_name VARCHAR(255) NOT NULL,
shipping_agent_description VARCHAR(255) NOT NULL,
PRIMARY KEY (shipping_agent_code)
)
CREATE TABLE "Roles" (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
) |
CREATE TABLE "Addresses" (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
/*
2 rows from Addresses table:
address_id address_details
0 IT
1 MX
*/
CREATE TABLE "Circulation_History" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
employee_id INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number, employee_id),
FOREIGN KEY(document_id, draft_number, copy_number) REFERENCES "Draft_Copies" (document_id, draft_number, copy_number),
FOREIGN KEY(employee_id) REFERENCES "Employees" (employee_id)
)
/*
2 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
*/
CREATE TABLE "Document_Drafts" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
draft_details VARCHAR(255),
PRIMARY KEY (document_id, draft_number),
FOREIGN KEY(document_id) REFERENCES "Documents" (document_id)
)
/*
2 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
*/
CREATE TABLE "Documents" (
document_id INTEGER NOT NULL,
document_status_code CHAR(15) NOT NULL,
document_type_code CHAR(15) NOT NULL,
shipping_agent_code CHAR(15),
receipt_date DATETIME,
receipt_number VARCHAR(255),
other_details VARCHAR(255),
PRIMARY KEY (document_id),
FOREIGN KEY(document_type_code) REFERENCES "Ref_Document_Types" (document_type_code),
FOREIGN KEY(document_status_code) REFERENCES "Ref_Document_Status" (document_status_code),
FOREIGN KEY(shipping_agent_code) REFERENCES "Ref_Shipping_Agents" (shipping_agent_code)
)
/*
2 rows from Documents table:
document_id document_status_code document_type_code shipping_agent_code receipt_date receipt_number other_details
1 working CD UP 2008-04-21 20:42:25 19 z
2 done Paper US 1974-05-08 00:00:46 34 h
*/
CREATE TABLE "Documents_Mailed" (
document_id INTEGER NOT NULL,
mailed_to_address_id INTEGER NOT NULL,
mailing_date DATETIME,
PRIMARY KEY (document_id, mailed_to_address_id),
FOREIGN KEY(document_id) REFERENCES "Documents" (document_id),
FOREIGN KEY(mailed_to_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Documents_Mailed table:
document_id mailed_to_address_id mailing_date
2 8 1977-04-01 17:03:50
4 3 1992-11-07 15:03:41
*/
CREATE TABLE "Draft_Copies" (
document_id INTEGER NOT NULL,
draft_number INTEGER NOT NULL,
copy_number INTEGER NOT NULL,
PRIMARY KEY (document_id, draft_number, copy_number),
FOREIGN KEY(document_id, draft_number) REFERENCES "Document_Drafts" (document_id, draft_number)
)
/*
2 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
*/
CREATE TABLE "Employees" (
employee_id INTEGER NOT NULL,
role_code CHAR(15) NOT NULL,
employee_name VARCHAR(255),
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 other_details
1 ED Koby h
2 ED Kenyon f
*/
CREATE TABLE "Ref_Document_Status" (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
/*
2 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
*/
CREATE TABLE "Ref_Document_Types" (
document_type_code CHAR(15) 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_description
CD b
Paper u
*/
CREATE TABLE "Ref_Shipping_Agents" (
shipping_agent_code CHAR(15) NOT NULL,
shipping_agent_name VARCHAR(255) NOT NULL,
shipping_agent_description VARCHAR(255) NOT NULL,
PRIMARY KEY (shipping_agent_code)
)
/*
2 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
*/
CREATE TABLE "Roles" (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
/*
2 rows from Roles table:
role_code role_description
ED Editor
PT Photo
*/ | What are all role codes? | SELECT role_code FROM ROLES; | [{'role_code': 'ED'}, {'role_code': 'MG'}, {'role_code': 'PR'}, {'role_code': 'PT'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the different template type codes?[/QUESTION]
[SQL]SELECT DISTINCT template_type_code FROM Templates[/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
*/ | How many reviews has Niloofar written in 2015 | SELECT COUNT ( DISTINCT t1.text ) FROM USER AS t2 JOIN review AS t1 ON t2.user_id = t1.user_id WHERE t1.year = 2015 AND t2.name = "Niloofar"; | [{'COUNT ( DISTINCT t1.text )': 0}] | Medium | true | false | false | false | false | false | false | true | false | false | false | false | false | ||||
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
*/ | When did Linda Smith visit Subway? | SELECT TIME FROM Student JOIN Visits_Restaurant ON Student.StuID = Visits_Restaurant.StuID JOIN Restaurant ON Visits_Restaurant.ResID = Restaurant.ResID WHERE Student.Fname = "Linda" AND Student.Lname = "Smith" AND Restaurant.ResName = "Subway"; | [{'Time': '2017-10-09 18:15:00'}] | Hard | false | false | false | false | false | false | false | false | true | false | false | false | false | ||||
company_employee |
CREATE TABLE company (
"Company_ID" REAL,
"Name" TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_in_Billion" REAL,
"Profits_in_Billion" REAL,
"Assets_in_Billion" REAL,
"Market_Value_in_Billion" REAL,
PRIMARY KEY ("Company_ID")
)
CREATE TABLE employment (
"Company_ID" INTEGER,
"People_ID" INTEGER,
"Year_working" INTEGER,
PRIMARY KEY ("Company_ID", "People_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID"),
FOREIGN KEY("Company_ID") REFERENCES company ("Company_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Age" INTEGER,
"Name" TEXT,
"Nationality" TEXT,
"Graduation_College" TEXT,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE company (
"Company_ID" REAL,
"Name" TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_in_Billion" REAL,
"Profits_in_Billion" REAL,
"Assets_in_Billion" REAL,
"Market_Value_in_Billion" REAL,
PRIMARY KEY ("Company_ID")
)
/*
2 rows from company table:
Company_ID Name Headquarters Industry Sales_in_Billion Profits_in_Billion Assets_in_Billion Market_Value_in_Billion
1.0 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4
2.0 JPMorgan Chase USA Banking 110.8 19.0 2265.8 170.1
*/
CREATE TABLE employment (
"Company_ID" INTEGER,
"People_ID" INTEGER,
"Year_working" INTEGER,
PRIMARY KEY ("Company_ID", "People_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID"),
FOREIGN KEY("Company_ID") REFERENCES company ("Company_ID")
)
/*
2 rows from employment table:
Company_ID People_ID Year_working
11 3 2
13 2 3
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Age" INTEGER,
"Name" TEXT,
"Nationality" TEXT,
"Graduation_College" TEXT,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Age Name Nationality Graduation_College
1 27 Reggie Lewis United States Northeastern
2 25 Brad Lohaus United States Iowa
*/ | Show the headquarters that have at least two companies. | SELECT Headquarters FROM company GROUP BY Headquarters HAVING COUNT(*) >= 2 | [{'Headquarters': 'China'}, {'Headquarters': 'UK'}, {'Headquarters': 'USA'}] | Easy | false | false | false | false | false | true | true | false | false | false | false | false | false | [QUESTION]Count the number of employees for each city.[/QUESTION]
[SQL]SELECT count(*) , city FROM employee GROUP BY city[/SQL] |
|||
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 number of distinct amenities. | SELECT count(*) FROM dorm_amenity | [{'count(*)': 12}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Count the number of distinct store locations.[/QUESTION]
[SQL]SELECT count(DISTINCT LOCATION) FROM shop[/SQL] | [QUESTION]Count the number of distinct store locations.[/QUESTION]
[SQL]SELECT count(DISTINCT LOCATION) FROM shop[/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 is the name of the project that requires the fewest number of hours, and the names of the scientists assigned to it? | SELECT T2.name , T3.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T2.hours = (SELECT min(hours) FROM projects) | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | false | false | false | false | false | false | false | false | true | false | false | false | false | ||||
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 longest river flowing through texas | SELECT river_name FROM river WHERE LENGTH = ( SELECT MAX ( LENGTH ) FROM river WHERE traverse = "texas" ) AND traverse = "texas"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | ||||
inn_1 |
CREATE TABLE "Reservations" (
"Code" INTEGER,
"Room" TEXT,
"CheckIn" TEXT,
"CheckOut" TEXT,
"Rate" REAL,
"LastName" TEXT,
"FirstName" TEXT,
"Adults" INTEGER,
"Kids" INTEGER,
PRIMARY KEY ("Code"),
FOREIGN KEY("Room") REFERENCES "Rooms" ("RoomId")
)
CREATE TABLE "Rooms" (
"RoomId" TEXT,
"roomName" TEXT,
beds INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
decor TEXT,
PRIMARY KEY ("RoomId")
) |
CREATE TABLE "Reservations" (
"Code" INTEGER,
"Room" TEXT,
"CheckIn" TEXT,
"CheckOut" TEXT,
"Rate" REAL,
"LastName" TEXT,
"FirstName" TEXT,
"Adults" INTEGER,
"Kids" INTEGER,
PRIMARY KEY ("Code"),
FOREIGN KEY("Room") REFERENCES "Rooms" ("RoomId")
)
/*
2 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
*/
CREATE TABLE "Rooms" (
"RoomId" TEXT,
"roomName" TEXT,
beds INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
decor TEXT,
PRIMARY KEY ("RoomId")
)
/*
2 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
*/ | Which room has the largest number of reservations? | SELECT T2.roomName FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY count(*) DESC LIMIT 1; | [{'roomName': 'Convoke and sanguine'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | [QUESTION]What is the total number of residents for the districts with the 3 largest areas?[/QUESTION]
[SQL]SELECT sum(city_population) FROM district ORDER BY city_area DESC LIMIT 3[/SQL] | [QUESTION]What is the total number of residents for the districts with the 3 largest areas?[/QUESTION]
[SQL]SELECT sum(city_population) FROM district ORDER BY city_area DESC LIMIT 3[/SQL] |
||
inn_1 |
CREATE TABLE "Reservations" (
"Code" INTEGER,
"Room" TEXT,
"CheckIn" TEXT,
"CheckOut" TEXT,
"Rate" REAL,
"LastName" TEXT,
"FirstName" TEXT,
"Adults" INTEGER,
"Kids" INTEGER,
PRIMARY KEY ("Code"),
FOREIGN KEY("Room") REFERENCES "Rooms" ("RoomId")
)
CREATE TABLE "Rooms" (
"RoomId" TEXT,
"roomName" TEXT,
beds INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
decor TEXT,
PRIMARY KEY ("RoomId")
) |
CREATE TABLE "Reservations" (
"Code" INTEGER,
"Room" TEXT,
"CheckIn" TEXT,
"CheckOut" TEXT,
"Rate" REAL,
"LastName" TEXT,
"FirstName" TEXT,
"Adults" INTEGER,
"Kids" INTEGER,
PRIMARY KEY ("Code"),
FOREIGN KEY("Room") REFERENCES "Rooms" ("RoomId")
)
/*
2 rows from Reservations table:
Code Room CheckIn CheckOut Rate LastName FirstName Adults Kids
10105 HBB 23-OCT-10 25-OCT-10 100.0 SELBIG CONRAD 1 0
10183 IBD 19-SEP-10 20-SEP-10 150.0 GABLER DOLLIE 2 0
*/
CREATE TABLE "Rooms" (
"RoomId" TEXT,
"roomName" TEXT,
beds INTEGER,
"bedType" TEXT,
"maxOccupancy" INTEGER,
"basePrice" INTEGER,
decor TEXT,
PRIMARY KEY ("RoomId")
)
/*
2 rows from Rooms table:
RoomId roomName beds bedType maxOccupancy basePrice decor
RND Recluse and defiance 1 King 2 150 modern
IBS Interim but salutary 1 King 2 150 traditional
*/ | Return the decor of the room named "Recluse and defiance". | SELECT decor FROM Rooms WHERE roomName = "Recluse and defiance"; | [{'decor': 'modern'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
products_gen_characteristics |
CREATE TABLE "Characteristics" (
characteristic_id INTEGER,
characteristic_type_code VARCHAR(15) NOT NULL,
characteristic_data_type VARCHAR(10),
characteristic_name VARCHAR(80),
other_characteristic_details VARCHAR(255),
PRIMARY KEY (characteristic_id),
FOREIGN KEY(characteristic_type_code) REFERENCES "Ref_Characteristic_Types" (characteristic_type_code)
)
CREATE TABLE "Product_Characteristics" (
product_id INTEGER NOT NULL,
characteristic_id INTEGER NOT NULL,
product_characteristic_value VARCHAR(50),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(characteristic_id) REFERENCES "Characteristics" (characteristic_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
color_code VARCHAR(15) NOT NULL,
product_category_code VARCHAR(15) NOT NULL,
product_name VARCHAR(80),
typical_buying_price VARCHAR(20),
typical_selling_price VARCHAR(20),
product_description VARCHAR(255),
other_product_details VARCHAR(255),
PRIMARY KEY (product_id),
FOREIGN KEY(color_code) REFERENCES "Ref_Colors" (color_code),
FOREIGN KEY(product_category_code) REFERENCES "Ref_Product_Categories" (product_category_code)
)
CREATE TABLE "Ref_Characteristic_Types" (
characteristic_type_code VARCHAR(15),
characteristic_type_description VARCHAR(80),
PRIMARY KEY (characteristic_type_code)
)
CREATE TABLE "Ref_Colors" (
color_code VARCHAR(15),
color_description VARCHAR(80),
PRIMARY KEY (color_code)
)
CREATE TABLE "Ref_Product_Categories" (
product_category_code VARCHAR(15),
product_category_description VARCHAR(80),
unit_of_measure VARCHAR(20),
PRIMARY KEY (product_category_code)
) |
CREATE TABLE "Characteristics" (
characteristic_id INTEGER,
characteristic_type_code VARCHAR(15) NOT NULL,
characteristic_data_type VARCHAR(10),
characteristic_name VARCHAR(80),
other_characteristic_details VARCHAR(255),
PRIMARY KEY (characteristic_id),
FOREIGN KEY(characteristic_type_code) REFERENCES "Ref_Characteristic_Types" (characteristic_type_code)
)
/*
2 rows from Characteristics table:
characteristic_id characteristic_type_code characteristic_data_type characteristic_name other_characteristic_details
1 Grade numquam slow None
2 Grade doloribus fast None
*/
CREATE TABLE "Product_Characteristics" (
product_id INTEGER NOT NULL,
characteristic_id INTEGER NOT NULL,
product_characteristic_value VARCHAR(50),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(characteristic_id) REFERENCES "Characteristics" (characteristic_id)
)
/*
2 rows from Product_Characteristics table:
product_id characteristic_id product_characteristic_value
13 13 low
11 2 low
*/
CREATE TABLE "Products" (
product_id INTEGER,
color_code VARCHAR(15) NOT NULL,
product_category_code VARCHAR(15) NOT NULL,
product_name VARCHAR(80),
typical_buying_price VARCHAR(20),
typical_selling_price VARCHAR(20),
product_description VARCHAR(255),
other_product_details VARCHAR(255),
PRIMARY KEY (product_id),
FOREIGN KEY(color_code) REFERENCES "Ref_Colors" (color_code),
FOREIGN KEY(product_category_code) REFERENCES "Ref_Product_Categories" (product_category_code)
)
/*
2 rows from Products table:
product_id color_code product_category_code product_name typical_buying_price typical_selling_price product_description other_product_details
1 4 Spices cumin 2878.3 et None
2 2 Spices peper 352447.2874677 1892070.2803543 rerum None
*/
CREATE TABLE "Ref_Characteristic_Types" (
characteristic_type_code VARCHAR(15),
characteristic_type_description VARCHAR(80),
PRIMARY KEY (characteristic_type_code)
)
/*
2 rows from Ref_Characteristic_Types table:
characteristic_type_code characteristic_type_description
Grade Grade
Purity Purity
*/
CREATE TABLE "Ref_Colors" (
color_code VARCHAR(15),
color_description VARCHAR(80),
PRIMARY KEY (color_code)
)
/*
2 rows from Ref_Colors table:
color_code color_description
9 red
5 green
*/
CREATE TABLE "Ref_Product_Categories" (
product_category_code VARCHAR(15),
product_category_description VARCHAR(80),
unit_of_measure VARCHAR(20),
PRIMARY KEY (product_category_code)
)
/*
2 rows from Ref_Product_Categories table:
product_category_code product_category_description unit_of_measure
Herbs Herbs Handful
Seeds Seeds Weight - pound,kilo.
*/ | How many products are in the 'Spices' category and have a typical price of over 1000? | SELECT count(*) FROM products WHERE product_category_code = "Spices" AND typical_buying_price > 1000 | [{'count(*)': 2}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the minimum and maximum number of products across all the shops?[/QUESTION]
[SQL]SELECT min(Number_products) , max(Number_products) FROM shop[/SQL] |
|||
race_track |
CREATE TABLE race (
"Race_ID" INTEGER,
"Name" TEXT,
"Class" TEXT,
"Date" TEXT,
"Track_ID" TEXT,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY("Track_ID") REFERENCES track ("Track_ID")
)
CREATE TABLE track (
"Track_ID" INTEGER,
"Name" TEXT,
"Location" TEXT,
"Seating" REAL,
"Year_Opened" REAL,
PRIMARY KEY ("Track_ID")
) |
CREATE TABLE race (
"Race_ID" INTEGER,
"Name" TEXT,
"Class" TEXT,
"Date" TEXT,
"Track_ID" TEXT,
PRIMARY KEY ("Race_ID"),
FOREIGN KEY("Track_ID") REFERENCES track ("Track_ID")
)
/*
2 rows from race table:
Race_ID Name Class Date Track_ID
1 Rolex 24 At Daytona DP/GT January 26 January 27 1
2 Gainsco Grand Prix of Miami DP/GT March 29 2
*/
CREATE TABLE track (
"Track_ID" INTEGER,
"Name" TEXT,
"Location" TEXT,
"Seating" REAL,
"Year_Opened" REAL,
PRIMARY KEY ("Track_ID")
)
/*
2 rows from track table:
Track_ID Name Location Seating Year_Opened
1 Auto Club Speedway Fontana, CA 92000.0 1997.0
2 Chicagoland Speedway Joliet, IL 75000.0 2001.0
*/ | Show the name and location for all tracks. | SELECT name , LOCATION FROM track | [{'Name': 'Auto Club Speedway', 'Location': 'Fontana, CA'}, {'Name': 'Chicagoland Speedway', 'Location': 'Joliet, IL'}, {'Name': 'Darlington Raceway', 'Location': 'Darlington, SC'}, {'Name': 'Daytona International Speedway', 'Location': 'Daytona Beach, FL'}, {'Name': 'Homestead-Miami Speedway', 'Location': 'Homestead, FL'}, {'Name': 'Kansas Speedway', 'Location': 'Kansas City, KS'}, {'Name': 'Martinsville Speedway', 'Location': 'Ridgeway, VA'}, {'Name': 'Michigan International Speedway', 'Location': 'Brooklyn, MI'}, {'Name': 'Phoenix International Raceway', 'Location': 'Avondale, AZ'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
party_people |
CREATE TABLE member (
"Member_ID" INTEGER,
"Member_Name" TEXT,
"Party_ID" TEXT,
"In_office" TEXT,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY("Party_ID") REFERENCES party ("Party_ID")
)
CREATE TABLE party (
"Party_ID" INTEGER,
"Minister" TEXT,
"Took_office" TEXT,
"Left_office" TEXT,
"Region_ID" INTEGER,
"Party_name" TEXT,
PRIMARY KEY ("Party_ID"),
FOREIGN KEY("Region_ID") REFERENCES region ("Region_ID")
)
CREATE TABLE party_events (
"Event_ID" INTEGER,
"Event_Name" TEXT,
"Party_ID" INTEGER,
"Member_in_charge_ID" INTEGER,
PRIMARY KEY ("Event_ID"),
FOREIGN KEY("Member_in_charge_ID") REFERENCES member ("Member_ID"),
FOREIGN KEY("Party_ID") REFERENCES party ("Party_ID")
)
CREATE TABLE region (
"Region_ID" INTEGER,
"Region_name" TEXT,
"Date" TEXT,
"Label" TEXT,
"Format" TEXT,
"Catalogue" TEXT,
PRIMARY KEY ("Region_ID")
) |
CREATE TABLE member (
"Member_ID" INTEGER,
"Member_Name" TEXT,
"Party_ID" TEXT,
"In_office" TEXT,
PRIMARY KEY ("Member_ID"),
FOREIGN KEY("Party_ID") REFERENCES party ("Party_ID")
)
/*
2 rows from member table:
Member_ID Member_Name Party_ID In_office
1 Hon Tony Abbott 3 1994–present
2 Hon Dick Adams 2 1993–2013
*/
CREATE TABLE party (
"Party_ID" INTEGER,
"Minister" TEXT,
"Took_office" TEXT,
"Left_office" TEXT,
"Region_ID" INTEGER,
"Party_name" TEXT,
PRIMARY KEY ("Party_ID"),
FOREIGN KEY("Region_ID") REFERENCES region ("Region_ID")
)
/*
2 rows from party table:
Party_ID Minister Took_office Left_office Region_ID Party_name
1 Dr. Kwame Nkrumah (MP) 1957 1958 1 Convention Peoples Party
2 Kojo Botsio (MP) 1958 1959 2 Progress Party
*/
CREATE TABLE party_events (
"Event_ID" INTEGER,
"Event_Name" TEXT,
"Party_ID" INTEGER,
"Member_in_charge_ID" INTEGER,
PRIMARY KEY ("Event_ID"),
FOREIGN KEY("Member_in_charge_ID") REFERENCES member ("Member_ID"),
FOREIGN KEY("Party_ID") REFERENCES party ("Party_ID")
)
/*
2 rows from party_events table:
Event_ID Event_Name Party_ID Member_in_charge_ID
1 Annaual Meeting 1 4
2 Conference 1 12
*/
CREATE TABLE region (
"Region_ID" INTEGER,
"Region_name" TEXT,
"Date" TEXT,
"Label" TEXT,
"Format" TEXT,
"Catalogue" TEXT,
PRIMARY KEY ("Region_ID")
)
/*
2 rows from region table:
Region_ID Region_name Date Label Format Catalogue
1 United Kingdom 1 July 2002 Parlophone CD 540 3622
2 United Kingdom 1 July 2002 Parlophone 2× LP 539 9821
*/ | What is the name of member in charge of greatest number of events? | SELECT T1.member_name FROM member AS T1 JOIN party_events AS T2 ON T1.member_id = T2.member_in_charge_id GROUP BY T2.member_in_charge_id ORDER BY count(*) DESC LIMIT 1 | [{'Member_Name': 'Hon John Anderson'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
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
*/ | Which tourist attractions are related to royal family? Tell me their details and how we can get there. | SELECT T1.Royal_Family_Details , T2.How_to_Get_There FROM ROYAL_FAMILY AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Royal_Family_ID = T2.Tourist_Attraction_ID | [{'Royal_Family_Details': None, 'How_to_Get_There': 'bus'}, {'Royal_Family_Details': None, 'How_to_Get_There': 'shuttle'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
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
*/ | kentucky borders how many states | SELECT COUNT ( border ) FROM border_info WHERE state_name = "kentucky"; | [{'COUNT ( border )': 0}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] |
journal_committee |
CREATE TABLE editor (
"Editor_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
PRIMARY KEY ("Editor_ID")
)
CREATE TABLE journal (
"Journal_ID" INTEGER,
"Date" TEXT,
"Theme" TEXT,
"Sales" INTEGER,
PRIMARY KEY ("Journal_ID")
)
CREATE TABLE journal_committee (
"Editor_ID" INTEGER,
"Journal_ID" INTEGER,
"Work_Type" TEXT,
PRIMARY KEY ("Editor_ID", "Journal_ID"),
FOREIGN KEY("Journal_ID") REFERENCES journal ("Journal_ID"),
FOREIGN KEY("Editor_ID") REFERENCES editor ("Editor_ID")
) |
CREATE TABLE editor (
"Editor_ID" INTEGER,
"Name" TEXT,
"Age" REAL,
PRIMARY KEY ("Editor_ID")
)
/*
2 rows from editor table:
Editor_ID Name Age
1 Kamila Porczyk 34.0
2 Anna Powierza 35.0
*/
CREATE TABLE journal (
"Journal_ID" INTEGER,
"Date" TEXT,
"Theme" TEXT,
"Sales" INTEGER,
PRIMARY KEY ("Journal_ID")
)
/*
2 rows from journal table:
Journal_ID Date Theme Sales
1 September 9, 2001 Miami Dolphins 798
2 September 23, 2001 at Jacksonville Jaguars 994
*/
CREATE TABLE journal_committee (
"Editor_ID" INTEGER,
"Journal_ID" INTEGER,
"Work_Type" TEXT,
PRIMARY KEY ("Editor_ID", "Journal_ID"),
FOREIGN KEY("Journal_ID") REFERENCES journal ("Journal_ID"),
FOREIGN KEY("Editor_ID") REFERENCES editor ("Editor_ID")
)
/*
2 rows from journal_committee table:
Editor_ID Journal_ID Work_Type
1 13 Photo
8 17 Article
*/ | Show the names of editors of age either 24 or 25. | SELECT Name FROM editor WHERE Age = 24 OR Age = 25 | [{'Name': 'Władysław Grzywna'}, {'Name': 'Mariusz Zalejski'}] | Easy | false | false | false | 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] | [QUESTION]Show the name of teachers aged either 32 or 33?[/QUESTION]
[SQL]SELECT Name FROM teacher WHERE Age = 32 OR Age = 33[/SQL] |
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 margarett.vonrueden@example.com
2 Credit Card 665 Chauncey 8408 Lindsay Court
East Dasiabury, IL 72656-3552 +41(8)1897032009 stiedemann.sigrid@example.com
*/
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 bmaggio@example.com
2 3 store_name 082 Purdy Expressway
O'Connellshire, IL 31732 877-917-5029 larissa10@example.org
*/
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
*/ | What is the name and job title of the staff who was assigned the latest? | SELECT T1.staff_name , T2.job_title_code FROM staff AS T1 JOIN staff_department_assignments AS T2 ON T1.staff_id = T2.staff_id ORDER BY T2.date_assigned_to DESC LIMIT 1 | [{'staff_name': 'Katelynn', 'job_title_code': 'Clerical Staff'}] | Medium | false | false | false | true | true | false | false | true | 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] |
|
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 name and ID of the product whose total order quantity is the largest. | SELECT t2.product_details , t2.product_id FROM order_items AS t1 JOIN products AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_id ORDER BY sum(t1.order_quantity) LIMIT 1 | [{'product_details': 'Americano', 'product_id': 1}] | Medium | false | false | false | true | true | true | false | true | 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] |
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
*/ | For each grade, return the grade number, the number of classrooms used for the grade, and the total number of students enrolled in the grade. | SELECT grade , count(DISTINCT classroom) , count(*) FROM list GROUP BY grade | [{'Grade': 0, 'count(DISTINCT classroom)': 3, 'count(*)': 16}, {'Grade': 1, 'count(DISTINCT classroom)': 2, 'count(*)': 12}, {'Grade': 2, 'count(DISTINCT classroom)': 1, 'count(*)': 3}, {'Grade': 3, 'count(DISTINCT classroom)': 1, 'count(*)': 6}, {'Grade': 4, 'count(DISTINCT classroom)': 3, 'count(*)': 12}, {'Grade': 5, 'count(DISTINCT classroom)': 1, 'count(*)': 8}, {'Grade': 6, 'count(DISTINCT classroom)': 1, 'count(*)': 3}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | [QUESTION]Show the number of high schoolers for each grade.[/QUESTION]
[SQL]SELECT grade , count(*) FROM Highschooler GROUP BY grade[/SQL] | [QUESTION]Show the number of high schoolers for each grade.[/QUESTION]
[SQL]SELECT grade , count(*) FROM Highschooler GROUP BY grade[/SQL] | [QUESTION]Show the number of high schoolers for each grade.[/QUESTION]
[SQL]SELECT grade , count(*) FROM Highschooler GROUP BY grade[/SQL] | [QUESTION]Show the number of high schoolers for each grade.[/QUESTION]
[SQL]SELECT grade , count(*) FROM Highschooler GROUP BY grade[/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
*/ | Show the name and population of the country that has the highest roller coaster. | SELECT T1.Name , T1.population FROM country AS T1 JOIN roller_coaster AS T2 ON T1.Country_ID = T2.Country_ID ORDER BY T2.Height DESC LIMIT 1 | [{'Name': 'Sweden', 'Population': 9047752}] | Medium | false | false | false | true | true | false | false | true | 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
*/ | Which physicians have never taken any appointment? Find their names. | SELECT name FROM physician EXCEPT SELECT T2.name FROM appointment AS T1 JOIN physician AS T2 ON T1.Physician = T2.EmployeeID | [{'Name': 'Bob Kelso'}, {'Name': 'John Wen'}, {'Name': 'Keith Dudemeister'}, {'Name': 'Todd Quinlan'}] | Hard | false | false | false | false | false | false | false | true | false | false | false | true | 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] |
|
cre_Drama_Workshop_Groups |
CREATE TABLE "Addresses" (
"Address_ID" VARCHAR(100) NOT NULL,
"Line_1" VARCHAR(255),
"Line_2" VARCHAR(255),
"City_Town" VARCHAR(255),
"State_County" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Address_ID"),
UNIQUE ("Address_ID")
)
CREATE TABLE "Bookings" (
"Booking_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Workshop_Group_ID" VARCHAR(100) NOT NULL,
"Status_Code" CHAR(15) NOT NULL,
"Store_ID" INTEGER NOT NULL,
"Order_Date" DATETIME NOT NULL,
"Planned_Delivery_Date" DATETIME NOT NULL,
"Actual_Delivery_Date" DATETIME NOT NULL,
"Other_Order_Details" VARCHAR(255),
PRIMARY KEY ("Booking_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Clients" ("Client_ID"),
FOREIGN KEY("Workshop_Group_ID") REFERENCES "Drama_Workshop_Groups" ("Workshop_Group_ID"),
UNIQUE ("Booking_ID")
)
CREATE TABLE "Bookings_Services" (
"Order_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
PRIMARY KEY ("Order_ID", "Product_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID"),
FOREIGN KEY("Product_ID") REFERENCES "Services" ("Service_ID")
)
CREATE TABLE "Clients" (
"Client_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Email_Address" VARCHAR(255),
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Client_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Client_ID")
)
CREATE TABLE "Customer_Orders" (
"Order_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Store_ID" INTEGER NOT NULL,
"Order_Date" DATETIME NOT NULL,
"Planned_Delivery_Date" DATETIME NOT NULL,
"Actual_Delivery_Date" DATETIME NOT NULL,
"Other_Order_Details" VARCHAR(255),
PRIMARY KEY ("Order_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Customers" ("Customer_ID"),
FOREIGN KEY("Store_ID") REFERENCES "Stores" ("Store_ID"),
UNIQUE ("Order_ID")
)
CREATE TABLE "Customers" (
"Customer_ID" VARCHAR(100) NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Customer_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Customer_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Customer_ID")
)
CREATE TABLE "Drama_Workshop_Groups" (
"Workshop_Group_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Currency_Code" CHAR(15) NOT NULL,
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Store_Name" VARCHAR(255),
"Store_Phone" VARCHAR(255),
"Store_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Workshop_Group_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Workshop_Group_ID")
)
CREATE TABLE "Invoice_Items" (
"Invoice_Item_ID" INTEGER NOT NULL,
"Invoice_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
"Order_Item_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" INTEGER,
"Other_Item_Details" VARCHAR(255),
PRIMARY KEY ("Invoice_Item_ID"),
FOREIGN KEY("Order_Item_ID") REFERENCES "Order_Items" ("Order_Item_ID"),
FOREIGN KEY("Invoice_ID") REFERENCES "Invoices" ("Invoice_ID"),
FOREIGN KEY("Order_ID", "Product_ID") REFERENCES "Bookings_Services" ("Order_ID", "Product_ID")
)
CREATE TABLE "Invoices" (
"Invoice_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
payment_method_code CHAR(15),
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" VARCHAR(288),
"Other_Item_Details" VARCHAR(255),
"Order_Item_ID" INTEGER NOT NULL,
PRIMARY KEY ("Invoice_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Customer_Orders" ("Order_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID"),
FOREIGN KEY(payment_method_code) REFERENCES "Ref_Payment_Methods" (payment_method_code)
)
CREATE TABLE "Marketing_Regions" (
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Marketing_Region_Name" VARCHAR(255) NOT NULL,
"Marketing_Region_Descriptrion" VARCHAR(255) NOT NULL,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Marketing_Region_Code"),
UNIQUE ("Marketing_Region_Code")
)
CREATE TABLE "Order_Items" (
"Order_Item_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" VARCHAR(288),
"Other_Item_Details" VARCHAR(255),
PRIMARY KEY ("Order_Item_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Customer_Orders" ("Order_ID"),
FOREIGN KEY("Product_ID") REFERENCES "Products" ("Product_ID")
)
CREATE TABLE "Performers" (
"Performer_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Customer_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Performer_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Performer_ID")
)
CREATE TABLE "Performers_in_Bookings" (
"Order_ID" INTEGER NOT NULL,
"Performer_ID" INTEGER NOT NULL,
PRIMARY KEY ("Order_ID", "Performer_ID"),
FOREIGN KEY("Performer_ID") REFERENCES "Performers" ("Performer_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID")
)
CREATE TABLE "Products" (
"Product_ID" VARCHAR(100) NOT NULL,
"Product_Name" VARCHAR(255),
"Product_Price" DECIMAL(20, 4),
"Product_Description" VARCHAR(255),
"Other_Product_Service_Details" VARCHAR(255),
PRIMARY KEY ("Product_ID"),
UNIQUE ("Product_ID")
)
CREATE TABLE "Ref_Payment_Methods" (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
)
CREATE TABLE "Ref_Service_Types" (
"Service_Type_Code" CHAR(15) NOT NULL,
"Parent_Service_Type_Code" CHAR(15),
"Service_Type_Description" VARCHAR(255),
PRIMARY KEY ("Service_Type_Code"),
UNIQUE ("Service_Type_Code")
)
CREATE TABLE "Services" (
"Service_ID" INTEGER NOT NULL,
"Service_Type_Code" CHAR(15),
"Workshop_Group_ID" INTEGER NOT NULL,
"Product_Description" VARCHAR(255),
"Product_Name" VARCHAR(255),
"Product_Price" DECIMAL(20, 4),
"Other_Product_Service_Details" VARCHAR(255),
PRIMARY KEY ("Service_ID"),
FOREIGN KEY("Workshop_Group_ID") REFERENCES "Drama_Workshop_Groups" ("Workshop_Group_ID"),
FOREIGN KEY("Service_Type_Code") REFERENCES "Ref_Service_Types" ("Service_Type_Code"),
UNIQUE ("Service_ID")
)
CREATE TABLE "Stores" (
"Store_ID" VARCHAR(100) NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Store_Name" VARCHAR(255),
"Store_Phone" VARCHAR(255),
"Store_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Store_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
FOREIGN KEY("Marketing_Region_Code") REFERENCES "Marketing_Regions" ("Marketing_Region_Code"),
UNIQUE ("Store_ID")
) |
CREATE TABLE "Addresses" (
"Address_ID" VARCHAR(100) NOT NULL,
"Line_1" VARCHAR(255),
"Line_2" VARCHAR(255),
"City_Town" VARCHAR(255),
"State_County" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Address_ID"),
UNIQUE ("Address_ID")
)
/*
2 rows from Addresses table:
Address_ID Line_1 Line_2 City_Town State_County Other_Details
110 4753 Dach Highway Suite 846 Feliciaberg Florida None
124 391 Vandervort Fall Apt. 446 Apt. 107 West Sherwoodstad Indiana None
*/
CREATE TABLE "Bookings" (
"Booking_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Workshop_Group_ID" VARCHAR(100) NOT NULL,
"Status_Code" CHAR(15) NOT NULL,
"Store_ID" INTEGER NOT NULL,
"Order_Date" DATETIME NOT NULL,
"Planned_Delivery_Date" DATETIME NOT NULL,
"Actual_Delivery_Date" DATETIME NOT NULL,
"Other_Order_Details" VARCHAR(255),
PRIMARY KEY ("Booking_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Clients" ("Client_ID"),
FOREIGN KEY("Workshop_Group_ID") REFERENCES "Drama_Workshop_Groups" ("Workshop_Group_ID"),
UNIQUE ("Booking_ID")
)
/*
2 rows from Bookings table:
Booking_ID Customer_ID Workshop_Group_ID Status_Code Store_ID Order_Date Planned_Delivery_Date Actual_Delivery_Date Other_Order_Details
1 938 140 good 8 2016-12-12 10:43:01 2013-03-10 18:47:05 1997-11-21 10:07:40 None
2 868 838 stop 7 1976-08-20 00:33:08 2009-07-09 09:18:38 1976-01-08 07:19:23 None
*/
CREATE TABLE "Bookings_Services" (
"Order_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
PRIMARY KEY ("Order_ID", "Product_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID"),
FOREIGN KEY("Product_ID") REFERENCES "Services" ("Service_ID")
)
/*
2 rows from Bookings_Services table:
Order_ID Product_ID
1 396
1 779
*/
CREATE TABLE "Clients" (
"Client_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Email_Address" VARCHAR(255),
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Client_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Client_ID")
)
/*
2 rows from Clients table:
Client_ID Address_ID Customer_Email_Address Customer_Name Customer_Phone Other_Details
423 201 branson94@example.net Clifford (042)912-3404x5135 VIP
426 383 alba04@example.com Bettye (604)849-0214 None
*/
CREATE TABLE "Customer_Orders" (
"Order_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Store_ID" INTEGER NOT NULL,
"Order_Date" DATETIME NOT NULL,
"Planned_Delivery_Date" DATETIME NOT NULL,
"Actual_Delivery_Date" DATETIME NOT NULL,
"Other_Order_Details" VARCHAR(255),
PRIMARY KEY ("Order_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Customers" ("Customer_ID"),
FOREIGN KEY("Store_ID") REFERENCES "Stores" ("Store_ID"),
UNIQUE ("Order_ID")
)
/*
2 rows from Customer_Orders table:
Order_ID Customer_ID Store_ID Order_Date Planned_Delivery_Date Actual_Delivery_Date Other_Order_Details
1 516 231 1994-08-03 12:34:58 1977-03-11 03:58:19 1992-07-21 22:11:11 None
2 418 229 2014-07-10 10:56:01 1996-08-26 19:19:59 1998-08-22 17:57:32 None
*/
CREATE TABLE "Customers" (
"Customer_ID" VARCHAR(100) NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Customer_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Customer_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Customer_ID")
)
/*
2 rows from Customers table:
Customer_ID Address_ID Customer_Name Customer_Phone Customer_Email_Address Other_Details
240 286 Harold 624-096-7791 jerde.harmon@example.com None
267 98 Federico 914-915-7483 johnson27@example.com None
*/
CREATE TABLE "Drama_Workshop_Groups" (
"Workshop_Group_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Currency_Code" CHAR(15) NOT NULL,
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Store_Name" VARCHAR(255),
"Store_Phone" VARCHAR(255),
"Store_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Workshop_Group_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Workshop_Group_ID")
)
/*
2 rows from Drama_Workshop_Groups table:
Workshop_Group_ID Address_ID Currency_Code Marketing_Region_Code Store_Name Store_Phone Store_Email_Address Other_Details
136 383 EU FR Amely Cafe 122-084-8029 amely.ruecker@example.com None
140 180 EU DE Veda Film 793-966-9311x5303 breitenberg.veda@example.com None
*/
CREATE TABLE "Invoice_Items" (
"Invoice_Item_ID" INTEGER NOT NULL,
"Invoice_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
"Order_Item_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" INTEGER,
"Other_Item_Details" VARCHAR(255),
PRIMARY KEY ("Invoice_Item_ID"),
FOREIGN KEY("Order_Item_ID") REFERENCES "Order_Items" ("Order_Item_ID"),
FOREIGN KEY("Invoice_ID") REFERENCES "Invoices" ("Invoice_ID"),
FOREIGN KEY("Order_ID", "Product_ID") REFERENCES "Bookings_Services" ("Order_ID", "Product_ID")
)
/*
2 rows from Invoice_Items table:
Invoice_Item_ID Invoice_ID Order_ID Order_Item_ID Product_ID Order_Quantity Other_Item_Details
1 128 1 5 396 2 None
2 162 4 6 191 6 Good quality
*/
CREATE TABLE "Invoices" (
"Invoice_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
payment_method_code CHAR(15),
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" VARCHAR(288),
"Other_Item_Details" VARCHAR(255),
"Order_Item_ID" INTEGER NOT NULL,
PRIMARY KEY ("Invoice_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Customer_Orders" ("Order_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID"),
FOREIGN KEY(payment_method_code) REFERENCES "Ref_Payment_Methods" (payment_method_code)
)
/*
2 rows from Invoices table:
Invoice_ID Order_ID payment_method_code Product_ID Order_Quantity Other_Item_Details Order_Item_ID
128 14 MasterCard 4 2 None 1
162 13 MasterCard 9 2 None 9
*/
CREATE TABLE "Marketing_Regions" (
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Marketing_Region_Name" VARCHAR(255) NOT NULL,
"Marketing_Region_Descriptrion" VARCHAR(255) NOT NULL,
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Marketing_Region_Code"),
UNIQUE ("Marketing_Region_Code")
)
/*
2 rows from Marketing_Regions table:
Marketing_Region_Code Marketing_Region_Name Marketing_Region_Descriptrion Other_Details
CA Canada Our target market None
CN China Our largest market None
*/
CREATE TABLE "Order_Items" (
"Order_Item_ID" INTEGER NOT NULL,
"Order_ID" INTEGER NOT NULL,
"Product_ID" INTEGER NOT NULL,
"Order_Quantity" VARCHAR(288),
"Other_Item_Details" VARCHAR(255),
PRIMARY KEY ("Order_Item_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Customer_Orders" ("Order_ID"),
FOREIGN KEY("Product_ID") REFERENCES "Products" ("Product_ID")
)
/*
2 rows from Order_Items table:
Order_Item_ID Order_ID Product_ID Order_Quantity Other_Item_Details
1 3 233 1 None
2 15 300 2 None
*/
CREATE TABLE "Performers" (
"Performer_ID" INTEGER NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Customer_Name" VARCHAR(255),
"Customer_Phone" VARCHAR(255),
"Customer_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Performer_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
UNIQUE ("Performer_ID")
)
/*
2 rows from Performers table:
Performer_ID Address_ID Customer_Name Customer_Phone Customer_Email_Address Other_Details
153 124 Shawna 664.495.1939 krogahn@example.com None
211 124 Ashley 893-536-8857 preston45@example.net None
*/
CREATE TABLE "Performers_in_Bookings" (
"Order_ID" INTEGER NOT NULL,
"Performer_ID" INTEGER NOT NULL,
PRIMARY KEY ("Order_ID", "Performer_ID"),
FOREIGN KEY("Performer_ID") REFERENCES "Performers" ("Performer_ID"),
FOREIGN KEY("Order_ID") REFERENCES "Bookings" ("Booking_ID")
)
/*
2 rows from Performers_in_Bookings table:
Order_ID Performer_ID
1 153
1 341
*/
CREATE TABLE "Products" (
"Product_ID" VARCHAR(100) NOT NULL,
"Product_Name" VARCHAR(255),
"Product_Price" DECIMAL(20, 4),
"Product_Description" VARCHAR(255),
"Other_Product_Service_Details" VARCHAR(255),
PRIMARY KEY ("Product_ID"),
UNIQUE ("Product_ID")
)
/*
2 rows from Products table:
Product_ID Product_Name Product_Price Product_Description Other_Product_Service_Details
11 photo 4448536.0000 None None
154 film 2302.0000 None None
*/
CREATE TABLE "Ref_Payment_Methods" (
payment_method_code CHAR(10) NOT NULL,
payment_method_description VARCHAR(80),
PRIMARY KEY (payment_method_code),
UNIQUE (payment_method_code)
)
/*
2 rows from Ref_Payment_Methods table:
payment_method_code payment_method_description
American E credit
MasterCard debit
*/
CREATE TABLE "Ref_Service_Types" (
"Service_Type_Code" CHAR(15) NOT NULL,
"Parent_Service_Type_Code" CHAR(15),
"Service_Type_Description" VARCHAR(255),
PRIMARY KEY ("Service_Type_Code"),
UNIQUE ("Service_Type_Code")
)
/*
2 rows from Ref_Service_Types table:
Service_Type_Code Parent_Service_Type_Code Service_Type_Description
1 1 provide photo service
2 1 provide dinning service
*/
CREATE TABLE "Services" (
"Service_ID" INTEGER NOT NULL,
"Service_Type_Code" CHAR(15),
"Workshop_Group_ID" INTEGER NOT NULL,
"Product_Description" VARCHAR(255),
"Product_Name" VARCHAR(255),
"Product_Price" DECIMAL(20, 4),
"Other_Product_Service_Details" VARCHAR(255),
PRIMARY KEY ("Service_ID"),
FOREIGN KEY("Workshop_Group_ID") REFERENCES "Drama_Workshop_Groups" ("Workshop_Group_ID"),
FOREIGN KEY("Service_Type_Code") REFERENCES "Ref_Service_Types" ("Service_Type_Code"),
UNIQUE ("Service_ID")
)
/*
2 rows from Services table:
Service_ID Service_Type_Code Workshop_Group_ID Product_Description Product_Name Product_Price Other_Product_Service_Details
191 1 415 None film 58932775.8822 None
219 2 838 None film 2704.4719 None
*/
CREATE TABLE "Stores" (
"Store_ID" VARCHAR(100) NOT NULL,
"Address_ID" INTEGER NOT NULL,
"Marketing_Region_Code" CHAR(15) NOT NULL,
"Store_Name" VARCHAR(255),
"Store_Phone" VARCHAR(255),
"Store_Email_Address" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Store_ID"),
FOREIGN KEY("Address_ID") REFERENCES "Addresses" ("Address_ID"),
FOREIGN KEY("Marketing_Region_Code") REFERENCES "Marketing_Regions" ("Marketing_Region_Code"),
UNIQUE ("Store_ID")
)
/*
2 rows from Stores table:
Store_ID Address_ID Marketing_Region_Code Store_Name Store_Phone Store_Email_Address Other_Details
150 286 IN FJA Filming +65(1)3590790358 fjacobson@example.com None
229 266 CA Rob Dinning 1-327-185-9368 rborer@example.org 5 stars
*/ | What is the description and code of the type of service that is performed the most often? | SELECT T1.Service_Type_Description , T1.Service_Type_Code FROM Ref_Service_Types AS T1 JOIN Services AS T2 ON T1.Service_Type_Code = T2.Service_Type_Code GROUP BY T1.Service_Type_Code ORDER BY COUNT(*) DESC LIMIT 1 | [{'Service_Type_Description': 'provide dinning service', 'Service_Type_Code': '2'}] | Medium | false | false | false | true | true | true | false | true | 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
*/ | Return the poll resource associated with the most candidates. | SELECT poll_source FROM candidate GROUP BY poll_source ORDER BY count(*) DESC LIMIT 1 | [{'Poll_Source': 'Newsweek Poll'}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | [QUESTION]List the vote ids, phone numbers and states of all votes.[/QUESTION]
[SQL]SELECT vote_id , phone_number , state FROM votes[/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 smallest city in the us | SELECT city_name FROM city WHERE population = ( SELECT MIN ( population ) FROM city ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]What is the name of the district with the smallest area?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_area ASC LIMIT 1[/SQL] | [QUESTION]What is the name of the district with the smallest area?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_area ASC LIMIT 1[/SQL] | [QUESTION]What is the name of the district with the smallest area?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_area ASC LIMIT 1[/SQL] | [QUESTION]What is the name of the district with the smallest area?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_area ASC LIMIT 1[/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
*/ | What are the names of studios that have made two or more films? | SELECT Studio FROM film GROUP BY Studio HAVING COUNT(*) >= 2 | [{'Studio': '20th Century Fox'}, {'Studio': 'Columbia'}, {'Studio': 'Paramount'}] | Easy | false | false | false | false | false | true | true | false | false | false | false | false | false | [QUESTION]Which producer has worked with the most number of directors ?[/QUESTION]
[SQL]SELECT t1.name FROM director AS t3 JOIN directed_by AS t2 ON t3.did = t2.did JOIN movie AS t4 ON t4.mid = t2.msid JOIN made_by AS t5 ON t4.mid = t5.msid JOIN producer AS t1 ON t1.pid = t5.pid GROUP BY t1.name ORDER BY COUNT ( DISTINCT t3.name ) DESC LIMIT 1;[/SQL] | [QUESTION]Which producer has worked with the most number of directors ?[/QUESTION]
[SQL]SELECT t1.name FROM director AS t3 JOIN directed_by AS t2 ON t3.did = t2.did JOIN movie AS t4 ON t4.mid = t2.msid JOIN made_by AS t5 ON t4.mid = t5.msid JOIN producer AS t1 ON t1.pid = t5.pid GROUP BY t1.name ORDER BY COUNT ( DISTINCT t3.name ) DESC LIMIT 1;[/SQL] | [QUESTION]Which producer has worked with the most number of directors ?[/QUESTION]
[SQL]SELECT t1.name FROM director AS t3 JOIN directed_by AS t2 ON t3.did = t2.did JOIN movie AS t4 ON t4.mid = t2.msid JOIN made_by AS t5 ON t4.mid = t5.msid JOIN producer AS t1 ON t1.pid = t5.pid GROUP BY t1.name ORDER BY COUNT ( DISTINCT t3.name ) DESC LIMIT 1;[/SQL] | [QUESTION]Which producer has worked with the most number of directors ?[/QUESTION]
[SQL]SELECT t1.name FROM director AS t3 JOIN directed_by AS t2 ON t3.did = t2.did JOIN movie AS t4 ON t4.mid = t2.msid JOIN made_by AS t5 ON t4.mid = t5.msid JOIN producer AS t1 ON t1.pid = t5.pid GROUP BY t1.name ORDER BY COUNT ( DISTINCT t3.name ) DESC LIMIT 1;[/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
*/ | How many students did not have any course enrollment? | SELECT count(*) FROM Students WHERE student_id NOT IN (SELECT student_id FROM Student_Course_Enrolment) | [{'count(*)': 3}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the name of the semester with no students enrolled?[/QUESTION]
[SQL]SELECT semester_name FROM Semesters WHERE semester_id NOT IN( SELECT semester_id FROM Student_Enrolment )[/SQL] | [QUESTION]What is the name of the semester with no students enrolled?[/QUESTION]
[SQL]SELECT semester_name FROM Semesters WHERE semester_id NOT IN( SELECT semester_id FROM Student_Enrolment )[/SQL] | [QUESTION]What is the name of the semester with no students enrolled?[/QUESTION]
[SQL]SELECT semester_name FROM Semesters WHERE semester_id NOT IN( SELECT semester_id FROM Student_Enrolment )[/SQL] | [QUESTION]What is the name of the semester with no students enrolled?[/QUESTION]
[SQL]SELECT semester_name FROM Semesters WHERE semester_id NOT IN( SELECT semester_id FROM Student_Enrolment )[/SQL] |
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 is the average salary for each job title? | SELECT job_title , AVG(salary) FROM employees AS T1 JOIN jobs AS T2 ON T1.job_id = T2.job_id GROUP BY T2.job_title | [{'JOB_TITLE': 'Accountant', 'AVG(salary)': 7920.0}, {'JOB_TITLE': 'Accounting Manager', 'AVG(salary)': 12000.0}, {'JOB_TITLE': 'Administration Assistant', 'AVG(salary)': 4400.0}, {'JOB_TITLE': 'Administration Vice President', 'AVG(salary)': 17000.0}, {'JOB_TITLE': 'Finance Manager', 'AVG(salary)': 12000.0}, {'JOB_TITLE': 'Human Resources Representative', 'AVG(salary)': 6500.0}, {'JOB_TITLE': 'Marketing Manager', 'AVG(salary)': 13000.0}, {'JOB_TITLE': 'Marketing Representative', 'AVG(salary)': 6000.0}, {'JOB_TITLE': 'President', 'AVG(salary)': 24000.0}, {'JOB_TITLE': 'Programmer', 'AVG(salary)': 5760.0}, {'JOB_TITLE': 'Public Accountant', 'AVG(salary)': 8300.0}, {'JOB_TITLE': 'Public Relations Representative', 'AVG(salary)': 10000.0}, {'JOB_TITLE': 'Purchasing Clerk', 'AVG(salary)': 2780.0}, {'JOB_TITLE': 'Purchasing Manager', 'AVG(salary)': 11000.0}, {'JOB_TITLE': 'Sales Manager', 'AVG(salary)': 12200.0}, {'JOB_TITLE': 'Sales Representative', 'AVG(salary)': 8350.0}, {'JOB_TITLE': 'Shipping Clerk', 'AVG(salary)': 3215.0}, {'JOB_TITLE': 'Stock Clerk', 'AVG(salary)': 2785.0}, {'JOB_TITLE': 'Stock Manager', 'AVG(salary)': 7280.0}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]What is the average and largest salary of all employees?[/QUESTION]
[SQL]SELECT avg(salary) , max(salary) FROM Employee[/SQL] | [QUESTION]What is the average and largest salary of all employees?[/QUESTION]
[SQL]SELECT avg(salary) , max(salary) FROM Employee[/SQL] | [QUESTION]What is the average and largest salary of all employees?[/QUESTION]
[SQL]SELECT avg(salary) , max(salary) FROM Employee[/SQL] | [QUESTION]What is the average and largest salary of all employees?[/QUESTION]
[SQL]SELECT avg(salary) , max(salary) FROM Employee[/SQL] |
musical |
CREATE TABLE actor (
"Actor_ID" INTEGER,
"Name" TEXT,
"Musical_ID" INTEGER,
"Character" TEXT,
"Duration" TEXT,
age INTEGER,
PRIMARY KEY ("Actor_ID"),
FOREIGN KEY("Musical_ID") REFERENCES actor ("Actor_ID")
)
CREATE TABLE musical (
"Musical_ID" INTEGER,
"Name" TEXT,
"Year" INTEGER,
"Award" TEXT,
"Category" TEXT,
"Nominee" TEXT,
"Result" TEXT,
PRIMARY KEY ("Musical_ID")
) |
CREATE TABLE actor (
"Actor_ID" INTEGER,
"Name" TEXT,
"Musical_ID" INTEGER,
"Character" TEXT,
"Duration" TEXT,
age INTEGER,
PRIMARY KEY ("Actor_ID"),
FOREIGN KEY("Musical_ID") REFERENCES actor ("Actor_ID")
)
/*
2 rows from actor table:
Actor_ID Name Musical_ID Character Duration age
1 Ray Meagher 1 Alf Stewart 1988— 26
2 Tom Oliver 1 Lou Carpenter 1988, 1992— 22
*/
CREATE TABLE musical (
"Musical_ID" INTEGER,
"Name" TEXT,
"Year" INTEGER,
"Award" TEXT,
"Category" TEXT,
"Nominee" TEXT,
"Result" TEXT,
PRIMARY KEY ("Musical_ID")
)
/*
2 rows from musical table:
Musical_ID Name Year Award Category Nominee Result
1 The Phantom of the Opera 1986 Tony Award Best Book of a Musical Bob Fosse Nominated
2 Les Misérables 1986 Tony Award Best Performance by a Leading Actor in a Musical Cleavant Derricks Nominated
*/ | How many actors are there? | SELECT count(*) FROM actor | [{'count(*)': 9}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the number of actors in the movie " Saving Private Ryan " ?[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t1.name ) FROM CAST AS t2 JOIN actor AS t1 ON t2.aid = t1.aid JOIN movie AS t3 ON t3.mid = t2.msid WHERE t3.title = "Saving Private Ryan";[/SQL] | [QUESTION]What is the number of actors in the movie " Saving Private Ryan " ?[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t1.name ) FROM CAST AS t2 JOIN actor AS t1 ON t2.aid = t1.aid JOIN movie AS t3 ON t3.mid = t2.msid WHERE t3.title = "Saving Private Ryan";[/SQL] | [QUESTION]What is the number of actors in the movie " Saving Private Ryan " ?[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t1.name ) FROM CAST AS t2 JOIN actor AS t1 ON t2.aid = t1.aid JOIN movie AS t3 ON t3.mid = t2.msid WHERE t3.title = "Saving Private Ryan";[/SQL] | [QUESTION]What is the number of actors in the movie " Saving Private Ryan " ?[/QUESTION]
[SQL]SELECT COUNT ( DISTINCT t1.name ) FROM CAST AS t2 JOIN actor AS t1 ON t2.aid = t1.aid JOIN movie AS t3 ON t3.mid = t2.msid WHERE t3.title = "Saving Private Ryan";[/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 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 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 andrew@chinookcorp.com
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 nancy@chinookcorp.com
*/
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 the name of all tracks in the album named Balls to the Wall? | SELECT T2.name FROM albums AS T1 JOIN tracks AS T2 ON T1.id = T2.genre_id WHERE T1.title = "Balls to the Wall"; | [{'name': 'Desafinado'}, {'name': 'Garota De Ipanema'}, {'name': 'Samba De Uma Nota Só (One Note Samba)'}, {'name': 'Por Causa De Você'}, {'name': 'Ligia'}, {'name': 'Fotografia'}, {'name': 'Dindi (Dindi)'}, {'name': 'Se Todos Fossem Iguais A Você (Instrumental)'}, {'name': 'Falando De Amor'}, {'name': 'Angela'}, {'name': 'Corcovado (Quiet Nights Of Quiet Stars)'}, {'name': 'Outra Vez'}, {'name': 'O Boto (Bôto)'}, {'name': 'Canta, Canta Mais'}, {'name': 'Quadrant'}, {'name': "Snoopy's search-Red baron"}, {'name': 'Spanish moss-"A sound portrait"-Spanish moss'}, {'name': 'Moon germs'}, {'name': 'Stratus'}, {'name': 'The pleasant pheasant'}, {'name': 'Solo-Panhandler'}, {'name': 'Do what cha wanna'}, {'name': 'Heart of the Night'}, {'name': 'De La Luz'}, {'name': 'Westwood Moon'}, {'name': 'Midnight'}, {'name': 'Playtime'}, {'name': 'Surrender'}, {'name': "Valentino's"}, {'name': 'Believe'}, {'name': 'As We Sleep'}, {'name': 'When Evening Falls'}, {'name': 'J Squared'}, {'name': 'Best Thing'}, {'name': "Now's The Time"}, {'name': 'Jeru'}, {'name': 'Compulsion'}, {'name': 'Tempus Fugit'}, {'name': "Walkin'"}, {'name': "'Round Midnight"}, {'name': 'Bye Bye Blackbird'}, {'name': 'New Rhumba'}, {'name': 'Generique'}, {'name': 'Summertime'}, {'name': 'So What'}, {'name': 'The Pan Piper'}, {'name': 'Someday My Prince Will Come'}, {'name': 'My Funny Valentine (Live)'}, {'name': 'E.S.P.'}, {'name': 'Nefertiti'}, {'name': 'Petits Machins (Little Stuff)'}, {'name': 'Miles Runs The Voodoo Down'}, {'name': 'Little Church (Live)'}, {'name': 'Black Satin'}, {'name': 'Jean Pierre (Live)'}, {'name': 'Time After Time'}, {'name': 'Portia'}, {'name': 'Jeepers Creepers'}, {'name': 'Blue Rythm Fantasy'}, {'name': 'Drum Boogie'}, {'name': 'Let Me Off Uptown'}, {'name': 'Leave Us Leap'}, {'name': 'Opus No.1'}, {'name': 'Boogie Blues'}, {'name': 'How High The Moon'}, {'name': 'Disc Jockey Jump'}, {'name': "Up An' Atom"}, {'name': 'Bop Boogie'}, {'name': 'Lemon Drop'}, {'name': 'Coronation Drop'}, {'name': 'Overtime'}, {'name': 'Imagination'}, {'name': "Don't Take Your Love From Me"}, {'name': 'Midget'}, {'name': "I'm Coming Virginia"}, {'name': "Payin' Them Dues Blues"}, {'name': 'Jungle Drums'}, {'name': 'Showcase'}, {'name': 'Swedish Schnapps'}, {'name': 'Roll Call'}, {'name': 'Otay'}, {'name': 'Groovus Interruptus'}, {'name': 'Paris On Mine'}, {'name': 'In Time'}, {'name': 'Plan B'}, {'name': 'Outbreak'}, {'name': 'Baltimore, DC'}, {'name': 'Talkin Loud and Saying Nothin'}, {'name': 'Doce De Carnaval (Candy All)'}, {'name': 'Lamento De Carnaval'}, {'name': 'Pretinha'}, {'name': 'Colibri'}, {'name': 'Love Is The Colour'}, {'name': 'Magnetic Ocean'}, {'name': 'Deep Waters'}, {'name': "L'Arc En Ciel De Miles"}, {'name': 'Gypsy'}, {'name': 'Journey Into Sunlight'}, {'name': 'Sunchild'}, {'name': 'Millenium'}, {'name': "Thinking 'Bout Tomorrow"}, {'name': "Jacob's Ladder"}, {'name': 'She Wears Black'}, {'name': 'Dark Side Of The Cog'}, {'name': 'Springsville'}, {'name': 'The Maids Of Cadiz'}, {'name': 'The Duke'}, {'name': 'My Ship'}, {'name': 'Miles Ahead'}, {'name': 'Blues For Pablo'}, {'name': 'New Rhumba'}, {'name': 'The Meaning Of The Blues'}, {'name': 'Lament'}, {'name': "I Don't Wanna Be Kissed (By Anyone But You)"}, {'name': 'Springsville (Alternate Take)'}, {'name': 'Blues For Pablo (Alternate Take)'}, {'name': 'The Meaning Of The Blues/Lament (Alternate Take)'}, {'name': "I Don't Wanna Be Kissed (By Anyone But You) (Alternate Take)"}, {'name': 'Morning Dance'}, {'name': 'Jubilee'}, {'name': 'Rasul'}, {'name': 'Song For Lorraine'}, {'name': 'Starburst'}, {'name': 'Heliopolis'}, {'name': "It Doesn't Matter"}, {'name': 'Little Linda'}, {'name': 'End Of Romanticism'}, {'name': 'Amanda'}, {'name': 'Despertar'}, {'name': "OAM's Blues"}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
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
*/ | What are the 3 most common cloud covers in the zip code of 94107? | SELECT cloud_cover FROM weather WHERE zip_code = 94107 GROUP BY cloud_cover ORDER BY COUNT (*) DESC LIMIT 3 | [{'cloud_cover': 5}, {'cloud_cover': 4}, {'cloud_cover': 6}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | ||||
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
*/ | Show the name of colleges that have at least two players in descending alphabetical order. | SELECT College FROM match_season GROUP BY College HAVING count(*) >= 2 ORDER BY College DESC | [{'College': 'Virginia'}, {'College': 'UCLA'}, {'College': 'Maryland'}] | Easy | false | false | false | true | false | true | true | false | false | false | false | false | false | [QUESTION]Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.[/QUESTION]
[SQL]SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name[/SQL] | [QUESTION]Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.[/QUESTION]
[SQL]SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name[/SQL] | [QUESTION]Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.[/QUESTION]
[SQL]SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name[/SQL] | [QUESTION]Show names of teachers and the courses they are arranged to teach in ascending alphabetical order of the teacher's name.[/QUESTION]
[SQL]SELECT T3.Name , T2.Course FROM course_arrange AS T1 JOIN course AS T2 ON T1.Course_ID = T2.Course_ID JOIN teacher AS T3 ON T1.Teacher_ID = T3.Teacher_ID ORDER BY T3.Name[/SQL] |
cre_Docs_and_Epenses |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
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 "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
) |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
/*
2 rows from Accounts table:
Account_ID Statement_ID Account_Details
7 57 495.063
61 57 930.14
*/
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
/*
2 rows from Documents table:
Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details
29 CV 30 2004-08-28 06:59:19 Review on UK files None None
42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None
*/
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Documents_with_Expenses table:
Document_ID Budget_Type_Code Document_Details
57 GV government
192 GV government
*/
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
/*
2 rows from Projects table:
Project_ID Project_Details
30 Society Research project
35 Internet of Things project
*/
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
/*
2 rows from Ref_Budget_Codes table:
Budget_Type_Code Budget_Type_Description
GV Government
ORG Organisation
*/
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
BK Book excellent
CV CV excellent
*/
CREATE TABLE "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Statements table:
Statement_ID Statement_Details
57 Open Project
192 Private Project
*/ | What are the type codes and descriptions of each budget type? | SELECT budget_type_code , budget_type_description FROM Ref_budget_codes | [{'Budget_Type_Code': 'GV', 'Budget_Type_Description': 'Government'}, {'Budget_Type_Code': 'ORG', 'Budget_Type_Description': 'Organisation'}, {'Budget_Type_Code': 'SF', 'Budget_Type_Description': 'Self founded'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the type codes and descriptions for all template types?[/QUESTION]
[SQL]SELECT template_type_code , template_type_description FROM Ref_template_types[/SQL] | [QUESTION]What are the type codes and descriptions for all template types?[/QUESTION]
[SQL]SELECT template_type_code , template_type_description FROM Ref_template_types[/SQL] | [QUESTION]What are the type codes and descriptions for all template types?[/QUESTION]
[SQL]SELECT template_type_code , template_type_description FROM Ref_template_types[/SQL] | [QUESTION]What are the type codes and descriptions for all template types?[/QUESTION]
[SQL]SELECT template_type_code , template_type_description FROM Ref_template_types[/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
*/ | papers coauthored by Peter Mertens and Dina Barbian | SELECT DISTINCT t3.paperid FROM writes AS t3 JOIN author AS t2 ON t3.authorid = t2.authorid JOIN writes AS t4 ON t4.paperid = t3.paperid JOIN author AS t1 ON t4.authorid = t1.authorid WHERE t2.authorname = "Peter Mertens" AND t1.authorname = "Dina Barbian"; | [{'Nenhum': 'Nenhum resultado encontrado'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | [QUESTION]return me the authors who have cited the papers by " H. V. Jagadish " .[/QUESTION]
[SQL]SELECT t2.name FROM publication AS t7 JOIN cite AS t5 ON t7.pid = t5.citing JOIN publication AS t6 ON t6.pid = t5.cited JOIN writes AS t3 ON t3.pid = t7.pid JOIN writes AS t4 ON t4.pid = t6.pid JOIN author AS t2 ON t3.aid = t2.aid JOIN author AS t1 ON t4.aid = t1.aid WHERE t1.name = "H. V. Jagadish";[/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 of "San Francisco State University" in year 2000? | SELECT t1.campusfee FROM csu_fees AS t1 JOIN campuses AS t2 ON t1.campus = t2.id WHERE t2.campus = "San Francisco State University" AND t1.year = 2000 | [{'Nenhum': 'Nenhum resultado encontrado'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
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 longest river in the largest state | SELECT river_name FROM river WHERE LENGTH = ( SELECT MAX ( LENGTH ) FROM river WHERE traverse IN ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) ) ) AND traverse IN ( SELECT state_name 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 longest river in the state with the highest point[/QUESTION]
[SQL]SELECT t1.river_name FROM highlow AS t2 JOIN river AS t1 ON t1.traverse = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow ) ORDER BY t1.length DESC LIMIT 1;[/SQL] | [QUESTION]what is the longest river in the state with the highest point[/QUESTION]
[SQL]SELECT t1.river_name FROM highlow AS t2 JOIN river AS t1 ON t1.traverse = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow ) ORDER BY t1.length DESC LIMIT 1;[/SQL] | [QUESTION]what is the longest river in the state with the highest point[/QUESTION]
[SQL]SELECT t1.river_name FROM highlow AS t2 JOIN river AS t1 ON t1.traverse = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow ) ORDER BY t1.length DESC LIMIT 1;[/SQL] | [QUESTION]what is the longest river in the state with the highest point[/QUESTION]
[SQL]SELECT t1.river_name FROM highlow AS t2 JOIN river AS t1 ON t1.traverse = t2.state_name WHERE t2.highest_elevation = ( SELECT MAX ( highest_elevation ) FROM highlow ) ORDER BY t1.length DESC LIMIT 1;[/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
*/ | What are the names of companies with revenue less than the lowest revenue of any manufacturer in Austin? | SELECT name FROM manufacturers WHERE revenue < (SELECT min(revenue) FROM manufacturers WHERE headquarter = 'Austin') | [{'Name': 'Hewlett-Packard'}, {'Name': 'Winchester'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
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
*/ | whats the largest city | SELECT city_name FROM city WHERE population = ( SELECT MAX ( population ) FROM city ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]Which district has the largest population?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1[/SQL] | [QUESTION]Which district has the largest population?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1[/SQL] | [QUESTION]Which district has the largest population?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1[/SQL] | [QUESTION]Which district has the largest population?[/QUESTION]
[SQL]SELECT district_name FROM district ORDER BY city_population DESC LIMIT 1[/SQL] |
protein_institute |
CREATE TABLE "Institution" (
"Institution_id" TEXT,
"Institution" TEXT,
"Location" TEXT,
"Founded" REAL,
"Type" TEXT,
"Enrollment" INTEGER,
"Team" TEXT,
"Primary_Conference" TEXT,
building_id TEXT,
PRIMARY KEY ("Institution_id"),
FOREIGN KEY(building_id) REFERENCES building (building_id)
)
CREATE TABLE building (
building_id TEXT,
"Name" TEXT,
"Street_address" TEXT,
"Years_as_tallest" TEXT,
"Height_feet" INTEGER,
"Floors" INTEGER,
PRIMARY KEY (building_id)
)
CREATE TABLE protein (
common_name TEXT,
protein_name TEXT,
divergence_from_human_lineage REAL,
accession_number TEXT,
sequence_length REAL,
sequence_identity_to_human_protein TEXT,
"Institution_id" TEXT,
PRIMARY KEY (common_name),
FOREIGN KEY("Institution_id") REFERENCES "Institution" ("Institution_id")
) |
CREATE TABLE "Institution" (
"Institution_id" TEXT,
"Institution" TEXT,
"Location" TEXT,
"Founded" REAL,
"Type" TEXT,
"Enrollment" INTEGER,
"Team" TEXT,
"Primary_Conference" TEXT,
building_id TEXT,
PRIMARY KEY ("Institution_id"),
FOREIGN KEY(building_id) REFERENCES building (building_id)
)
/*
2 rows from Institution table:
Institution_id Institution Location Founded Type Enrollment Team Primary_Conference building_id
0 Ave Maria University Ave Maria, Florida 1998.0 Private 1200 Gyrenes The Sun 1
1 Dakota State University Madison, South Dakota 1881.0 Public 3102 Trojans none 1
*/
CREATE TABLE building (
building_id TEXT,
"Name" TEXT,
"Street_address" TEXT,
"Years_as_tallest" TEXT,
"Height_feet" INTEGER,
"Floors" INTEGER,
PRIMARY KEY (building_id)
)
/*
2 rows from building table:
building_id Name Street_address Years_as_tallest Height_feet Floors
0 Citizens Bank Building 701 North Franklin Street 1913–1915 145 12
1 Tampa City Hall 315 John F. Kennedy Boulevard 1915–1926 160 10
*/
CREATE TABLE protein (
common_name TEXT,
protein_name TEXT,
divergence_from_human_lineage REAL,
accession_number TEXT,
sequence_length REAL,
sequence_identity_to_human_protein TEXT,
"Institution_id" TEXT,
PRIMARY KEY (common_name),
FOREIGN KEY("Institution_id") REFERENCES "Institution" ("Institution_id")
)
/*
2 rows from protein table:
common_name protein_name divergence_from_human_lineage accession_number sequence_length sequence_identity_to_human_protein Institution_id
Tropical Clawed Frog uncharacterized protein C20orf117-like 371.2 XP_002942331.1 1584.0 39% 1
purple sea urchin uncharacterized protein LOC578090 742.9 XP_783370.2 1587.0 47% 3
*/ | Show the name, street address, and number of floors for all buildings ordered by the number of floors. | SELECT name , street_address , floors FROM building ORDER BY floors | [{'Name': 'Tampa City Hall', 'Street_address': '315 John F. Kennedy Boulevard', 'Floors': 10}, {'Name': 'Citizens Bank Building', 'Street_address': '701 North Franklin Street', 'Floors': 12}, {'Name': 'Floridan Hotel', 'Street_address': '905 Franklin Street', 'Floors': 17}, {'Name': 'Franklin Exchange Building', 'Street_address': '655 North Franklin Street', 'Floors': 22}, {'Name': 'Park Tower', 'Street_address': '400 North Tampa Street', 'Floors': 36}, {'Name': 'One Tampa City Center', 'Street_address': '201 North Franklin Street', 'Floors': 39}, {'Name': 'Bank of America Tower', 'Street_address': '101 East Kennedy Boulevard', 'Floors': 42}, {'Name': '100 North Tampa', 'Street_address': '100 North Tampa Street', 'Floors': 42}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.[/QUESTION]
[SQL]SELECT flno , origin , destination FROM Flight ORDER BY origin[/SQL] | [QUESTION]Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.[/QUESTION]
[SQL]SELECT flno , origin , destination FROM Flight ORDER BY origin[/SQL] | [QUESTION]Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.[/QUESTION]
[SQL]SELECT flno , origin , destination FROM Flight ORDER BY origin[/SQL] | [QUESTION]Show flight number, origin, destination of all flights in the alphabetical order of the departure cities.[/QUESTION]
[SQL]SELECT flno , origin , destination FROM Flight ORDER BY origin[/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 are the details of the markets that can be accessed by walk or bus? | SELECT T1.Market_Details FROM Street_Markets AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Market_ID = T2.Tourist_Attraction_ID WHERE T2.How_to_Get_There = "walk" OR T2.How_to_Get_There = "bus" | [{'Market_Details': 'Broadway'}, {'Market_Details': 'Fish Farm Market'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
customer_deliveries |
CREATE TABLE "Actual_Order_Products" (
actual_order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
FOREIGN KEY(actual_order_id) REFERENCES "Actual_Orders" (actual_order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Actual_Orders" (
actual_order_id INTEGER,
order_status_code VARCHAR(10) NOT NULL,
regular_order_id INTEGER NOT NULL,
actual_order_date DATETIME,
PRIMARY KEY (actual_order_id),
FOREIGN KEY(regular_order_id) REFERENCES "Regular_Orders" (regular_order_id)
)
CREATE TABLE "Addresses" (
address_id INTEGER,
address_details VARCHAR(80),
city VARCHAR(50),
zip_postcode VARCHAR(20),
state_province_county VARCHAR(50),
country VARCHAR(50),
PRIMARY KEY (address_id)
)
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
address_type VARCHAR(10) NOT NULL,
date_to DATETIME,
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(10) NOT NULL,
customer_name VARCHAR(80),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
date_became_customer DATETIME,
PRIMARY KEY (customer_id)
)
CREATE TABLE "Delivery_Route_Locations" (
location_code VARCHAR(10),
route_id INTEGER NOT NULL,
location_address_id INTEGER NOT NULL,
location_name VARCHAR(50),
PRIMARY KEY (location_code),
FOREIGN KEY(route_id) REFERENCES "Delivery_Routes" (route_id),
FOREIGN KEY(location_address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Delivery_Routes" (
route_id INTEGER,
route_name VARCHAR(50),
other_route_details VARCHAR(255),
PRIMARY KEY (route_id)
)
CREATE TABLE "Employees" (
employee_id INTEGER,
employee_address_id INTEGER NOT NULL,
employee_name VARCHAR(80),
employee_phone VARCHAR(80),
PRIMARY KEY (employee_id),
FOREIGN KEY(employee_address_id) REFERENCES "Addresses" (address_id)
)
CREATE TABLE "Order_Deliveries" (
location_code VARCHAR(10) NOT NULL,
actual_order_id INTEGER NOT NULL,
delivery_status_code VARCHAR(10) NOT NULL,
driver_employee_id INTEGER NOT NULL,
truck_id INTEGER NOT NULL,
delivery_date DATETIME,
FOREIGN KEY(driver_employee_id) REFERENCES "Employees" (employee_id),
FOREIGN KEY(location_code) REFERENCES "Delivery_Route_Locations" (location_code),
FOREIGN KEY(actual_order_id) REFERENCES "Actual_Orders" (actual_order_id),
FOREIGN KEY(truck_id) REFERENCES "Trucks" (truck_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
product_name VARCHAR(20),
product_price DECIMAL(19, 4),
product_description VARCHAR(255),
PRIMARY KEY (product_id)
)
CREATE TABLE "Regular_Order_Products" (
regular_order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
FOREIGN KEY(regular_order_id) REFERENCES "Regular_Orders" (regular_order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
CREATE TABLE "Regular_Orders" (
regular_order_id INTEGER,
distributer_id INTEGER NOT NULL,
PRIMARY KEY (regular_order_id),
FOREIGN KEY(distributer_id) REFERENCES "Customers" (customer_id)
)
CREATE TABLE "Trucks" (
truck_id INTEGER,
truck_licence_number VARCHAR(20),
truck_details VARCHAR(255),
PRIMARY KEY (truck_id)
) |
CREATE TABLE "Actual_Order_Products" (
actual_order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
FOREIGN KEY(actual_order_id) REFERENCES "Actual_Orders" (actual_order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Actual_Order_Products table:
actual_order_id product_id
2 1
14 5
*/
CREATE TABLE "Actual_Orders" (
actual_order_id INTEGER,
order_status_code VARCHAR(10) NOT NULL,
regular_order_id INTEGER NOT NULL,
actual_order_date DATETIME,
PRIMARY KEY (actual_order_id),
FOREIGN KEY(regular_order_id) REFERENCES "Regular_Orders" (regular_order_id)
)
/*
2 rows from Actual_Orders table:
actual_order_id order_status_code regular_order_id actual_order_date
1 Success 8 2018-03-02 23:26:19
2 Cancel 15 2018-03-02 08:33:39
*/
CREATE TABLE "Addresses" (
address_id INTEGER,
address_details 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 address_details city zip_postcode state_province_county country
1 92283 Lora Forges Suite 322 Mohrville 271 Nebraska USA
2 17135 Jaida Fork Suite 798 East Brody 940 Colorado USA
*/
CREATE TABLE "Customer_Addresses" (
customer_id INTEGER NOT NULL,
address_id INTEGER NOT NULL,
date_from DATETIME NOT NULL,
address_type VARCHAR(10) NOT NULL,
date_to DATETIME,
FOREIGN KEY(address_id) REFERENCES "Addresses" (address_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Customer_Addresses table:
customer_id address_id date_from address_type date_to
5 6 2016-09-06 19:23:46 House 2018-02-25 15:34:58
14 5 2016-12-21 03:49:54 House 2018-03-13 21:20:21
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
payment_method VARCHAR(10) NOT NULL,
customer_name VARCHAR(80),
customer_phone VARCHAR(80),
customer_email VARCHAR(80),
date_became_customer DATETIME,
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id payment_method customer_name customer_phone customer_email date_became_customer
1 Visa Ron Emard 1-382-503-5179x53639 shaniya45@example.net 2011-04-25 22:20:35
2 MasterCard Gabe Schroeder 1-728-537-4293x0885 alexandra91@example.net 2011-10-17 16:08:25
*/
CREATE TABLE "Delivery_Route_Locations" (
location_code VARCHAR(10),
route_id INTEGER NOT NULL,
location_address_id INTEGER NOT NULL,
location_name VARCHAR(50),
PRIMARY KEY (location_code),
FOREIGN KEY(route_id) REFERENCES "Delivery_Routes" (route_id),
FOREIGN KEY(location_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Delivery_Route_Locations table:
location_code route_id location_address_id location_name
27 City Rd 11 5 Labadie-Crooks
30 Sam Rd 7 13 VonRueden, Schmeler and Fay
*/
CREATE TABLE "Delivery_Routes" (
route_id INTEGER,
route_name VARCHAR(50),
other_route_details VARCHAR(255),
PRIMARY KEY (route_id)
)
/*
2 rows from Delivery_Routes table:
route_id route_name other_route_details
1 Torphy Ltd 16893 Wilderman Terrace
Port Lucasburgh, ND 55978-5550
2 Heidenreich Group 6534 Cheyenne Trace Suite 242
Koryburgh, PA 21391-9164
*/
CREATE TABLE "Employees" (
employee_id INTEGER,
employee_address_id INTEGER NOT NULL,
employee_name VARCHAR(80),
employee_phone VARCHAR(80),
PRIMARY KEY (employee_id),
FOREIGN KEY(employee_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Employees table:
employee_id employee_address_id employee_name employee_phone
1 4 Kacie 716-650-2081
2 12 Dejuan 211.289.9042
*/
CREATE TABLE "Order_Deliveries" (
location_code VARCHAR(10) NOT NULL,
actual_order_id INTEGER NOT NULL,
delivery_status_code VARCHAR(10) NOT NULL,
driver_employee_id INTEGER NOT NULL,
truck_id INTEGER NOT NULL,
delivery_date DATETIME,
FOREIGN KEY(driver_employee_id) REFERENCES "Employees" (employee_id),
FOREIGN KEY(location_code) REFERENCES "Delivery_Route_Locations" (location_code),
FOREIGN KEY(actual_order_id) REFERENCES "Actual_Orders" (actual_order_id),
FOREIGN KEY(truck_id) REFERENCES "Trucks" (truck_id)
)
/*
2 rows from Order_Deliveries table:
location_code actual_order_id delivery_status_code driver_employee_id truck_id delivery_date
27 City Rd 11 Ready 6 11 2018-03-21 00:57:22
27 City Rd 1 On Road 4 10 2018-02-26 01:32:49
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_name VARCHAR(20),
product_price DECIMAL(19, 4),
product_description VARCHAR(255),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_name product_price product_description
1 dvds 1322.7800 good condition
2 cloth 6402.0900 good condition
*/
CREATE TABLE "Regular_Order_Products" (
regular_order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
FOREIGN KEY(regular_order_id) REFERENCES "Regular_Orders" (regular_order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Regular_Order_Products table:
regular_order_id product_id
5 3
2 3
*/
CREATE TABLE "Regular_Orders" (
regular_order_id INTEGER,
distributer_id INTEGER NOT NULL,
PRIMARY KEY (regular_order_id),
FOREIGN KEY(distributer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Regular_Orders table:
regular_order_id distributer_id
1 12
2 15
*/
CREATE TABLE "Trucks" (
truck_id INTEGER,
truck_licence_number VARCHAR(20),
truck_details VARCHAR(255),
PRIMARY KEY (truck_id)
)
/*
2 rows from Trucks table:
truck_id truck_licence_number truck_details
1 58110 Frida
2 33822 Randy
*/ | How many different payment methods are there? | SELECT count(DISTINCT payment_method) FROM customers | [{'count(DISTINCT payment_method)': 4}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken?[/QUESTION]
[SQL]SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount)[/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
*/ | Show all advisors who have at least two students. | SELECT advisor FROM Student GROUP BY advisor HAVING count(*) >= 2 | [{'Advisor': 1121}, {'Advisor': 1148}, {'Advisor': 2192}, {'Advisor': 2311}, {'Advisor': 5718}, {'Advisor': 7134}, {'Advisor': 7271}, {'Advisor': 8722}, {'Advisor': 8772}] | Easy | false | false | false | false | false | true | true | false | false | false | false | false | false | [QUESTION]Show the names of students who have at least 2 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 HAVING count(*) >= 2[/SQL] | [QUESTION]Show the names of students who have at least 2 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 HAVING count(*) >= 2[/SQL] | [QUESTION]Show the names of students who have at least 2 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 HAVING count(*) >= 2[/SQL] |
|
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
*/ | Which faculty do not participate in any activity? Find their faculty ids. | SELECT FacID FROM Faculty EXCEPT SELECT FacID FROM Faculty_participates_in | [{'FacID': 1148}, {'FacID': 1172}, {'FacID': 1823}, {'FacID': 2028}, {'FacID': 2119}, {'FacID': 2291}, {'FacID': 2311}, {'FacID': 2738}, {'FacID': 6191}, {'FacID': 6330}, {'FacID': 6541}, {'FacID': 6910}, {'FacID': 6925}, {'FacID': 7134}, {'FacID': 7231}, {'FacID': 7271}, {'FacID': 7506}, {'FacID': 7712}, {'FacID': 7792}, {'FacID': 8102}, {'FacID': 8118}, {'FacID': 8122}, {'FacID': 8423}, {'FacID': 8722}, {'FacID': 8723}, {'FacID': 8772}, {'FacID': 8791}, {'FacID': 8989}, {'FacID': 9011}, {'FacID': 9172}, {'FacID': 9191}, {'FacID': 9199}, {'FacID': 9210}, {'FacID': 9379}, {'FacID': 9514}, {'FacID': 9643}, {'FacID': 9811}, {'FacID': 9823}, {'FacID': 9824}, {'FacID': 9826}] | Hard | false | false | false | false | false | false | false | false | false | false | false | true | 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] |
||
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
*/ | What is the label that has the most albums? | SELECT label FROM albums GROUP BY label ORDER BY count(*) DESC LIMIT 1 | [{'Nenhum': 'Nenhum resultado encontrado'}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | [QUESTION]What is the record company used by the greatest number of orchestras?[/QUESTION]
[SQL]SELECT Record_Company FROM orchestra GROUP BY Record_Company ORDER BY COUNT(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the record company used by the greatest number of orchestras?[/QUESTION]
[SQL]SELECT Record_Company FROM orchestra GROUP BY Record_Company ORDER BY COUNT(*) DESC LIMIT 1[/SQL] | [QUESTION]What is the record company used by the greatest number of orchestras?[/QUESTION]
[SQL]SELECT Record_Company FROM orchestra GROUP BY Record_Company ORDER BY COUNT(*) DESC LIMIT 1[/SQL] |
|
train_station |
CREATE TABLE station (
"Station_ID" INTEGER,
"Name" TEXT,
"Annual_entry_exit" REAL,
"Annual_interchanges" REAL,
"Total_Passengers" REAL,
"Location" TEXT,
"Main_Services" TEXT,
"Number_of_Platforms" INTEGER,
PRIMARY KEY ("Station_ID")
)
CREATE TABLE train (
"Train_ID" INTEGER,
"Name" TEXT,
"Time" TEXT,
"Service" TEXT,
PRIMARY KEY ("Train_ID")
)
CREATE TABLE train_station (
"Train_ID" INTEGER,
"Station_ID" INTEGER,
PRIMARY KEY ("Train_ID", "Station_ID"),
FOREIGN KEY("Train_ID") REFERENCES train ("Train_ID"),
FOREIGN KEY("Station_ID") REFERENCES station ("Station_ID")
) |
CREATE TABLE station (
"Station_ID" INTEGER,
"Name" TEXT,
"Annual_entry_exit" REAL,
"Annual_interchanges" REAL,
"Total_Passengers" REAL,
"Location" TEXT,
"Main_Services" TEXT,
"Number_of_Platforms" INTEGER,
PRIMARY KEY ("Station_ID")
)
/*
2 rows from station table:
Station_ID Name Annual_entry_exit Annual_interchanges Total_Passengers Location Main_Services Number_of_Platforms
1 London Waterloo 94.046 9.489 103.534 London South Western Main Line West of England Main Line 19
2 London Victoria 76.231 9.157 85.38 London Brighton Main Line Chatham Main Line 19
*/
CREATE TABLE train (
"Train_ID" INTEGER,
"Name" TEXT,
"Time" TEXT,
"Service" TEXT,
PRIMARY KEY ("Train_ID")
)
/*
2 rows from train table:
Train_ID Name Time Service
1 Ananthapuri Express 17:15 Daily
2 Guruvayur Express 22:10 Daily
*/
CREATE TABLE train_station (
"Train_ID" INTEGER,
"Station_ID" INTEGER,
PRIMARY KEY ("Train_ID", "Station_ID"),
FOREIGN KEY("Train_ID") REFERENCES train ("Train_ID"),
FOREIGN KEY("Station_ID") REFERENCES station ("Station_ID")
)
/*
2 rows from train_station table:
Train_ID Station_ID
1 1
2 1
*/ | Show the station name with greatest number of trains. | SELECT T2.name FROM train_station AS T1 JOIN station AS T2 ON T1.station_id = T2.station_id GROUP BY T1.station_id ORDER BY count(*) DESC LIMIT 1 | [{'Name': 'London Waterloo'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
network_2 |
CREATE TABLE "Person" (
name VARCHAR(20),
age INTEGER,
city TEXT,
gender TEXT,
job TEXT,
PRIMARY KEY (name)
)
CREATE TABLE "PersonFriend" (
name VARCHAR(20),
friend VARCHAR(20),
year INTEGER,
FOREIGN KEY(name) REFERENCES "Person" (name),
FOREIGN KEY(friend) REFERENCES "Person" (name)
) |
CREATE TABLE "Person" (
name VARCHAR(20),
age INTEGER,
city TEXT,
gender TEXT,
job TEXT,
PRIMARY KEY (name)
)
/*
2 rows from Person table:
name age city gender job
Alice 25 new york city female student
Bob 35 salt lake city male engineer
*/
CREATE TABLE "PersonFriend" (
name VARCHAR(20),
friend VARCHAR(20),
year INTEGER,
FOREIGN KEY(name) REFERENCES "Person" (name),
FOREIGN KEY(friend) REFERENCES "Person" (name)
)
/*
2 rows from PersonFriend table:
name friend year
Alice Bob 10
Zach Dan 12
*/ | How many different cities do people originate from? | SELECT count(DISTINCT city) FROM Person | [{'count(DISTINCT city)': 4}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many people are there of each nationality?[/QUESTION]
[SQL]SELECT Nationality , COUNT(*) FROM people GROUP BY Nationality[/SQL] | [QUESTION]How many people are there of each nationality?[/QUESTION]
[SQL]SELECT Nationality , COUNT(*) FROM people GROUP BY Nationality[/SQL] | [QUESTION]How many people are there of each nationality?[/QUESTION]
[SQL]SELECT Nationality , COUNT(*) FROM people GROUP BY Nationality[/SQL] | [QUESTION]How many people are there of each nationality?[/QUESTION]
[SQL]SELECT Nationality , COUNT(*) FROM people GROUP BY Nationality[/SQL] |
workshop_paper |
CREATE TABLE "Acceptance" (
"Submission_ID" INTEGER,
"Workshop_ID" INTEGER,
"Result" TEXT,
PRIMARY KEY ("Submission_ID", "Workshop_ID"),
FOREIGN KEY("Workshop_ID") REFERENCES workshop ("Workshop_ID"),
FOREIGN KEY("Submission_ID") REFERENCES submission ("Submission_ID")
)
CREATE TABLE submission (
"Submission_ID" INTEGER,
"Scores" REAL,
"Author" TEXT,
"College" TEXT,
PRIMARY KEY ("Submission_ID")
)
CREATE TABLE workshop (
"Workshop_ID" INTEGER,
"Date" TEXT,
"Venue" TEXT,
"Name" TEXT,
PRIMARY KEY ("Workshop_ID")
) |
CREATE TABLE "Acceptance" (
"Submission_ID" INTEGER,
"Workshop_ID" INTEGER,
"Result" TEXT,
PRIMARY KEY ("Submission_ID", "Workshop_ID"),
FOREIGN KEY("Workshop_ID") REFERENCES workshop ("Workshop_ID"),
FOREIGN KEY("Submission_ID") REFERENCES submission ("Submission_ID")
)
/*
2 rows from Acceptance table:
Submission_ID Workshop_ID Result
2 5 Accepted
2 3 Rejected
*/
CREATE TABLE submission (
"Submission_ID" INTEGER,
"Scores" REAL,
"Author" TEXT,
"College" TEXT,
PRIMARY KEY ("Submission_ID")
)
/*
2 rows from submission table:
Submission_ID Scores Author College
1 72.0 Steve Niehaus Notre Dame
2 79.0 Sammy Green Florida
*/
CREATE TABLE workshop (
"Workshop_ID" INTEGER,
"Date" TEXT,
"Venue" TEXT,
"Name" TEXT,
PRIMARY KEY ("Workshop_ID")
)
/*
2 rows from workshop table:
Workshop_ID Date Venue Name
1 August 18, 2007 London UK ABC 2007
2 August 21, 2007 London UK Conference 2007
*/ | Show the authors of submissions and the acceptance results of their submissions. | SELECT T2.Author , T1.Result FROM acceptance AS T1 JOIN submission AS T2 ON T1.Submission_ID = T2.Submission_ID | [{'Author': 'Sammy Green', 'Result': 'Accepted'}, {'Author': 'Sammy Green', 'Result': 'Rejected'}, {'Author': 'Sherman Smith', 'Result': 'Rejected'}, {'Author': 'Steve Raible', 'Result': 'Rejected'}, {'Author': 'Jeff Lloyd', 'Result': 'Rejected'}, {'Author': 'Steve Niehaus', 'Result': 'Accepted'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
tracking_share_transactions |
CREATE TABLE "Investors" (
investor_id INTEGER,
"Investor_details" VARCHAR(255),
PRIMARY KEY (investor_id)
)
CREATE TABLE "Lots" (
lot_id INTEGER,
investor_id INTEGER NOT NULL,
lot_details VARCHAR(255),
PRIMARY KEY (lot_id),
FOREIGN KEY(investor_id) REFERENCES "Investors" (investor_id)
)
CREATE TABLE "Purchases" (
purchase_transaction_id INTEGER NOT NULL,
purchase_details VARCHAR(255) NOT NULL,
FOREIGN KEY(purchase_transaction_id) REFERENCES "Transactions" (transaction_id)
)
CREATE TABLE "Ref_Transaction_Types" (
transaction_type_code VARCHAR(10),
transaction_type_description VARCHAR(80) NOT NULL,
PRIMARY KEY (transaction_type_code)
)
CREATE TABLE "Sales" (
sales_transaction_id INTEGER,
sales_details VARCHAR(255),
PRIMARY KEY (sales_transaction_id),
FOREIGN KEY(sales_transaction_id) REFERENCES "Transactions" (transaction_id)
)
CREATE TABLE "Transactions" (
transaction_id INTEGER,
investor_id INTEGER NOT NULL,
transaction_type_code VARCHAR(10) NOT NULL,
date_of_transaction DATETIME,
amount_of_transaction DECIMAL(19, 4),
share_count VARCHAR(40),
other_details VARCHAR(255),
PRIMARY KEY (transaction_id),
FOREIGN KEY(transaction_type_code) REFERENCES "Ref_Transaction_Types" (transaction_type_code),
FOREIGN KEY(investor_id) REFERENCES "Investors" (investor_id)
)
CREATE TABLE "Transactions_Lots" (
transaction_id INTEGER NOT NULL,
lot_id INTEGER NOT NULL,
FOREIGN KEY(transaction_id) REFERENCES "Transactions" (transaction_id),
FOREIGN KEY(lot_id) REFERENCES "Lots" (lot_id)
) |
CREATE TABLE "Investors" (
investor_id INTEGER,
"Investor_details" VARCHAR(255),
PRIMARY KEY (investor_id)
)
/*
2 rows from Investors table:
investor_id Investor_details
1 z
2 z
*/
CREATE TABLE "Lots" (
lot_id INTEGER,
investor_id INTEGER NOT NULL,
lot_details VARCHAR(255),
PRIMARY KEY (lot_id),
FOREIGN KEY(investor_id) REFERENCES "Investors" (investor_id)
)
/*
2 rows from Lots table:
lot_id investor_id lot_details
1 13 r
2 16 z
*/
CREATE TABLE "Purchases" (
purchase_transaction_id INTEGER NOT NULL,
purchase_details VARCHAR(255) NOT NULL,
FOREIGN KEY(purchase_transaction_id) REFERENCES "Transactions" (transaction_id)
)
/*
2 rows from Purchases table:
purchase_transaction_id purchase_details
1 c
2 y
*/
CREATE TABLE "Ref_Transaction_Types" (
transaction_type_code VARCHAR(10),
transaction_type_description VARCHAR(80) NOT NULL,
PRIMARY KEY (transaction_type_code)
)
/*
2 rows from Ref_Transaction_Types table:
transaction_type_code transaction_type_description
SALE Sale
PUR Purchase
*/
CREATE TABLE "Sales" (
sales_transaction_id INTEGER,
sales_details VARCHAR(255),
PRIMARY KEY (sales_transaction_id),
FOREIGN KEY(sales_transaction_id) REFERENCES "Transactions" (transaction_id)
)
/*
2 rows from Sales table:
sales_transaction_id sales_details
1 x
2 o
*/
CREATE TABLE "Transactions" (
transaction_id INTEGER,
investor_id INTEGER NOT NULL,
transaction_type_code VARCHAR(10) NOT NULL,
date_of_transaction DATETIME,
amount_of_transaction DECIMAL(19, 4),
share_count VARCHAR(40),
other_details VARCHAR(255),
PRIMARY KEY (transaction_id),
FOREIGN KEY(transaction_type_code) REFERENCES "Ref_Transaction_Types" (transaction_type_code),
FOREIGN KEY(investor_id) REFERENCES "Investors" (investor_id)
)
/*
2 rows from Transactions table:
transaction_id investor_id transaction_type_code date_of_transaction amount_of_transaction share_count other_details
1 6 SALE 1988-09-16 19:02:51 302507.6996 8718572 None
2 18 PUR 1982-06-06 17:19:00 27.2570 9 None
*/
CREATE TABLE "Transactions_Lots" (
transaction_id INTEGER NOT NULL,
lot_id INTEGER NOT NULL,
FOREIGN KEY(transaction_id) REFERENCES "Transactions" (transaction_id),
FOREIGN KEY(lot_id) REFERENCES "Lots" (lot_id)
)
/*
2 rows from Transactions_Lots table:
transaction_id lot_id
3 11
3 8
*/ | Show the maximum amount of transaction. | SELECT max(amount_of_transaction) FROM TRANSACTIONS | [{'max(amount_of_transaction)': 207484122.2796}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/SQL] | [QUESTION]Show the id and name of the employee with maximum salary.[/QUESTION]
[SQL]SELECT eid , name FROM Employee ORDER BY salary DESC LIMIT 1[/SQL] |
||
assets_maintenance |
CREATE TABLE "Asset_Parts" (
asset_id INTEGER NOT NULL,
part_id INTEGER NOT NULL,
FOREIGN KEY(asset_id) REFERENCES "Assets" (asset_id),
FOREIGN KEY(part_id) REFERENCES "Parts" (part_id)
)
CREATE TABLE "Assets" (
asset_id INTEGER,
maintenance_contract_id INTEGER NOT NULL,
supplier_company_id INTEGER NOT NULL,
asset_details VARCHAR(255),
asset_make VARCHAR(20),
asset_model VARCHAR(20),
asset_acquired_date DATETIME,
asset_disposed_date DATETIME,
other_asset_details VARCHAR(255),
PRIMARY KEY (asset_id),
FOREIGN KEY(supplier_company_id) REFERENCES "Third_Party_Companies" (company_id),
FOREIGN KEY(maintenance_contract_id) REFERENCES "Maintenance_Contracts" (maintenance_contract_id)
)
CREATE TABLE "Engineer_Skills" (
engineer_id INTEGER NOT NULL,
skill_id INTEGER NOT NULL,
FOREIGN KEY(skill_id) REFERENCES "Skills" (skill_id),
FOREIGN KEY(engineer_id) REFERENCES "Maintenance_Engineers" (engineer_id)
)
CREATE TABLE "Engineer_Visits" (
engineer_visit_id INTEGER,
contact_staff_id INTEGER,
engineer_id INTEGER NOT NULL,
fault_log_entry_id INTEGER NOT NULL,
fault_status VARCHAR(10) NOT NULL,
visit_start_datetime DATETIME,
visit_end_datetime DATETIME,
other_visit_details VARCHAR(255),
PRIMARY KEY (engineer_visit_id),
FOREIGN KEY(contact_staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(engineer_id) REFERENCES "Maintenance_Engineers" (engineer_id),
FOREIGN KEY(fault_log_entry_id) REFERENCES "Fault_Log" (fault_log_entry_id)
)
CREATE TABLE "Fault_Log" (
fault_log_entry_id INTEGER,
asset_id INTEGER NOT NULL,
recorded_by_staff_id INTEGER NOT NULL,
fault_log_entry_datetime DATETIME,
fault_description VARCHAR(255),
other_fault_details VARCHAR(255),
PRIMARY KEY (fault_log_entry_id),
FOREIGN KEY(recorded_by_staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(asset_id) REFERENCES "Assets" (asset_id)
)
CREATE TABLE "Fault_Log_Parts" (
fault_log_entry_id INTEGER NOT NULL,
part_fault_id INTEGER NOT NULL,
fault_status VARCHAR(10) NOT NULL,
FOREIGN KEY(fault_log_entry_id) REFERENCES "Fault_Log" (fault_log_entry_id),
FOREIGN KEY(part_fault_id) REFERENCES "Part_Faults" (part_fault_id)
)
CREATE TABLE "Maintenance_Contracts" (
maintenance_contract_id INTEGER,
maintenance_contract_company_id INTEGER NOT NULL,
contract_start_date DATETIME,
contract_end_date DATETIME,
other_contract_details VARCHAR(255),
PRIMARY KEY (maintenance_contract_id),
FOREIGN KEY(maintenance_contract_company_id) REFERENCES "Third_Party_Companies" (company_id)
)
CREATE TABLE "Maintenance_Engineers" (
engineer_id INTEGER,
company_id INTEGER NOT NULL,
first_name VARCHAR(50),
last_name VARCHAR(50),
other_details VARCHAR(255),
PRIMARY KEY (engineer_id),
FOREIGN KEY(company_id) REFERENCES "Third_Party_Companies" (company_id)
)
CREATE TABLE "Part_Faults" (
part_fault_id INTEGER,
part_id INTEGER NOT NULL,
fault_short_name VARCHAR(20),
fault_description VARCHAR(255),
other_fault_details VARCHAR(255),
PRIMARY KEY (part_fault_id),
FOREIGN KEY(part_id) REFERENCES "Parts" (part_id)
)
CREATE TABLE "Parts" (
part_id INTEGER,
part_name VARCHAR(255),
chargeable_yn VARCHAR(1),
chargeable_amount VARCHAR(20),
other_part_details VARCHAR(255),
PRIMARY KEY (part_id)
)
CREATE TABLE "Skills" (
skill_id INTEGER,
skill_code VARCHAR(20),
skill_description VARCHAR(255),
PRIMARY KEY (skill_id)
)
CREATE TABLE "Skills_Required_To_Fix" (
part_fault_id INTEGER NOT NULL,
skill_id INTEGER NOT NULL,
FOREIGN KEY(skill_id) REFERENCES "Skills" (skill_id),
FOREIGN KEY(part_fault_id) REFERENCES "Part_Faults" (part_fault_id)
)
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_name VARCHAR(255),
gender VARCHAR(1),
other_staff_details VARCHAR(255),
PRIMARY KEY (staff_id)
)
CREATE TABLE "Third_Party_Companies" (
company_id INTEGER,
company_type VARCHAR(5) NOT NULL,
company_name VARCHAR(255),
company_address VARCHAR(255),
other_company_details VARCHAR(255),
PRIMARY KEY (company_id)
) |
CREATE TABLE "Asset_Parts" (
asset_id INTEGER NOT NULL,
part_id INTEGER NOT NULL,
FOREIGN KEY(asset_id) REFERENCES "Assets" (asset_id),
FOREIGN KEY(part_id) REFERENCES "Parts" (part_id)
)
/*
2 rows from Asset_Parts table:
asset_id part_id
5 3
3 3
*/
CREATE TABLE "Assets" (
asset_id INTEGER,
maintenance_contract_id INTEGER NOT NULL,
supplier_company_id INTEGER NOT NULL,
asset_details VARCHAR(255),
asset_make VARCHAR(20),
asset_model VARCHAR(20),
asset_acquired_date DATETIME,
asset_disposed_date DATETIME,
other_asset_details VARCHAR(255),
PRIMARY KEY (asset_id),
FOREIGN KEY(supplier_company_id) REFERENCES "Third_Party_Companies" (company_id),
FOREIGN KEY(maintenance_contract_id) REFERENCES "Maintenance_Contracts" (maintenance_contract_id)
)
/*
2 rows from Assets table:
asset_id maintenance_contract_id supplier_company_id asset_details asset_make asset_model asset_acquired_date asset_disposed_date other_asset_details
1 2 2 dell laptop1 PT 58 ub 2017-12-25 00:31:27 2018-03-14 10:50:00 None
2 14 1 dell laptop2 IN 35 xt 2018-01-27 00:59:46 2018-03-20 04:24:09 None
*/
CREATE TABLE "Engineer_Skills" (
engineer_id INTEGER NOT NULL,
skill_id INTEGER NOT NULL,
FOREIGN KEY(skill_id) REFERENCES "Skills" (skill_id),
FOREIGN KEY(engineer_id) REFERENCES "Maintenance_Engineers" (engineer_id)
)
/*
2 rows from Engineer_Skills table:
engineer_id skill_id
10 2
10 1
*/
CREATE TABLE "Engineer_Visits" (
engineer_visit_id INTEGER,
contact_staff_id INTEGER,
engineer_id INTEGER NOT NULL,
fault_log_entry_id INTEGER NOT NULL,
fault_status VARCHAR(10) NOT NULL,
visit_start_datetime DATETIME,
visit_end_datetime DATETIME,
other_visit_details VARCHAR(255),
PRIMARY KEY (engineer_visit_id),
FOREIGN KEY(contact_staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(engineer_id) REFERENCES "Maintenance_Engineers" (engineer_id),
FOREIGN KEY(fault_log_entry_id) REFERENCES "Fault_Log" (fault_log_entry_id)
)
/*
2 rows from Engineer_Visits table:
engineer_visit_id contact_staff_id engineer_id fault_log_entry_id fault_status visit_start_datetime visit_end_datetime other_visit_details
1 8 8 13 Waiting 1978-10-12 23:14:40 1988-01-07 06:41:51 None
2 7 15 13 Return 1980-05-02 23:31:18 1990-08-30 22:44:16 None
*/
CREATE TABLE "Fault_Log" (
fault_log_entry_id INTEGER,
asset_id INTEGER NOT NULL,
recorded_by_staff_id INTEGER NOT NULL,
fault_log_entry_datetime DATETIME,
fault_description VARCHAR(255),
other_fault_details VARCHAR(255),
PRIMARY KEY (fault_log_entry_id),
FOREIGN KEY(recorded_by_staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(asset_id) REFERENCES "Assets" (asset_id)
)
/*
2 rows from Fault_Log table:
fault_log_entry_id asset_id recorded_by_staff_id fault_log_entry_datetime fault_description other_fault_details
1 3 14 2018-03-21 04:25:00 system error None
2 7 4 2018-03-13 09:43:05 system error None
*/
CREATE TABLE "Fault_Log_Parts" (
fault_log_entry_id INTEGER NOT NULL,
part_fault_id INTEGER NOT NULL,
fault_status VARCHAR(10) NOT NULL,
FOREIGN KEY(fault_log_entry_id) REFERENCES "Fault_Log" (fault_log_entry_id),
FOREIGN KEY(part_fault_id) REFERENCES "Part_Faults" (part_fault_id)
)
/*
2 rows from Fault_Log_Parts table:
fault_log_entry_id part_fault_id fault_status
12 3 Reported
7 4 Reported
*/
CREATE TABLE "Maintenance_Contracts" (
maintenance_contract_id INTEGER,
maintenance_contract_company_id INTEGER NOT NULL,
contract_start_date DATETIME,
contract_end_date DATETIME,
other_contract_details VARCHAR(255),
PRIMARY KEY (maintenance_contract_id),
FOREIGN KEY(maintenance_contract_company_id) REFERENCES "Third_Party_Companies" (company_id)
)
/*
2 rows from Maintenance_Contracts table:
maintenance_contract_id maintenance_contract_company_id contract_start_date contract_end_date other_contract_details
1 15 2017-09-13 11:51:29 2018-03-16 21:21:50 None
2 9 2017-12-18 11:43:16 2018-03-22 06:00:37 None
*/
CREATE TABLE "Maintenance_Engineers" (
engineer_id INTEGER,
company_id INTEGER NOT NULL,
first_name VARCHAR(50),
last_name VARCHAR(50),
other_details VARCHAR(255),
PRIMARY KEY (engineer_id),
FOREIGN KEY(company_id) REFERENCES "Third_Party_Companies" (company_id)
)
/*
2 rows from Maintenance_Engineers table:
engineer_id company_id first_name last_name other_details
1 14 Etha Reinger Skilled
2 2 Clemens Orn None
*/
CREATE TABLE "Part_Faults" (
part_fault_id INTEGER,
part_id INTEGER NOT NULL,
fault_short_name VARCHAR(20),
fault_description VARCHAR(255),
other_fault_details VARCHAR(255),
PRIMARY KEY (part_fault_id),
FOREIGN KEY(part_id) REFERENCES "Parts" (part_id)
)
/*
2 rows from Part_Faults table:
part_fault_id part_id fault_short_name fault_description other_fault_details
1 1 PW Package Wrong None
2 1 PW Package Wrong None
*/
CREATE TABLE "Parts" (
part_id INTEGER,
part_name VARCHAR(255),
chargeable_yn VARCHAR(1),
chargeable_amount VARCHAR(20),
other_part_details VARCHAR(255),
PRIMARY KEY (part_id)
)
/*
2 rows from Parts table:
part_id part_name chargeable_yn chargeable_amount other_part_details
1 top 0 4 None
2 middle 1 9 None
*/
CREATE TABLE "Skills" (
skill_id INTEGER,
skill_code VARCHAR(20),
skill_description VARCHAR(255),
PRIMARY KEY (skill_id)
)
/*
2 rows from Skills table:
skill_id skill_code skill_description
1 ELEC Electrical
2 MECH Mechanical
*/
CREATE TABLE "Skills_Required_To_Fix" (
part_fault_id INTEGER NOT NULL,
skill_id INTEGER NOT NULL,
FOREIGN KEY(skill_id) REFERENCES "Skills" (skill_id),
FOREIGN KEY(part_fault_id) REFERENCES "Part_Faults" (part_fault_id)
)
/*
2 rows from Skills_Required_To_Fix table:
part_fault_id skill_id
3 2
12 3
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_name VARCHAR(255),
gender VARCHAR(1),
other_staff_details VARCHAR(255),
PRIMARY KEY (staff_id)
)
/*
2 rows from Staff table:
staff_id staff_name gender other_staff_details
1 Audreanne 1 Manager
2 Berneice 1 Manager
*/
CREATE TABLE "Third_Party_Companies" (
company_id INTEGER,
company_type VARCHAR(5) NOT NULL,
company_name VARCHAR(255),
company_address VARCHAR(255),
other_company_details VARCHAR(255),
PRIMARY KEY (company_id)
)
/*
2 rows from Third_Party_Companies table:
company_id company_type company_name company_address other_company_details
1 Maintenance Contractor Langworth-Funk 615 Jacobs Mews Uganda
2 Maintenance Contractor McDermott Group 873 Conrad Creek Apt. 286 China
*/ | Which kind of part has the least number of faults? List the part name. | SELECT T1.part_name FROM Parts AS T1 JOIN Part_Faults AS T2 ON T1.part_id = T2.part_id GROUP BY T1.part_name ORDER BY count(*) ASC LIMIT 1 | [{'part_name': 'middle'}] | Medium | false | false | false | true | true | true | false | true | false | false | false | false | false | ||||
station_weather |
CREATE TABLE route (
train_id INTEGER,
station_id INTEGER,
PRIMARY KEY (train_id, station_id),
FOREIGN KEY(station_id) REFERENCES station (id),
FOREIGN KEY(train_id) REFERENCES train (id)
)
CREATE TABLE station (
id INTEGER,
network_name TEXT,
services TEXT,
local_authority TEXT,
PRIMARY KEY (id)
)
CREATE TABLE train (
id INTEGER,
train_number INTEGER,
name TEXT,
origin TEXT,
destination TEXT,
time TEXT,
interval TEXT,
PRIMARY KEY (id)
)
CREATE TABLE weekly_weather (
station_id INTEGER,
day_of_week TEXT,
high_temperature INTEGER,
low_temperature INTEGER,
precipitation REAL,
wind_speed_mph INTEGER,
PRIMARY KEY (station_id, day_of_week),
FOREIGN KEY(station_id) REFERENCES station (id)
) |
CREATE TABLE route (
train_id INTEGER,
station_id INTEGER,
PRIMARY KEY (train_id, station_id),
FOREIGN KEY(station_id) REFERENCES station (id),
FOREIGN KEY(train_id) REFERENCES train (id)
)
/*
2 rows from route table:
train_id station_id
1 1
1 2
*/
CREATE TABLE station (
id INTEGER,
network_name TEXT,
services TEXT,
local_authority TEXT,
PRIMARY KEY (id)
)
/*
2 rows from station table:
id network_name services local_authority
1 Amersham Metropolitan line and Chiltern Railways Chiltern
2 Bushey London Overground and London Midland Watford
*/
CREATE TABLE train (
id INTEGER,
train_number INTEGER,
name TEXT,
origin TEXT,
destination TEXT,
time TEXT,
interval TEXT,
PRIMARY KEY (id)
)
/*
2 rows from train table:
id train_number name origin destination time interval
1 16724 Ananthapuri Express Trivandrum Chennai 17:15 Daily
2 16127 Guruvayur Express Chennai Guruvayur 22:10 Daily
*/
CREATE TABLE weekly_weather (
station_id INTEGER,
day_of_week TEXT,
high_temperature INTEGER,
low_temperature INTEGER,
precipitation REAL,
wind_speed_mph INTEGER,
PRIMARY KEY (station_id, day_of_week),
FOREIGN KEY(station_id) REFERENCES station (id)
)
/*
2 rows from weekly_weather table:
station_id day_of_week high_temperature low_temperature precipitation wind_speed_mph
1 Monday 59 54 90.0 13
1 Tuesday 66 55 20.0 12
*/ | Find the number of trains for each station, as well as the station network name and services. | SELECT count(*) , t1.network_name , t1.services FROM station AS t1 JOIN route AS t2 ON t1.id = t2.station_id GROUP BY t2.station_id | [{'count(*)': 3, 'network_name': 'Amersham', 'services': 'Metropolitan line and Chiltern Railways'}, {'count(*)': 2, 'network_name': 'Bushey', 'services': 'London Overground and London Midland'}, {'count(*)': 2, 'network_name': 'Brentwood', 'services': 'Greater Anglia'}, {'count(*)': 2, 'network_name': 'Broxbourne', 'services': 'Greater Anglia'}, {'count(*)': 2, 'network_name': 'Carpenders Park', 'services': 'London Overground'}, {'count(*)': 1, 'network_name': 'Chafford Hundred', 'services': 'c2c'}, {'count(*)': 2, 'network_name': 'Chalfont & Latimer', 'services': 'Metropolitan line and Chiltern Railways'}, {'count(*)': 3, 'network_name': 'Chesham', 'services': 'Metropolitan line'}, {'count(*)': 1, 'network_name': 'Cheshunt', 'services': 'Greater Anglia'}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | [QUESTION]Find the number of employees hired in each shop; show the shop name as well.[/QUESTION]
[SQL]SELECT count(*) , t2.name FROM hiring AS t1 JOIN shop AS t2 ON t1.shop_id = t2.shop_id GROUP BY t2.name[/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 largest state that borders the state with the highest population | SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state WHERE state_name IN ( SELECT state_name FROM border_info WHERE border IN ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) ) ) ) AND state_name IN ( SELECT state_name FROM border_info WHERE border IN ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) ) ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] | [QUESTION]how many states border the largest state[/QUESTION]
[SQL]SELECT COUNT ( border ) FROM border_info WHERE state_name = ( SELECT state_name FROM state WHERE area = ( SELECT MAX ( area ) FROM state ) );[/SQL] |
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
*/ | Which job titles correspond to jobs with salaries over 9000? | SELECT job_title FROM jobs WHERE min_salary > 9000 | [{'JOB_TITLE': 'President'}, {'JOB_TITLE': 'Administration Vice President'}, {'JOB_TITLE': 'Sales Manager'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many employees have salary between 100000 and 200000?[/QUESTION]
[SQL]SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000[/SQL] | [QUESTION]How many employees have salary between 100000 and 200000?[/QUESTION]
[SQL]SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000[/SQL] | [QUESTION]How many employees have salary between 100000 and 200000?[/QUESTION]
[SQL]SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000[/SQL] | [QUESTION]How many employees have salary between 100000 and 200000?[/QUESTION]
[SQL]SELECT count(*) FROM Employee WHERE salary BETWEEN 100000 AND 200000[/SQL] |
manufacturer |
CREATE TABLE furniture (
"Furniture_ID" INTEGER,
"Name" TEXT,
"Num_of_Component" INTEGER,
"Market_Rate" REAL,
PRIMARY KEY ("Furniture_ID")
)
CREATE TABLE furniture_manufacte (
"Manufacturer_ID" INTEGER,
"Furniture_ID" INTEGER,
"Price_in_Dollar" REAL,
PRIMARY KEY ("Manufacturer_ID", "Furniture_ID"),
FOREIGN KEY("Furniture_ID") REFERENCES furniture ("Furniture_ID"),
FOREIGN KEY("Manufacturer_ID") REFERENCES manufacturer ("Manufacturer_ID")
)
CREATE TABLE manufacturer (
"Manufacturer_ID" INTEGER,
"Open_Year" REAL,
"Name" TEXT,
"Num_of_Factories" INTEGER,
"Num_of_Shops" INTEGER,
PRIMARY KEY ("Manufacturer_ID")
) |
CREATE TABLE furniture (
"Furniture_ID" INTEGER,
"Name" TEXT,
"Num_of_Component" INTEGER,
"Market_Rate" REAL,
PRIMARY KEY ("Furniture_ID")
)
/*
2 rows from furniture table:
Furniture_ID Name Num_of_Component Market_Rate
1 Billiard table 14 52.5
2 Chabudai 4 40.0
*/
CREATE TABLE furniture_manufacte (
"Manufacturer_ID" INTEGER,
"Furniture_ID" INTEGER,
"Price_in_Dollar" REAL,
PRIMARY KEY ("Manufacturer_ID", "Furniture_ID"),
FOREIGN KEY("Furniture_ID") REFERENCES furniture ("Furniture_ID"),
FOREIGN KEY("Manufacturer_ID") REFERENCES manufacturer ("Manufacturer_ID")
)
/*
2 rows from furniture_manufacte table:
Manufacturer_ID Furniture_ID Price_in_Dollar
1 3 239.0
4 2 450.0
*/
CREATE TABLE manufacturer (
"Manufacturer_ID" INTEGER,
"Open_Year" REAL,
"Name" TEXT,
"Num_of_Factories" INTEGER,
"Num_of_Shops" INTEGER,
PRIMARY KEY ("Manufacturer_ID")
)
/*
2 rows from manufacturer table:
Manufacturer_ID Open_Year Name Num_of_Factories Num_of_Shops
1 1980.0 Chevrolet House 36 8
2 1990.0 IKEA 21 19
*/ | find the total market rate of the furnitures that have the top 2 market shares. | SELECT sum(market_rate) FROM furniture ORDER BY market_rate DESC LIMIT 2 | [{'sum(market_rate)': 100.0}] | Easy | false | false | false | true | true | false | false | false | false | false | false | false | false | ||||
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
*/ | What is the total revenue of each manufacturer? | SELECT sum(revenue) , name FROM manufacturers GROUP BY name | [{'sum(revenue)': 100.0, 'Name': 'Creative Labs'}, {'sum(revenue)': 130.0, 'Name': 'Fujitsu'}, {'sum(revenue)': 50.0, 'Name': 'Hewlett-Packard'}, {'sum(revenue)': 200.0, 'Name': 'Iomega'}, {'sum(revenue)': 120.0, 'Name': 'Sony'}, {'sum(revenue)': 30.0, 'Name': 'Winchester'}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | ||||
company_office |
CREATE TABLE "Companies" (
id INTEGER,
name TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_billion" REAL,
"Profits_billion" REAL,
"Assets_billion" REAL,
"Market_Value_billion" TEXT,
PRIMARY KEY (id)
)
CREATE TABLE "Office_locations" (
building_id INTEGER,
company_id INTEGER,
move_in_year INTEGER,
PRIMARY KEY (building_id, company_id),
FOREIGN KEY(building_id) REFERENCES buildings (id),
FOREIGN KEY(company_id) REFERENCES "Companies" (id)
)
CREATE TABLE buildings (
id INTEGER,
name TEXT,
"City" TEXT,
"Height" INTEGER,
"Stories" INTEGER,
"Status" TEXT,
PRIMARY KEY (id)
) |
CREATE TABLE "Companies" (
id INTEGER,
name TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_billion" REAL,
"Profits_billion" REAL,
"Assets_billion" REAL,
"Market_Value_billion" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from Companies table:
id name Headquarters Industry Sales_billion Profits_billion Assets_billion Market_Value_billion
1 JPMorgan Chase USA Banking 115.5 17.4 2117.6 182.2
2 HSBC UK Banking 103.3 13.3 2467.9 186.5
*/
CREATE TABLE "Office_locations" (
building_id INTEGER,
company_id INTEGER,
move_in_year INTEGER,
PRIMARY KEY (building_id, company_id),
FOREIGN KEY(building_id) REFERENCES buildings (id),
FOREIGN KEY(company_id) REFERENCES "Companies" (id)
)
/*
2 rows from Office_locations table:
building_id company_id move_in_year
1 1 2021
2 2 2022
*/
CREATE TABLE buildings (
id INTEGER,
name TEXT,
"City" TEXT,
"Height" INTEGER,
"Stories" INTEGER,
"Status" TEXT,
PRIMARY KEY (id)
)
/*
2 rows from buildings table:
id name City Height Stories Status
1 Torre KOI Monterrey 220 67 under construction
2 Torre Mitikah Mexico City 210 60 under construction
*/ | List the industry shared by the most companies. | SELECT Industry FROM Companies GROUP BY Industry ORDER BY COUNT(*) DESC LIMIT 1 | [{'Industry': 'Banking'}] | Easy | false | false | false | true | true | true | 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 luisg@embraer.com.br 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None leonekohler@surfeu.de 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 andrew@chinookcorp.com
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 nancy@chinookcorp.com
*/
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
*/ | List the state in the US with the most invoices. | SELECT billing_state , COUNT(*) FROM invoices WHERE billing_country = "USA" GROUP BY billing_state ORDER BY COUNT(*) DESC LIMIT 1; | [{'billing_state': 'CA', 'COUNT(*)': 21}] | Easy | false | false | false | true | true | true | false | false | false | false | false | false | false | [QUESTION]Which state has the greatest total number of bank customers?[/QUESTION]
[SQL]SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1[/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 are the names and descriptions of the photos taken at the tourist attraction "film festival"? | SELECT T1.Name , T1.Description FROM PHOTOS AS T1 JOIN TOURIST_ATTRACTIONS AS T2 ON T1.Tourist_Attraction_ID = T2.Tourist_Attraction_ID WHERE T2.Name = "film festival" | [{'Name': 'park1', 'Description': None}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | ||||
customer_complaints |
CREATE TABLE "Complaints" (
complaint_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
complaint_outcome_code VARCHAR(20) NOT NULL,
complaint_status_code VARCHAR(20) NOT NULL,
complaint_type_code VARCHAR(20) NOT NULL,
date_complaint_raised DATETIME,
date_complaint_closed DATETIME,
staff_id INTEGER NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id)
)
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_type_code VARCHAR(20) NOT NULL,
address_line_1 VARCHAR(80),
address_line_2 VARCHAR(80),
town_city VARCHAR(80),
state VARCHAR(80),
email_address VARCHAR(255),
phone_number VARCHAR(80),
PRIMARY KEY (customer_id)
)
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
product_category_code VARCHAR(20) NOT NULL,
date_product_first_available DATETIME,
date_product_discontinued DATETIME,
product_name VARCHAR(80),
product_description VARCHAR(255),
product_price DECIMAL(19, 4),
PRIMARY KEY (product_id)
)
CREATE TABLE "Staff" (
staff_id INTEGER,
gender VARCHAR(1),
first_name VARCHAR(80),
last_name VARCHAR(80),
email_address VARCHAR(255),
phone_number VARCHAR(80),
PRIMARY KEY (staff_id)
) |
CREATE TABLE "Complaints" (
complaint_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
complaint_outcome_code VARCHAR(20) NOT NULL,
complaint_status_code VARCHAR(20) NOT NULL,
complaint_type_code VARCHAR(20) NOT NULL,
date_complaint_raised DATETIME,
date_complaint_closed DATETIME,
staff_id INTEGER NOT NULL,
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id)
)
/*
2 rows from Complaints table:
complaint_id product_id customer_id complaint_outcome_code complaint_status_code complaint_type_code date_complaint_raised date_complaint_closed staff_id
1 117 120 OK Closed Product Failure 2002-07-18 10:59:35 1976-04-19 11:03:06 114
2 118 113 OK New Product Unusable 1973-02-10 22:55:56 2013-09-14 02:59:10 120
*/
CREATE TABLE "Customers" (
customer_id INTEGER,
customer_type_code VARCHAR(20) NOT NULL,
address_line_1 VARCHAR(80),
address_line_2 VARCHAR(80),
town_city VARCHAR(80),
state VARCHAR(80),
email_address VARCHAR(255),
phone_number VARCHAR(80),
PRIMARY KEY (customer_id)
)
/*
2 rows from Customers table:
customer_id customer_type_code address_line_1 address_line_2 town_city state email_address phone_number
113 Good Credit Rating 144 Legros Landing Apt. 551 Maryamport Kansas hsteuber@example.org 06963347450
114 Good Credit Rating 039 Jedidiah Estate Suite 537 Apt. 245 Sauerberg Hawaii cayla.satterfield@example.net 470-803-0244
*/
CREATE TABLE "Products" (
product_id INTEGER,
parent_product_id INTEGER,
product_category_code VARCHAR(20) NOT NULL,
date_product_first_available DATETIME,
date_product_discontinued DATETIME,
product_name VARCHAR(80),
product_description VARCHAR(255),
product_price DECIMAL(19, 4),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id parent_product_id product_category_code date_product_first_available date_product_discontinued product_name product_description product_price
117 4 Food 1988-09-29 17:54:50 1987-12-20 13:46:16 Chocolate Handmade chocolate 2.8800
118 3 Book 1974-06-25 12:26:47 1991-08-20 05:22:31 The Great Gatsby American novel 35.0000
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
gender VARCHAR(1),
first_name VARCHAR(80),
last_name VARCHAR(80),
email_address VARCHAR(255),
phone_number VARCHAR(80),
PRIMARY KEY (staff_id)
)
/*
2 rows from Staff table:
staff_id gender first_name last_name email_address phone_number
114 0 Ward Boehm marcelle.ritchie@example.com (379)551-0838x146
115 1 Lucie Lowe ohintz@example.org 142-311-6503x206
*/ | What are lines 1 and 2 of the addressed of the customer with the email "vbogisich@example.org"? | SELECT address_line_1 , address_line_2 FROM customers WHERE email_address = "vbogisich@example.org" | [{'address_line_1': '72144 Katlynn Flat Suite 512', 'address_line_2': 'Suite 959'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the first and second line for all addresses?[/QUESTION]
[SQL]SELECT line_1 , line_2 FROM addresses[/SQL] | [QUESTION]What is the first and second line for all addresses?[/QUESTION]
[SQL]SELECT line_1 , line_2 FROM addresses[/SQL] | [QUESTION]What is the first and second line for all addresses?[/QUESTION]
[SQL]SELECT line_1 , line_2 FROM addresses[/SQL] | [QUESTION]What is the first and second line for all addresses?[/QUESTION]
[SQL]SELECT line_1 , line_2 FROM addresses[/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
*/ | Count the number of songs. | SELECT count(*) FROM Songs | [{'count(*)': 0}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]Show the names of singers that have more than one song.[/QUESTION]
[SQL]SELECT T1.Name FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID = T2.Singer_ID GROUP BY T1.Name HAVING COUNT(*) > 1[/SQL] | [QUESTION]Show the names of singers that have more than one song.[/QUESTION]
[SQL]SELECT T1.Name FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID = T2.Singer_ID GROUP BY T1.Name HAVING COUNT(*) > 1[/SQL] | [QUESTION]Show the names of singers that have more than one song.[/QUESTION]
[SQL]SELECT T1.Name FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID = T2.Singer_ID GROUP BY T1.Name HAVING COUNT(*) > 1[/SQL] | [QUESTION]Show the names of singers that have more than one song.[/QUESTION]
[SQL]SELECT T1.Name FROM singer AS T1 JOIN song AS T2 ON T1.Singer_ID = T2.Singer_ID GROUP BY T1.Name HAVING COUNT(*) > 1[/SQL] |
insurance_policies |
CREATE TABLE "Claims" (
"Claim_ID" INTEGER NOT NULL,
"Policy_ID" INTEGER NOT NULL,
"Date_Claim_Made" DATE,
"Date_Claim_Settled" DATE,
"Amount_Claimed" INTEGER,
"Amount_Settled" INTEGER,
PRIMARY KEY ("Claim_ID"),
FOREIGN KEY("Policy_ID") REFERENCES "Customer_Policies" ("Policy_ID")
)
CREATE TABLE "Customer_Policies" (
"Policy_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Policy_Type_Code" CHAR(15) NOT NULL,
"Start_Date" DATE,
"End_Date" DATE,
PRIMARY KEY ("Policy_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Customers" ("Customer_ID")
)
CREATE TABLE "Customers" (
"Customer_ID" INTEGER NOT NULL,
"Customer_Details" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Customer_ID")
)
CREATE TABLE "Payments" (
"Payment_ID" INTEGER NOT NULL,
"Settlement_ID" INTEGER NOT NULL,
"Payment_Method_Code" VARCHAR(255),
"Date_Payment_Made" DATE,
"Amount_Payment" INTEGER,
PRIMARY KEY ("Payment_ID"),
FOREIGN KEY("Settlement_ID") REFERENCES "Settlements" ("Settlement_ID")
)
CREATE TABLE "Settlements" (
"Settlement_ID" INTEGER NOT NULL,
"Claim_ID" INTEGER NOT NULL,
"Date_Claim_Made" DATE,
"Date_Claim_Settled" DATE,
"Amount_Claimed" INTEGER,
"Amount_Settled" INTEGER,
"Customer_Policy_ID" INTEGER NOT NULL,
PRIMARY KEY ("Settlement_ID"),
FOREIGN KEY("Claim_ID") REFERENCES "Claims" ("Claim_ID")
) |
CREATE TABLE "Claims" (
"Claim_ID" INTEGER NOT NULL,
"Policy_ID" INTEGER NOT NULL,
"Date_Claim_Made" DATE,
"Date_Claim_Settled" DATE,
"Amount_Claimed" INTEGER,
"Amount_Settled" INTEGER,
PRIMARY KEY ("Claim_ID"),
FOREIGN KEY("Policy_ID") REFERENCES "Customer_Policies" ("Policy_ID")
)
/*
2 rows from Claims table:
Claim_ID Policy_ID Date_Claim_Made Date_Claim_Settled Amount_Claimed Amount_Settled
143 744 2017-03-11 2017-11-03 43884 1085
423 552 2016-08-12 2018-01-27 79134 1724
*/
CREATE TABLE "Customer_Policies" (
"Policy_ID" INTEGER NOT NULL,
"Customer_ID" INTEGER NOT NULL,
"Policy_Type_Code" CHAR(15) NOT NULL,
"Start_Date" DATE,
"End_Date" DATE,
PRIMARY KEY ("Policy_ID"),
FOREIGN KEY("Customer_ID") REFERENCES "Customers" ("Customer_ID")
)
/*
2 rows from Customer_Policies table:
Policy_ID Customer_ID Policy_Type_Code Start_Date End_Date
119 1 Car 2018-01-21 2017-12-15
141 2 Life 2017-08-21 2017-09-29
*/
CREATE TABLE "Customers" (
"Customer_ID" INTEGER NOT NULL,
"Customer_Details" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Customer_ID")
)
/*
2 rows from Customers table:
Customer_ID Customer_Details
1 America Jaskolski
2 Ellsworth Paucek
*/
CREATE TABLE "Payments" (
"Payment_ID" INTEGER NOT NULL,
"Settlement_ID" INTEGER NOT NULL,
"Payment_Method_Code" VARCHAR(255),
"Date_Payment_Made" DATE,
"Amount_Payment" INTEGER,
PRIMARY KEY ("Payment_ID"),
FOREIGN KEY("Settlement_ID") REFERENCES "Settlements" ("Settlement_ID")
)
/*
2 rows from Payments table:
Payment_ID Settlement_ID Payment_Method_Code Date_Payment_Made Amount_Payment
384 516 MasterCard 2018-02-16 241730
435 476 MasterCard 2017-05-28 448613
*/
CREATE TABLE "Settlements" (
"Settlement_ID" INTEGER NOT NULL,
"Claim_ID" INTEGER NOT NULL,
"Date_Claim_Made" DATE,
"Date_Claim_Settled" DATE,
"Amount_Claimed" INTEGER,
"Amount_Settled" INTEGER,
"Customer_Policy_ID" INTEGER NOT NULL,
PRIMARY KEY ("Settlement_ID"),
FOREIGN KEY("Claim_ID") REFERENCES "Claims" ("Claim_ID")
)
/*
2 rows from Settlements table:
Settlement_ID Claim_ID Date_Claim_Made Date_Claim_Settled Amount_Claimed Amount_Settled Customer_Policy_ID
357 486 2018-08-07 2018-01-16 38543 1181 515
412 621 2017-08-27 2018-02-04 57669 1427 617
*/ | Give me the payment Id, the date and the amount for all the payments processed with Visa. | SELECT Payment_ID , Date_Payment_Made , Amount_Payment FROM Payments WHERE Payment_Method_Code = 'Visa' | [{'Payment_ID': 678, 'Date_Payment_Made': '2017-12-16', 'Amount_Payment': 459407}, {'Payment_ID': 754, 'Date_Payment_Made': '2018-02-24', 'Amount_Payment': 7343}, {'Payment_ID': 779, 'Date_Payment_Made': '2017-05-28', 'Amount_Payment': 155654}, {'Payment_ID': 791, 'Date_Payment_Made': '2017-05-03', 'Amount_Payment': 172309}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | ||||
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 has the greatest population | SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ); | [{'Nenhum': 'Nenhum resultado encontrado'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | [QUESTION]how many rivers are in the state with the largest population[/QUESTION]
[SQL]SELECT COUNT ( t2.river_name ) FROM river AS t2 JOIN state AS t1 ON t1.state_name = t2.traverse WHERE t1.state_name = ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) );[/SQL] | [QUESTION]how many rivers are in the state with the largest population[/QUESTION]
[SQL]SELECT COUNT ( t2.river_name ) FROM river AS t2 JOIN state AS t1 ON t1.state_name = t2.traverse WHERE t1.state_name = ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) );[/SQL] | [QUESTION]how many rivers are in the state with the largest population[/QUESTION]
[SQL]SELECT COUNT ( t2.river_name ) FROM river AS t2 JOIN state AS t1 ON t1.state_name = t2.traverse WHERE t1.state_name = ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) );[/SQL] | [QUESTION]how many rivers are in the state with the largest population[/QUESTION]
[SQL]SELECT COUNT ( t2.river_name ) FROM river AS t2 JOIN state AS t1 ON t1.state_name = t2.traverse WHERE t1.state_name = ( SELECT state_name FROM state WHERE population = ( SELECT MAX ( population ) FROM state ) );[/SQL] |
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 employee ids and job titles for employees in department 80? | SELECT T1.employee_id , T2.job_title FROM employees AS T1 JOIN jobs AS T2 ON T1.job_id = T2.job_id WHERE T1.department_id = 80 | [{'EMPLOYEE_ID': 145, 'JOB_TITLE': 'Sales Manager'}, {'EMPLOYEE_ID': 146, 'JOB_TITLE': 'Sales Manager'}, {'EMPLOYEE_ID': 147, 'JOB_TITLE': 'Sales Manager'}, {'EMPLOYEE_ID': 148, 'JOB_TITLE': 'Sales Manager'}, {'EMPLOYEE_ID': 149, 'JOB_TITLE': 'Sales Manager'}, {'EMPLOYEE_ID': 150, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 151, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 152, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 153, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 154, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 155, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 156, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 157, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 158, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 159, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 160, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 161, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 162, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 163, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 164, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 165, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 166, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 167, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 168, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 169, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 170, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 171, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 172, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 173, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 174, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 175, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 176, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 177, 'JOB_TITLE': 'Sales Representative'}, {'EMPLOYEE_ID': 179, 'JOB_TITLE': 'Sales Representative'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]What are the ids of all employees that don't have certificates?[/QUESTION]
[SQL]SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate[/SQL] | [QUESTION]What are the ids of all employees that don't have certificates?[/QUESTION]
[SQL]SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate[/SQL] | [QUESTION]What are the ids of all employees that don't have certificates?[/QUESTION]
[SQL]SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate[/SQL] | [QUESTION]What are the ids of all employees that don't have certificates?[/QUESTION]
[SQL]SELECT eid FROM Employee EXCEPT SELECT eid FROM Certificate[/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 people live in the united states | SELECT SUM ( population ) FROM state; | [{'SUM ( population )': None}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What is the total number of people living in the nations that do not use English?[/QUESTION]
[SQL]SELECT sum(Population) FROM country WHERE Name NOT IN (SELECT T1.Name FROM country AS T1 JOIN countrylanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = "English")[/SQL] | [QUESTION]What is the total number of people living in the nations that do not use English?[/QUESTION]
[SQL]SELECT sum(Population) FROM country WHERE Name NOT IN (SELECT T1.Name FROM country AS T1 JOIN countrylanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = "English")[/SQL] | [QUESTION]What is the total number of people living in the nations that do not use English?[/QUESTION]
[SQL]SELECT sum(Population) FROM country WHERE Name NOT IN (SELECT T1.Name FROM country AS T1 JOIN countrylanguage AS T2 ON T1.Code = T2.CountryCode WHERE T2.Language = "English")[/SQL] |
|
car_1 |
CREATE TABLE car_makers (
"Id" INTEGER,
"Maker" TEXT,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY("Country") REFERENCES countries ("CountryId")
)
CREATE TABLE car_names (
"MakeId" INTEGER,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY("Model") REFERENCES model_list ("Model")
)
CREATE TABLE cars_data (
"Id" INTEGER,
"MPG" TEXT,
"Cylinders" INTEGER,
"Edispl" REAL,
"Horsepower" TEXT,
"Weight" INTEGER,
"Accelerate" REAL,
"Year" INTEGER,
PRIMARY KEY ("Id"),
FOREIGN KEY("Id") REFERENCES car_names ("MakeId")
)
CREATE TABLE continents (
"ContId" INTEGER,
"Continent" TEXT,
PRIMARY KEY ("ContId")
)
CREATE TABLE countries (
"CountryId" INTEGER,
"CountryName" TEXT,
"Continent" INTEGER,
PRIMARY KEY ("CountryId"),
FOREIGN KEY("Continent") REFERENCES continents ("ContId")
)
CREATE TABLE model_list (
"ModelId" INTEGER,
"Maker" INTEGER,
"Model" TEXT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY("Maker") REFERENCES car_makers ("Id"),
UNIQUE ("Model")
) |
CREATE TABLE car_makers (
"Id" INTEGER,
"Maker" TEXT,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY("Country") REFERENCES countries ("CountryId")
)
/*
2 rows from car_makers table:
Id Maker FullName Country
1 amc American Motor Company 1
2 volkswagen Volkswagen 2
*/
CREATE TABLE car_names (
"MakeId" INTEGER,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY("Model") REFERENCES model_list ("Model")
)
/*
2 rows from car_names table:
MakeId Model Make
1 chevrolet chevrolet chevelle malibu
2 buick buick skylark 320
*/
CREATE TABLE cars_data (
"Id" INTEGER,
"MPG" TEXT,
"Cylinders" INTEGER,
"Edispl" REAL,
"Horsepower" TEXT,
"Weight" INTEGER,
"Accelerate" REAL,
"Year" INTEGER,
PRIMARY KEY ("Id"),
FOREIGN KEY("Id") REFERENCES car_names ("MakeId")
)
/*
2 rows from cars_data table:
Id MPG Cylinders Edispl Horsepower Weight Accelerate Year
1 18 8 307.0 130 3504 12.0 1970
2 15 8 350.0 165 3693 11.5 1970
*/
CREATE TABLE continents (
"ContId" INTEGER,
"Continent" TEXT,
PRIMARY KEY ("ContId")
)
/*
2 rows from continents table:
ContId Continent
1 america
2 europe
*/
CREATE TABLE countries (
"CountryId" INTEGER,
"CountryName" TEXT,
"Continent" INTEGER,
PRIMARY KEY ("CountryId"),
FOREIGN KEY("Continent") REFERENCES continents ("ContId")
)
/*
2 rows from countries table:
CountryId CountryName Continent
1 usa 1
2 germany 2
*/
CREATE TABLE model_list (
"ModelId" INTEGER,
"Maker" INTEGER,
"Model" TEXT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY("Maker") REFERENCES car_makers ("Id"),
UNIQUE ("Model")
)
/*
2 rows from model_list table:
ModelId Maker Model
1 1 amc
2 2 audi
*/ | Among the cars that do not have the minimum horsepower , what are the make ids and names of all those with less than 4 cylinders ? | SELECT t2.makeid , t2.make FROM cars_data AS t1 JOIN car_names AS t2 ON t1.id = t2.makeid WHERE t1.horsepower > (SELECT min(horsepower) FROM cars_data) AND t1.cylinders < 4; | [{'MakeId': 79, 'Make': 'mazda rx2 coupe'}, {'MakeId': 119, 'Make': 'mazda rx3'}, {'MakeId': 251, 'Make': 'mazda rx-4'}] | Medium | false | false | false | false | false | false | false | true | false | false | false | false | false | [QUESTION]What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?[/QUESTION]
[SQL]SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING count(*) >= 2 INTERSECT SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING count(*) > 3;[/SQL] | [QUESTION]What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?[/QUESTION]
[SQL]SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING count(*) >= 2 INTERSECT SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING count(*) > 3;[/SQL] | [QUESTION]What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?[/QUESTION]
[SQL]SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING count(*) >= 2 INTERSECT SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING count(*) > 3;[/SQL] | [QUESTION]What are the ids and makers of all car makers that produce at least 2 models and make more than 3 cars?[/QUESTION]
[SQL]SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker GROUP BY T1.Id HAVING count(*) >= 2 INTERSECT SELECT T1.Id , T1.Maker FROM CAR_MAKERS AS T1 JOIN MODEL_LIST AS T2 ON T1.Id = T2.Maker JOIN CAR_NAMES AS T3 ON T2.model = T3.model GROUP BY T1.Id HAVING count(*) > 3;[/SQL] |
tracking_grants_for_research |
CREATE TABLE "Document_Types" (
document_type_code VARCHAR(10),
document_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
CREATE TABLE "Documents" (
document_id INTEGER,
document_type_code VARCHAR(10),
grant_id INTEGER NOT NULL,
sent_date DATETIME NOT NULL,
response_received_date DATETIME NOT NULL,
other_details VARCHAR(255) NOT NULL,
PRIMARY KEY (document_id),
FOREIGN KEY(grant_id) REFERENCES "Grants" (grant_id),
FOREIGN KEY(document_type_code) REFERENCES "Document_Types" (document_type_code)
)
CREATE TABLE "Grants" (
grant_id INTEGER,
organisation_id INTEGER NOT NULL,
grant_amount DECIMAL(19, 4) DEFAULT 0 NOT NULL,
grant_start_date DATETIME NOT NULL,
grant_end_date DATETIME NOT NULL,
other_details VARCHAR(255) NOT NULL,
PRIMARY KEY (grant_id),
FOREIGN KEY(organisation_id) REFERENCES "Organisations" (organisation_id)
)
CREATE TABLE "Organisation_Types" (
organisation_type VARCHAR(10),
organisation_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (organisation_type)
)
CREATE TABLE "Organisations" (
organisation_id INTEGER,
organisation_type VARCHAR(10) NOT NULL,
organisation_details VARCHAR(255) NOT NULL,
PRIMARY KEY (organisation_id),
FOREIGN KEY(organisation_type) REFERENCES "Organisation_Types" (organisation_type)
)
CREATE TABLE "Project_Outcomes" (
project_id INTEGER NOT NULL,
outcome_code VARCHAR(10) NOT NULL,
outcome_details VARCHAR(255),
FOREIGN KEY(outcome_code) REFERENCES "Research_Outcomes" (outcome_code),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
)
CREATE TABLE "Project_Staff" (
staff_id DOUBLE,
project_id INTEGER NOT NULL,
role_code VARCHAR(10) NOT NULL,
date_from DATETIME,
date_to DATETIME,
other_details VARCHAR(255),
PRIMARY KEY (staff_id),
FOREIGN KEY(role_code) REFERENCES "Staff_Roles" (role_code),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
)
CREATE TABLE "Projects" (
project_id INTEGER,
organisation_id INTEGER NOT NULL,
project_details VARCHAR(255) NOT NULL,
PRIMARY KEY (project_id),
FOREIGN KEY(organisation_id) REFERENCES "Organisations" (organisation_id)
)
CREATE TABLE "Research_Outcomes" (
outcome_code VARCHAR(10),
outcome_description VARCHAR(255) NOT NULL,
PRIMARY KEY (outcome_code)
)
CREATE TABLE "Research_Staff" (
staff_id INTEGER,
employer_organisation_id INTEGER NOT NULL,
staff_details VARCHAR(255) NOT NULL,
PRIMARY KEY (staff_id),
FOREIGN KEY(employer_organisation_id) REFERENCES "Organisations" (organisation_id)
)
CREATE TABLE "Staff_Roles" (
role_code VARCHAR(10),
role_description VARCHAR(255) NOT NULL,
PRIMARY KEY (role_code)
)
CREATE TABLE "Tasks" (
task_id INTEGER,
project_id INTEGER NOT NULL,
task_details VARCHAR(255) NOT NULL,
"eg Agree Objectives" VARCHAR(1),
PRIMARY KEY (task_id),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
) |
CREATE TABLE "Document_Types" (
document_type_code VARCHAR(10),
document_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
/*
2 rows from Document_Types table:
document_type_code document_description
APP Initial Application
REG Regular
*/
CREATE TABLE "Documents" (
document_id INTEGER,
document_type_code VARCHAR(10),
grant_id INTEGER NOT NULL,
sent_date DATETIME NOT NULL,
response_received_date DATETIME NOT NULL,
other_details VARCHAR(255) NOT NULL,
PRIMARY KEY (document_id),
FOREIGN KEY(grant_id) REFERENCES "Grants" (grant_id),
FOREIGN KEY(document_type_code) REFERENCES "Document_Types" (document_type_code)
)
/*
2 rows from Documents table:
document_id document_type_code grant_id sent_date response_received_date other_details
1 APP 5 1986-11-30 07:56:35 1977-12-01 02:18:53
2 APP 13 2004-01-23 11:57:08 1979-12-08 10:38:07
*/
CREATE TABLE "Grants" (
grant_id INTEGER,
organisation_id INTEGER NOT NULL,
grant_amount DECIMAL(19, 4) DEFAULT 0 NOT NULL,
grant_start_date DATETIME NOT NULL,
grant_end_date DATETIME NOT NULL,
other_details VARCHAR(255) NOT NULL,
PRIMARY KEY (grant_id),
FOREIGN KEY(organisation_id) REFERENCES "Organisations" (organisation_id)
)
/*
2 rows from Grants table:
grant_id organisation_id grant_amount grant_start_date grant_end_date other_details
1 10 4094.5420 2016-11-20 00:18:51 2004-10-24 09:09:39 et
2 3 281.2446 1985-10-09 20:08:49 1985-06-08 00:22:07 occaecati
*/
CREATE TABLE "Organisation_Types" (
organisation_type VARCHAR(10),
organisation_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (organisation_type)
)
/*
2 rows from Organisation_Types table:
organisation_type organisation_type_description
RES Research
SPON Sponsor
*/
CREATE TABLE "Organisations" (
organisation_id INTEGER,
organisation_type VARCHAR(10) NOT NULL,
organisation_details VARCHAR(255) NOT NULL,
PRIMARY KEY (organisation_id),
FOREIGN KEY(organisation_type) REFERENCES "Organisation_Types" (organisation_type)
)
/*
2 rows from Organisations table:
organisation_id organisation_type organisation_details
1 RES et
2 RES eius
*/
CREATE TABLE "Project_Outcomes" (
project_id INTEGER NOT NULL,
outcome_code VARCHAR(10) NOT NULL,
outcome_details VARCHAR(255),
FOREIGN KEY(outcome_code) REFERENCES "Research_Outcomes" (outcome_code),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
)
/*
2 rows from Project_Outcomes table:
project_id outcome_code outcome_details
4 Paper None
3 Patent None
*/
CREATE TABLE "Project_Staff" (
staff_id DOUBLE,
project_id INTEGER NOT NULL,
role_code VARCHAR(10) NOT NULL,
date_from DATETIME,
date_to DATETIME,
other_details VARCHAR(255),
PRIMARY KEY (staff_id),
FOREIGN KEY(role_code) REFERENCES "Staff_Roles" (role_code),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
)
/*
2 rows from Project_Staff table:
staff_id project_id role_code date_from date_to other_details
0.0 2 leader 1981-10-04 22:44:50 1985-05-30 22:26:30 None
674810.0 5 leader 2003-04-19 15:06:20 2010-12-08 11:55:36 None
*/
CREATE TABLE "Projects" (
project_id INTEGER,
organisation_id INTEGER NOT NULL,
project_details VARCHAR(255) NOT NULL,
PRIMARY KEY (project_id),
FOREIGN KEY(organisation_id) REFERENCES "Organisations" (organisation_id)
)
/*
2 rows from Projects table:
project_id organisation_id project_details
1 15 porro
2 11 et
*/
CREATE TABLE "Research_Outcomes" (
outcome_code VARCHAR(10),
outcome_description VARCHAR(255) NOT NULL,
PRIMARY KEY (outcome_code)
)
/*
2 rows from Research_Outcomes table:
outcome_code outcome_description
Paper Published Research Paper
Patent Research Patent
*/
CREATE TABLE "Research_Staff" (
staff_id INTEGER,
employer_organisation_id INTEGER NOT NULL,
staff_details VARCHAR(255) NOT NULL,
PRIMARY KEY (staff_id),
FOREIGN KEY(employer_organisation_id) REFERENCES "Organisations" (organisation_id)
)
/*
2 rows from Research_Staff table:
staff_id employer_organisation_id staff_details
1 1 quo
2 4 est
*/
CREATE TABLE "Staff_Roles" (
role_code VARCHAR(10),
role_description VARCHAR(255) NOT NULL,
PRIMARY KEY (role_code)
)
/*
2 rows from Staff_Roles table:
role_code role_description
leader Project Leader
researcher Project Researcher
*/
CREATE TABLE "Tasks" (
task_id INTEGER,
project_id INTEGER NOT NULL,
task_details VARCHAR(255) NOT NULL,
"eg Agree Objectives" VARCHAR(1),
PRIMARY KEY (task_id),
FOREIGN KEY(project_id) REFERENCES "Projects" (project_id)
)
/*
2 rows from Tasks table:
task_id project_id task_details eg Agree Objectives
1 1 a None
2 2 b None
*/ | What are the details for all projects that did not hire any staff in a research role? | SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_Staff WHERE role_code = 'researcher' ) | [{'project_details': 'porro'}, {'project_details': 'sint'}, {'project_details': 'deserunt'}, {'project_details': 'consectetur'}, {'project_details': 'omnis'}, {'project_details': 'non'}, {'project_details': 'beatae'}, {'project_details': 'dolorem'}] | Extra Hard | false | false | false | false | false | false | false | false | false | true | false | false | false | ||||
apartment_rentals |
CREATE TABLE "Apartment_Bookings" (
apt_booking_id INTEGER NOT NULL,
apt_id INTEGER,
guest_id INTEGER NOT NULL,
booking_status_code CHAR(15) NOT NULL,
booking_start_date DATETIME,
booking_end_date DATETIME,
PRIMARY KEY (apt_booking_id),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id),
FOREIGN KEY(guest_id) REFERENCES "Guests" (guest_id),
UNIQUE (apt_booking_id)
)
CREATE TABLE "Apartment_Buildings" (
building_id INTEGER NOT NULL,
building_short_name CHAR(15),
building_full_name VARCHAR(80),
building_description VARCHAR(255),
building_address VARCHAR(255),
building_manager VARCHAR(50),
building_phone VARCHAR(80),
PRIMARY KEY (building_id),
UNIQUE (building_id)
)
CREATE TABLE "Apartment_Facilities" (
apt_id INTEGER NOT NULL,
facility_code CHAR(15) NOT NULL,
PRIMARY KEY (apt_id, facility_code),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id)
)
CREATE TABLE "Apartments" (
apt_id INTEGER NOT NULL,
building_id INTEGER NOT NULL,
apt_type_code CHAR(15),
apt_number CHAR(10),
bathroom_count INTEGER,
bedroom_count INTEGER,
room_count CHAR(5),
PRIMARY KEY (apt_id),
FOREIGN KEY(building_id) REFERENCES "Apartment_Buildings" (building_id),
UNIQUE (apt_id)
)
CREATE TABLE "Guests" (
guest_id INTEGER NOT NULL,
gender_code CHAR(1),
guest_first_name VARCHAR(80),
guest_last_name VARCHAR(80),
date_of_birth DATETIME,
PRIMARY KEY (guest_id),
UNIQUE (guest_id)
)
CREATE TABLE "View_Unit_Status" (
apt_id INTEGER,
apt_booking_id INTEGER,
status_date DATETIME NOT NULL,
available_yn NUMERIC,
PRIMARY KEY (status_date),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id),
FOREIGN KEY(apt_booking_id) REFERENCES "Apartment_Bookings" (apt_booking_id)
) |
CREATE TABLE "Apartment_Bookings" (
apt_booking_id INTEGER NOT NULL,
apt_id INTEGER,
guest_id INTEGER NOT NULL,
booking_status_code CHAR(15) NOT NULL,
booking_start_date DATETIME,
booking_end_date DATETIME,
PRIMARY KEY (apt_booking_id),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id),
FOREIGN KEY(guest_id) REFERENCES "Guests" (guest_id),
UNIQUE (apt_booking_id)
)
/*
2 rows from Apartment_Bookings table:
apt_booking_id apt_id guest_id booking_status_code booking_start_date booking_end_date
258 10 2 Provisional 2016-09-26 17:13:49 2017-10-07 11:38:48
279 15 15 Provisional 2016-04-01 06:28:08 2017-10-25 11:08:42
*/
CREATE TABLE "Apartment_Buildings" (
building_id INTEGER NOT NULL,
building_short_name CHAR(15),
building_full_name VARCHAR(80),
building_description VARCHAR(255),
building_address VARCHAR(255),
building_manager VARCHAR(50),
building_phone VARCHAR(80),
PRIMARY KEY (building_id),
UNIQUE (building_id)
)
/*
2 rows from Apartment_Buildings table:
building_id building_short_name building_full_name building_description building_address building_manager building_phone
133 Normandie Court Normandie Court Studio 7950 Casper Vista Apt. 176
Marquiseberg, CA 70496 Emma (948)040-1064x387
153 Mercedes House Mercedes House Studio 354 Otto Villages
Charliefort, VT 71664 Brenden 915-617-2408x832
*/
CREATE TABLE "Apartment_Facilities" (
apt_id INTEGER NOT NULL,
facility_code CHAR(15) NOT NULL,
PRIMARY KEY (apt_id, facility_code),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id)
)
/*
2 rows from Apartment_Facilities table:
apt_id facility_code
1 Boardband
2 Boardband
*/
CREATE TABLE "Apartments" (
apt_id INTEGER NOT NULL,
building_id INTEGER NOT NULL,
apt_type_code CHAR(15),
apt_number CHAR(10),
bathroom_count INTEGER,
bedroom_count INTEGER,
room_count CHAR(5),
PRIMARY KEY (apt_id),
FOREIGN KEY(building_id) REFERENCES "Apartment_Buildings" (building_id),
UNIQUE (apt_id)
)
/*
2 rows from Apartments table:
apt_id building_id apt_type_code apt_number bathroom_count bedroom_count room_count
1 808 Flat Suite 645 1 3 7
2 624 Flat Apt. 585 2 4 5
*/
CREATE TABLE "Guests" (
guest_id INTEGER NOT NULL,
gender_code CHAR(1),
guest_first_name VARCHAR(80),
guest_last_name VARCHAR(80),
date_of_birth DATETIME,
PRIMARY KEY (guest_id),
UNIQUE (guest_id)
)
/*
2 rows from Guests table:
guest_id gender_code guest_first_name guest_last_name date_of_birth
1 Male Kip DuBuque 1995-11-04 07:09:57
2 Unknown Rebeca Runolfsdottir 1974-05-12 21:53:58
*/
CREATE TABLE "View_Unit_Status" (
apt_id INTEGER,
apt_booking_id INTEGER,
status_date DATETIME NOT NULL,
available_yn NUMERIC,
PRIMARY KEY (status_date),
FOREIGN KEY(apt_id) REFERENCES "Apartments" (apt_id),
FOREIGN KEY(apt_booking_id) REFERENCES "Apartment_Bookings" (apt_booking_id)
)
/*
2 rows from View_Unit_Status table:
apt_id apt_booking_id status_date available_yn
11 920 1970-09-28 10:24:29 1.0000000000
15 575 1972-03-23 22:55:53 1.0000000000
*/ | Find the average number of bedrooms of all the apartments. | SELECT avg(bedroom_count) FROM Apartments | [{'avg(bedroom_count)': 4.466666666666667}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the names of properties that are either houses or apartments with more than 1 room?[/QUESTION]
[SQL]SELECT property_name FROM Properties WHERE property_type_code = "House" UNION SELECT property_name FROM Properties WHERE property_type_code = "Apartment" AND room_count > 1[/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
*/ | For each start station id, what is its name, longitude and average duration of trips started there? | SELECT T1.name , T1.long , avg(T2.duration) FROM station AS T1 JOIN trip AS T2 ON T1.id = T2.start_station_id GROUP BY T2.start_station_id | [{'name': 'San Jose Diridon Caltrain Station', 'long': -121.90178200000001, 'avg(T2.duration)': 544.7611940298508}, {'name': 'San Jose Civic Center', 'long': -121.888979, 'avg(T2.duration)': 885.0}, {'name': 'Santa Clara at Almaden', 'long': -121.894902, 'avg(T2.duration)': 378.28}, {'name': 'Adobe on Almaden', 'long': -121.8932, 'avg(T2.duration)': 980.0714285714286}, {'name': 'San Pedro Square', 'long': -121.894074, 'avg(T2.duration)': 840.225}, {'name': 'Paseo de San Antonio', 'long': -121.88694299999999, 'avg(T2.duration)': 529.0909090909091}, {'name': 'San Salvador at 1st', 'long': -121.88583100000001, 'avg(T2.duration)': 682.3333333333334}, {'name': 'Japantown', 'long': -121.89471499999999, 'avg(T2.duration)': 1230.655172413793}, {'name': 'San Jose City Hall', 'long': -121.886995, 'avg(T2.duration)': 1123.4}, {'name': 'MLK Library', 'long': -121.88566000000002, 'avg(T2.duration)': 810.5416666666666}, {'name': 'SJSU 4th at San Carlos', 'long': -121.88389099999999, 'avg(T2.duration)': 711.7777777777778}, {'name': 'St James Park', 'long': -121.88993700000002, 'avg(T2.duration)': 616.4}, {'name': 'Arena Green / SAP Center', 'long': -121.900084, 'avg(T2.duration)': 608.8333333333334}, {'name': 'SJSU - San Salvador at 9th', 'long': -121.877349, 'avg(T2.duration)': 3597.095238095238}, {'name': 'Franklin at Maple', 'long': -122.226904, 'avg(T2.duration)': 3909.0}, {'name': 'Redwood City Caltrain Station', 'long': -122.23208899999999, 'avg(T2.duration)': 2643.871794871795}, {'name': 'Redwood City Public Library', 'long': -122.227424, 'avg(T2.duration)': 741.0}, {'name': 'Stanford in Redwood City', 'long': -122.20328799999999, 'avg(T2.duration)': 979.0666666666667}, {'name': 'Redwood City Medical Center', 'long': -122.223492, 'avg(T2.duration)': 555.4}, {'name': 'Mountain View City Hall', 'long': -122.081896, 'avg(T2.duration)': 563.0333333333333}, {'name': 'Mountain View Caltrain Station', 'long': -122.07671299999998, 'avg(T2.duration)': 714.8062015503876}, {'name': 'San Antonio Caltrain Station', 'long': -122.10675800000001, 'avg(T2.duration)': 380.40909090909093}, {'name': 'Evelyn Park and Ride', 'long': -122.066553, 'avg(T2.duration)': 918.1315789473684}, {'name': 'San Antonio Shopping Center', 'long': -122.10833799999999, 'avg(T2.duration)': 667.5925925925926}, {'name': 'Castro Street and El Camino Real', 'long': -122.083678, 'avg(T2.duration)': 1082.7142857142858}, {'name': 'Rengstorff Avenue / California Street', 'long': -122.099076, 'avg(T2.duration)': 699.7}, {'name': 'Palo Alto Caltrain Station', 'long': -122.164759, 'avg(T2.duration)': 1653.3255813953488}, {'name': 'University and Emerson', 'long': -122.16309299999999, 'avg(T2.duration)': 2643.6}, {'name': 'California Ave Caltrain Station', 'long': -122.14280500000001, 'avg(T2.duration)': 1423.842105263158}, {'name': 'Cowper at University', 'long': -122.159504, 'avg(T2.duration)': 1164.1153846153845}, {'name': 'Park at Olive', 'long': -122.13777749999998, 'avg(T2.duration)': 872.2222222222222}, {'name': 'Powell Street BART', 'long': -122.408433, 'avg(T2.duration)': 1245.5836909871246}, {'name': 'Clay at Battery', 'long': -122.39997, 'avg(T2.duration)': 906.0827586206897}, {'name': 'Davis at Jackson', 'long': -122.398436, 'avg(T2.duration)': 1067.6629213483145}, {'name': 'Commercial at Montgomery', 'long': -122.402923, 'avg(T2.duration)': 524.774834437086}, {'name': 'Washington at Kearney', 'long': -122.40476699999999, 'avg(T2.duration)': 1497.7671232876712}, {'name': 'Post at Kearney', 'long': -122.403452, 'avg(T2.duration)': 825.1928571428572}, {'name': 'Embarcadero at Vallejo', 'long': -122.398525, 'avg(T2.duration)': 1817.221649484536}, {'name': 'Spear at Folsom', 'long': -122.39063700000001, 'avg(T2.duration)': 655.7166666666667}, {'name': 'Harry Bridges Plaza (Ferry Building)', 'long': -122.394203, 'avg(T2.duration)': 1802.6721991701245}, {'name': 'Embarcadero at Folsom', 'long': -122.391034, 'avg(T2.duration)': 938.7894736842105}, {'name': 'Embarcadero at Bryant', 'long': -122.38801299999999, 'avg(T2.duration)': 766.0746268656717}, {'name': 'Temporary Transbay Terminal (Howard at Beale)', 'long': -122.39464299999999, 'avg(T2.duration)': 535.0488372093023}, {'name': 'Beale at Market', 'long': -122.39708600000002, 'avg(T2.duration)': 752.6637554585153}, {'name': '5th at Howard', 'long': -122.40512700000001, 'avg(T2.duration)': 551.4051282051282}, {'name': 'San Francisco City Hall', 'long': -122.41823500000001, 'avg(T2.duration)': 1774.6315789473683}, {'name': 'Golden Gate at Polk', 'long': -122.418603, 'avg(T2.duration)': 734.3861386138614}, {'name': 'Embarcadero at Sansome', 'long': -122.40323400000001, 'avg(T2.duration)': 1630.0022675736961}, {'name': '2nd at Townsend', 'long': -122.39028799999998, 'avg(T2.duration)': 905.3340611353711}, {'name': '2nd at Folsom', 'long': -122.39623600000002, 'avg(T2.duration)': 399.6787330316742}, {'name': 'Howard at 2nd', 'long': -122.39810800000001, 'avg(T2.duration)': 414.51173708920186}, {'name': '2nd at South Park', 'long': -122.392738, 'avg(T2.duration)': 512.8461538461538}, {'name': 'Townsend at 7th', 'long': -122.402717, 'avg(T2.duration)': 568.9297752808989}, {'name': 'South Van Ness at Market', 'long': -122.418954, 'avg(T2.duration)': 912.8475609756098}, {'name': 'Market at 10th', 'long': -122.41738500000001, 'avg(T2.duration)': 1139.6389891696751}, {'name': 'Yerba Buena Center of the Arts (3rd @ Howard)', 'long': -122.40101399999999, 'avg(T2.duration)': 561.7394957983194}, {'name': 'San Francisco Caltrain 2 (330 Townsend)', 'long': -122.39546999999999, 'avg(T2.duration)': 725.3219284603422}, {'name': 'San Francisco Caltrain (Townsend at 4th)', 'long': -122.39526000000001, 'avg(T2.duration)': 801.9405320813771}, {'name': 'Powell at Post (Union Square)', 'long': -122.408499, 'avg(T2.duration)': 765.4458598726114}, {'name': 'Civic Center BART (7th at Market)', 'long': -122.411748, 'avg(T2.duration)': 1276.7208121827412}, {'name': 'Grant Avenue at Columbus Avenue', 'long': -122.40724499999999, 'avg(T2.duration)': 1423.375}, {'name': 'Steuart at Market', 'long': -122.394434, 'avg(T2.duration)': 890.9441964285714}, {'name': 'Mechanics Plaza (Market at Battery)', 'long': -122.399051, 'avg(T2.duration)': 655.2933333333333}, {'name': 'Market at 4th', 'long': -122.40496599999999, 'avg(T2.duration)': 1664.8505338078292}, {'name': 'Market at Sansome', 'long': -122.400811, 'avg(T2.duration)': 786.4408284023668}, {'name': 'Santa Clara County Civic Center', 'long': -121.90573300000001, 'avg(T2.duration)': 862.4666666666667}, {'name': 'Broadway St at Battery St', 'long': -122.40086200000002, 'avg(T2.duration)': 1044.7237569060774}, {'name': 'Mezes Park', 'long': -122.23623400000001, 'avg(T2.duration)': 253.33333333333334}, {'name': 'Ryland Park', 'long': -121.89561699999999, 'avg(T2.duration)': 556.0}] | Medium | false | false | false | false | false | true | false | true | 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] |
||
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 by artists who are at most 23 years old? | SELECT Issue_Date FROM artist AS T1 JOIN volume AS T2 ON T1.Artist_ID = T2.Artist_ID WHERE T1.age <= 23 | [{'Issue_Date': '6 June'}] | Medium | false | false | false | false | false | false | false | true | 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
*/ | What are the first names of students studying in room 107? | SELECT DISTINCT firstname FROM list WHERE classroom = 107 | [{'FirstName': ' SHERWOOD'}, {'FirstName': ' ROBBY'}, {'FirstName': ' CRYSTA'}, {'FirstName': ' VERTIE'}, {'FirstName': ' CHRISSY'}, {'FirstName': ' JORDON'}] | Easy | true | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the first names of all students in course ACCT-211?[/QUESTION]
[SQL]SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'[/SQL] | [QUESTION]What are the first names of all students in course ACCT-211?[/QUESTION]
[SQL]SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'[/SQL] | [QUESTION]What are the first names of all students in course ACCT-211?[/QUESTION]
[SQL]SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'[/SQL] | [QUESTION]What are the first names of all students in course ACCT-211?[/QUESTION]
[SQL]SELECT T3.stu_fname FROM CLASS AS T1 JOIN enroll AS T2 ON T1.class_code = T2.class_code JOIN student AS T3 ON T2.stu_num = T3.stu_num WHERE T1.crs_code = 'ACCT-211'[/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
*/ | What are the names of teams that do no have match season record? | SELECT Name FROM team WHERE Team_id NOT IN (SELECT Team FROM match_season) | [{'Name': 'Brown Erdman'}, {'Name': 'Los Angeles Galaxy'}, {'Name': 'Berneice Hand'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]How many matches were played in each year?[/QUESTION]
[SQL]SELECT count(*) , YEAR FROM matches GROUP BY YEAR[/SQL] | [QUESTION]How many matches were played in each year?[/QUESTION]
[SQL]SELECT count(*) , YEAR FROM matches GROUP BY YEAR[/SQL] | [QUESTION]How many matches were played in each year?[/QUESTION]
[SQL]SELECT count(*) , YEAR FROM matches GROUP BY YEAR[/SQL] | [QUESTION]How many matches were played in each year?[/QUESTION]
[SQL]SELECT count(*) , YEAR FROM matches GROUP BY YEAR[/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
*/ | How many regions were affected by each storm? | SELECT T1.name , count(*) FROM storm AS T1 JOIN affected_region AS T2 ON T1.storm_id = T2.storm_id GROUP BY T1.storm_id | [{'Name': 'One', 'count(*)': 2}, {'Name': 'Three', 'count(*)': 1}, {'Name': 'Four', 'count(*)': 1}, {'Name': 'Five', 'count(*)': 2}] | Medium | false | false | false | false | false | true | false | true | false | false | false | false | false | ||||
cre_Docs_and_Epenses |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
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 "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
) |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
/*
2 rows from Accounts table:
Account_ID Statement_ID Account_Details
7 57 495.063
61 57 930.14
*/
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
/*
2 rows from Documents table:
Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details
29 CV 30 2004-08-28 06:59:19 Review on UK files None None
42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None
*/
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Documents_with_Expenses table:
Document_ID Budget_Type_Code Document_Details
57 GV government
192 GV government
*/
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
/*
2 rows from Projects table:
Project_ID Project_Details
30 Society Research project
35 Internet of Things project
*/
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
/*
2 rows from Ref_Budget_Codes table:
Budget_Type_Code Budget_Type_Description
GV Government
ORG Organisation
*/
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
BK Book excellent
CV CV excellent
*/
CREATE TABLE "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Statements table:
Statement_ID Statement_Details
57 Open Project
192 Private Project
*/ | List document type codes and the number of documents in each code. | SELECT document_type_code , count(*) FROM Documents GROUP BY document_type_code | [{'Document_Type_Code': 'BK', 'count(*)': 6}, {'Document_Type_Code': 'CV', 'count(*)': 3}, {'Document_Type_Code': 'FM', 'count(*)': 1}, {'Document_Type_Code': 'PP', 'count(*)': 5}] | Easy | false | false | false | false | false | true | false | false | false | false | false | false | false | [QUESTION]Show all template type codes and the number of documents using each type.[/QUESTION]
[SQL]SELECT T1.template_type_code , count(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code[/SQL] | [QUESTION]Show all template type codes and the number of documents using each type.[/QUESTION]
[SQL]SELECT T1.template_type_code , count(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code[/SQL] | [QUESTION]Show all template type codes and the number of documents using each type.[/QUESTION]
[SQL]SELECT T1.template_type_code , count(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code[/SQL] | [QUESTION]Show all template type codes and the number of documents using each type.[/QUESTION]
[SQL]SELECT T1.template_type_code , count(*) FROM Templates AS T1 JOIN Documents AS T2 ON T1.template_id = T2.template_id GROUP BY T1.template_type_code[/SQL] |
icfp_1 |
CREATE TABLE "Authors" (
"authID" INTEGER,
lname TEXT,
fname TEXT,
PRIMARY KEY ("authID")
)
CREATE TABLE "Authorship" (
"authID" INTEGER,
"instID" INTEGER,
"paperID" INTEGER,
"authOrder" INTEGER,
PRIMARY KEY ("authID", "instID", "paperID"),
FOREIGN KEY("authID") REFERENCES "Authors" ("authID"),
FOREIGN KEY("instID") REFERENCES "Inst" ("instID"),
FOREIGN KEY("paperID") REFERENCES "Papers" ("paperID")
)
CREATE TABLE "Inst" (
"instID" INTEGER,
name TEXT,
country TEXT,
PRIMARY KEY ("instID")
)
CREATE TABLE "Papers" (
"paperID" INTEGER,
title TEXT,
PRIMARY KEY ("paperID")
) |
CREATE TABLE "Authors" (
"authID" INTEGER,
lname TEXT,
fname TEXT,
PRIMARY KEY ("authID")
)
/*
2 rows from Authors table:
authID lname fname
50 Gibbons Jeremy
51 Hinze Ralf
*/
CREATE TABLE "Authorship" (
"authID" INTEGER,
"instID" INTEGER,
"paperID" INTEGER,
"authOrder" INTEGER,
PRIMARY KEY ("authID", "instID", "paperID"),
FOREIGN KEY("authID") REFERENCES "Authors" ("authID"),
FOREIGN KEY("instID") REFERENCES "Inst" ("instID"),
FOREIGN KEY("paperID") REFERENCES "Papers" ("paperID")
)
/*
2 rows from Authorship table:
authID instID paperID authOrder
50 1000 200 1
51 1000 200 2
*/
CREATE TABLE "Inst" (
"instID" INTEGER,
name TEXT,
country TEXT,
PRIMARY KEY ("instID")
)
/*
2 rows from Inst table:
instID name country
1000 University of Oxford UK
1010 Northeastern University USA
*/
CREATE TABLE "Papers" (
"paperID" INTEGER,
title TEXT,
PRIMARY KEY ("paperID")
)
/*
2 rows from Papers table:
paperID title
200 Just do it: Simple Monadic Equational Reasoning
201 Proving the Unique Fixed-Point Principle Correct: An Adventure with Category Theory
*/ | Which papers were written by authors from the institution "Google"? | SELECT DISTINCT t1.title FROM papers AS t1 JOIN authorship AS t2 ON t1.paperid = t2.paperid JOIN inst AS t3 ON t2.instid = t3.instid WHERE t3.name = "Google" | [{'title': 'An Equivalence-Preserving CPS Translation via Multi-Language Semantics'}] | Hard | true | false | false | false | false | false | false | false | true | false | false | false | false | ||||
cre_Docs_and_Epenses |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
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 "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
) |
CREATE TABLE "Accounts" (
"Account_ID" INTEGER NOT NULL,
"Statement_ID" INTEGER NOT NULL,
"Account_Details" VARCHAR(255),
PRIMARY KEY ("Account_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Statements" ("Statement_ID")
)
/*
2 rows from Accounts table:
Account_ID Statement_ID Account_Details
7 57 495.063
61 57 930.14
*/
CREATE TABLE "Documents" (
"Document_ID" INTEGER NOT NULL,
"Document_Type_Code" CHAR(15) NOT NULL,
"Project_ID" INTEGER NOT NULL,
"Document_Date" DATETIME,
"Document_Name" VARCHAR(255),
"Document_Description" VARCHAR(255),
"Other_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Document_Type_Code") REFERENCES "Ref_Document_Types" ("Document_Type_Code"),
FOREIGN KEY("Project_ID") REFERENCES "Projects" ("Project_ID")
)
/*
2 rows from Documents table:
Document_ID Document_Type_Code Project_ID Document_Date Document_Name Document_Description Other_Details
29 CV 30 2004-08-28 06:59:19 Review on UK files None None
42 BK 105 2012-12-27 19:09:18 Review on Canadian files None None
*/
CREATE TABLE "Documents_with_Expenses" (
"Document_ID" INTEGER NOT NULL,
"Budget_Type_Code" CHAR(15) NOT NULL,
"Document_Details" VARCHAR(255),
PRIMARY KEY ("Document_ID"),
FOREIGN KEY("Budget_Type_Code") REFERENCES "Ref_Budget_Codes" ("Budget_Type_Code"),
FOREIGN KEY("Document_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Documents_with_Expenses table:
Document_ID Budget_Type_Code Document_Details
57 GV government
192 GV government
*/
CREATE TABLE "Projects" (
"Project_ID" INTEGER NOT NULL,
"Project_Details" VARCHAR(255),
PRIMARY KEY ("Project_ID")
)
/*
2 rows from Projects table:
Project_ID Project_Details
30 Society Research project
35 Internet of Things project
*/
CREATE TABLE "Ref_Budget_Codes" (
"Budget_Type_Code" CHAR(15) NOT NULL,
"Budget_Type_Description" VARCHAR(255) NOT NULL,
PRIMARY KEY ("Budget_Type_Code")
)
/*
2 rows from Ref_Budget_Codes table:
Budget_Type_Code Budget_Type_Description
GV Government
ORG Organisation
*/
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
BK Book excellent
CV CV excellent
*/
CREATE TABLE "Statements" (
"Statement_ID" INTEGER NOT NULL,
"Statement_Details" VARCHAR(255),
PRIMARY KEY ("Statement_ID"),
FOREIGN KEY("Statement_ID") REFERENCES "Documents" ("Document_ID")
)
/*
2 rows from Statements table:
Statement_ID Statement_Details
57 Open Project
192 Private Project
*/ | What are the ids and details of all statements? | SELECT STATEMENT_ID , statement_details FROM Statements | [{'Statement_ID': 57, 'Statement_Details': 'Open Project'}, {'Statement_ID': 192, 'Statement_Details': 'Private Project'}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the ids, names, and descriptions for all documents?[/QUESTION]
[SQL]SELECT document_id , document_name , document_description FROM Documents[/SQL] | [QUESTION]What are the ids, names, and descriptions for all documents?[/QUESTION]
[SQL]SELECT document_id , document_name , document_description FROM Documents[/SQL] | [QUESTION]What are the ids, names, and descriptions for all documents?[/QUESTION]
[SQL]SELECT document_id , document_name , document_description FROM Documents[/SQL] | [QUESTION]What are the ids, names, and descriptions for all documents?[/QUESTION]
[SQL]SELECT document_id , document_name , document_description FROM Documents[/SQL] |
car_1 |
CREATE TABLE car_makers (
"Id" INTEGER,
"Maker" TEXT,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY("Country") REFERENCES countries ("CountryId")
)
CREATE TABLE car_names (
"MakeId" INTEGER,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY("Model") REFERENCES model_list ("Model")
)
CREATE TABLE cars_data (
"Id" INTEGER,
"MPG" TEXT,
"Cylinders" INTEGER,
"Edispl" REAL,
"Horsepower" TEXT,
"Weight" INTEGER,
"Accelerate" REAL,
"Year" INTEGER,
PRIMARY KEY ("Id"),
FOREIGN KEY("Id") REFERENCES car_names ("MakeId")
)
CREATE TABLE continents (
"ContId" INTEGER,
"Continent" TEXT,
PRIMARY KEY ("ContId")
)
CREATE TABLE countries (
"CountryId" INTEGER,
"CountryName" TEXT,
"Continent" INTEGER,
PRIMARY KEY ("CountryId"),
FOREIGN KEY("Continent") REFERENCES continents ("ContId")
)
CREATE TABLE model_list (
"ModelId" INTEGER,
"Maker" INTEGER,
"Model" TEXT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY("Maker") REFERENCES car_makers ("Id"),
UNIQUE ("Model")
) |
CREATE TABLE car_makers (
"Id" INTEGER,
"Maker" TEXT,
"FullName" TEXT,
"Country" TEXT,
PRIMARY KEY ("Id"),
FOREIGN KEY("Country") REFERENCES countries ("CountryId")
)
/*
2 rows from car_makers table:
Id Maker FullName Country
1 amc American Motor Company 1
2 volkswagen Volkswagen 2
*/
CREATE TABLE car_names (
"MakeId" INTEGER,
"Model" TEXT,
"Make" TEXT,
PRIMARY KEY ("MakeId"),
FOREIGN KEY("Model") REFERENCES model_list ("Model")
)
/*
2 rows from car_names table:
MakeId Model Make
1 chevrolet chevrolet chevelle malibu
2 buick buick skylark 320
*/
CREATE TABLE cars_data (
"Id" INTEGER,
"MPG" TEXT,
"Cylinders" INTEGER,
"Edispl" REAL,
"Horsepower" TEXT,
"Weight" INTEGER,
"Accelerate" REAL,
"Year" INTEGER,
PRIMARY KEY ("Id"),
FOREIGN KEY("Id") REFERENCES car_names ("MakeId")
)
/*
2 rows from cars_data table:
Id MPG Cylinders Edispl Horsepower Weight Accelerate Year
1 18 8 307.0 130 3504 12.0 1970
2 15 8 350.0 165 3693 11.5 1970
*/
CREATE TABLE continents (
"ContId" INTEGER,
"Continent" TEXT,
PRIMARY KEY ("ContId")
)
/*
2 rows from continents table:
ContId Continent
1 america
2 europe
*/
CREATE TABLE countries (
"CountryId" INTEGER,
"CountryName" TEXT,
"Continent" INTEGER,
PRIMARY KEY ("CountryId"),
FOREIGN KEY("Continent") REFERENCES continents ("ContId")
)
/*
2 rows from countries table:
CountryId CountryName Continent
1 usa 1
2 germany 2
*/
CREATE TABLE model_list (
"ModelId" INTEGER,
"Maker" INTEGER,
"Model" TEXT,
PRIMARY KEY ("ModelId"),
FOREIGN KEY("Maker") REFERENCES car_makers ("Id"),
UNIQUE ("Model")
)
/*
2 rows from model_list table:
ModelId Maker Model
1 1 amc
2 2 audi
*/ | What is the average weight and year for each year? | SELECT avg(Weight) , YEAR FROM CARS_DATA GROUP BY YEAR; | [{'avg(Weight)': 3441.3142857142857, 'Year': 1970}, {'avg(Weight)': 2960.344827586207, 'Year': 1971}, {'avg(Weight)': 3237.714285714286, 'Year': 1972}, {'avg(Weight)': 3419.025, 'Year': 1973}, {'avg(Weight)': 2877.925925925926, 'Year': 1974}, {'avg(Weight)': 3176.8, 'Year': 1975}, {'avg(Weight)': 3078.735294117647, 'Year': 1976}, {'avg(Weight)': 2997.3571428571427, 'Year': 1977}, {'avg(Weight)': 2861.8055555555557, 'Year': 1978}, {'avg(Weight)': 3055.344827586207, 'Year': 1979}, {'avg(Weight)': 2436.655172413793, 'Year': 1980}, {'avg(Weight)': 2532.1666666666665, 'Year': 1981}, {'avg(Weight)': 2453.548387096774, 'Year': 1982}] | Easy | false | false | false | false | false | true | false | false | 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
*/ | number of papers written by Christopher D. Manning | SELECT DISTINCT COUNT ( DISTINCT t2.paperid ) FROM writes AS t2 JOIN author AS t1 ON t2.authorid = t1.authorid WHERE t1.authorname = "Christopher D. Manning"; | [{'COUNT ( DISTINCT t2.paperid )': 0}] | Medium | true | false | false | false | false | false | false | true | false | false | false | false | false | ||||
company_employee |
CREATE TABLE company (
"Company_ID" REAL,
"Name" TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_in_Billion" REAL,
"Profits_in_Billion" REAL,
"Assets_in_Billion" REAL,
"Market_Value_in_Billion" REAL,
PRIMARY KEY ("Company_ID")
)
CREATE TABLE employment (
"Company_ID" INTEGER,
"People_ID" INTEGER,
"Year_working" INTEGER,
PRIMARY KEY ("Company_ID", "People_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID"),
FOREIGN KEY("Company_ID") REFERENCES company ("Company_ID")
)
CREATE TABLE people (
"People_ID" INTEGER,
"Age" INTEGER,
"Name" TEXT,
"Nationality" TEXT,
"Graduation_College" TEXT,
PRIMARY KEY ("People_ID")
) |
CREATE TABLE company (
"Company_ID" REAL,
"Name" TEXT,
"Headquarters" TEXT,
"Industry" TEXT,
"Sales_in_Billion" REAL,
"Profits_in_Billion" REAL,
"Assets_in_Billion" REAL,
"Market_Value_in_Billion" REAL,
PRIMARY KEY ("Company_ID")
)
/*
2 rows from company table:
Company_ID Name Headquarters Industry Sales_in_Billion Profits_in_Billion Assets_in_Billion Market_Value_in_Billion
1.0 ExxonMobil USA Oil and gas 433.5 41.1 331.1 407.4
2.0 JPMorgan Chase USA Banking 110.8 19.0 2265.8 170.1
*/
CREATE TABLE employment (
"Company_ID" INTEGER,
"People_ID" INTEGER,
"Year_working" INTEGER,
PRIMARY KEY ("Company_ID", "People_ID"),
FOREIGN KEY("People_ID") REFERENCES people ("People_ID"),
FOREIGN KEY("Company_ID") REFERENCES company ("Company_ID")
)
/*
2 rows from employment table:
Company_ID People_ID Year_working
11 3 2
13 2 3
*/
CREATE TABLE people (
"People_ID" INTEGER,
"Age" INTEGER,
"Name" TEXT,
"Nationality" TEXT,
"Graduation_College" TEXT,
PRIMARY KEY ("People_ID")
)
/*
2 rows from people table:
People_ID Age Name Nationality Graduation_College
1 27 Reggie Lewis United States Northeastern
2 25 Brad Lohaus United States Iowa
*/ | What is the maximum and minimum market value of companies? | SELECT max(Market_Value_in_Billion) , min(Market_Value_in_Billion) FROM company | [{'max(Market_Value_in_Billion)': 407.4, 'min(Market_Value_in_Billion)': 79.5}] | Easy | false | false | false | false | false | false | false | false | false | false | false | false | false | [QUESTION]What are the minimum and maximum number of products across all the shops?[/QUESTION]
[SQL]SELECT min(Number_products) , max(Number_products) FROM shop[/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 name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order). | SELECT name , price FROM products WHERE price >= 180 ORDER BY price DESC , name ASC | [{'Name': 'Printer', 'Price': 270}, {'Name': 'Hard drive', 'Price': 240}, {'Name': 'Monitor', 'Price': 240}, {'Name': 'DVD burner', 'Price': 180}, {'Name': 'DVD drive', 'Price': 180}] | Easy | false | false | false | true | false | false | false | false | false | false | false | false | false | [QUESTION]Return the name, location and district of all shops in descending order of number of products.[/QUESTION]
[SQL]SELECT name , LOCATION , district FROM shop ORDER BY number_products DESC[/SQL] | [QUESTION]Return the name, location and district of all shops in descending order of number of products.[/QUESTION]
[SQL]SELECT name , LOCATION , district FROM shop ORDER BY number_products DESC[/SQL] | [QUESTION]Return the name, location and district of all shops in descending order of number of products.[/QUESTION]
[SQL]SELECT name , LOCATION , district FROM shop ORDER BY number_products DESC[/SQL] |