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 [email protected] 3
2 Leonie Köhler None Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 +49 0711 2842222 None [email protected] 5
*/
CREATE TABLE employees (
id INTEGER,
last_name VARCHAR(20) NOT NULL,
first_name VARCHAR(20) NOT NULL,
title VARCHAR(30),
reports_to INTEGER,
birth_date TIMESTAMP,
hire_date TIMESTAMP,
address VARCHAR(70),
city VARCHAR(40),
state VARCHAR(40),
country VARCHAR(40),
postal_code VARCHAR(10),
phone VARCHAR(24),
fax VARCHAR(24),
email VARCHAR(60),
PRIMARY KEY (id),
FOREIGN KEY(reports_to) REFERENCES employees (id)
)
/*
2 rows from employees table:
id last_name first_name title reports_to birth_date hire_date address city state country postal_code phone fax email
1 Adams Andrew General Manager None 1962-02-18 00:00:00 2002-08-14 00:00:00 11120 Jasper Ave NW Edmonton AB Canada T5K 2N1 +1 (780) 428-9482 +1 (780) 428-3457 [email protected]
2 Edwards Nancy Sales Manager 1 1958-12-08 00:00:00 2002-05-01 00:00:00 825 8 Ave SW Calgary AB Canada T2P 2T3 +1 (403) 262-3443 +1 (403) 262-3322 [email protected]
*/
CREATE TABLE genres (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from genres table:
id name
1 Rock
2 Jazz
*/
CREATE TABLE invoice_lines (
id INTEGER,
invoice_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
unit_price NUMERIC(10, 2) NOT NULL,
quantity INTEGER NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(invoice_id) REFERENCES invoices (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from invoice_lines table:
id invoice_id track_id unit_price quantity
1 1 2 0.99 1
2 1 4 0.99 1
*/
CREATE TABLE invoices (
id INTEGER,
customer_id INTEGER NOT NULL,
invoice_date TIMESTAMP NOT NULL,
billing_address VARCHAR(70),
billing_city VARCHAR(40),
billing_state VARCHAR(40),
billing_country VARCHAR(40),
billing_postal_code VARCHAR(10),
total NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(customer_id) REFERENCES customers (id)
)
/*
2 rows from invoices table:
id customer_id invoice_date billing_address billing_city billing_state billing_country billing_postal_code total
1 2 2007-01-01 00:00:00 Theodor-Heuss-Straße 34 Stuttgart None Germany 70174 1.98
2 4 2007-01-02 00:00:00 Ullevålsveien 14 Oslo None Norway 0171 3.96
*/
CREATE TABLE media_types (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from media_types table:
id name
1 MPEG audio file
2 Protected AAC audio file
*/
CREATE TABLE playlist_tracks (
playlist_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
CONSTRAINT "PK_PlaylistTrack" PRIMARY KEY (playlist_id, track_id),
FOREIGN KEY(playlist_id) REFERENCES playlists (id),
FOREIGN KEY(track_id) REFERENCES tracks (id)
)
/*
2 rows from playlist_tracks table:
playlist_id track_id
1 3402
1 3389
*/
CREATE TABLE playlists (
id INTEGER,
name VARCHAR(120),
PRIMARY KEY (id)
)
/*
2 rows from playlists table:
id name
1 Music
2 Movies
*/
CREATE TABLE tracks (
id INTEGER,
name VARCHAR(200) NOT NULL,
album_id INTEGER,
media_type_id INTEGER NOT NULL,
genre_id INTEGER,
composer VARCHAR(220),
milliseconds INTEGER NOT NULL,
bytes INTEGER,
unit_price NUMERIC(10, 2) NOT NULL,
PRIMARY KEY (id),
FOREIGN KEY(album_id) REFERENCES albums (id),
FOREIGN KEY(genre_id) REFERENCES genres (id),
FOREIGN KEY(media_type_id) REFERENCES media_types (id)
)
/*
2 rows from tracks table:
id name album_id media_type_id genre_id composer milliseconds bytes unit_price
1 For Those About To Rock (We Salute You) 1 1 1 Angus Young, Malcolm Young, Brian Johnson 343719 11170334 0.99
2 Balls to the Wall 2 2 1 None 342562 5510424 0.99
*/ | 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 [email protected] 618 Webster Stream Apt. 161 None b4459ad261
2 Direct Debit Gage (402)890-2603x6005 [email protected] 0260 Walker Trace None 7905d7f1b1
*/
CREATE TABLE "Mailshot_Campaigns" (
mailshot_id INTEGER,
product_category VARCHAR(15),
mailshot_name VARCHAR(80),
mailshot_start_date DATETIME,
mailshot_end_date DATETIME,
PRIMARY KEY (mailshot_id)
)
/*
2 rows from Mailshot_Campaigns table:
mailshot_id product_category mailshot_name mailshot_start_date mailshot_end_date
1 food US 2018-02-15 09:52:17 2018-03-08 14:40:20
2 clothes US 2017-09-14 12:05:30 2018-03-15 01:06:16
*/
CREATE TABLE "Mailshot_Customers" (
mailshot_id INTEGER NOT NULL,
customer_id INTEGER NOT NULL,
outcome_code VARCHAR(15) NOT NULL,
mailshot_customer_date DATETIME,
FOREIGN KEY(mailshot_id) REFERENCES "Mailshot_Campaigns" (mailshot_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id)
)
/*
2 rows from Mailshot_Customers table:
mailshot_id customer_id outcome_code mailshot_customer_date
4 3 Order 2018-03-15 15:43:14
10 1 No Response 2018-03-04 13:06:55
*/
CREATE TABLE "Order_Items" (
item_id INTEGER NOT NULL,
order_item_status_code VARCHAR(15) NOT NULL,
order_id INTEGER NOT NULL,
product_id INTEGER NOT NULL,
item_status_code VARCHAR(15),
item_delivered_datetime DATETIME,
item_order_quantity VARCHAR(80),
FOREIGN KEY(order_id) REFERENCES "Customer_Orders" (order_id),
FOREIGN KEY(product_id) REFERENCES "Products" (product_id)
)
/*
2 rows from Order_Items table:
item_id order_item_status_code order_id product_id item_status_code item_delivered_datetime item_order_quantity
1 Delivered 10 13 good 2018-02-25 18:22:10 6
2 Paid 6 7 good 2018-02-27 18:04:55 7
*/
CREATE TABLE "Premises" (
premise_id INTEGER,
premises_type VARCHAR(15) NOT NULL,
premise_details VARCHAR(255),
PRIMARY KEY (premise_id)
)
/*
2 rows from Premises table:
premise_id premises_type premise_details
1 Warehouse 036 Lueilwitz Harbor
2 Warehouse 676 Kelly Spur
*/
CREATE TABLE "Products" (
product_id INTEGER,
product_category VARCHAR(15) NOT NULL,
product_name VARCHAR(80),
PRIMARY KEY (product_id)
)
/*
2 rows from Products table:
product_id product_category product_name
1 Food Coffee Bean
2 Electronics Keyboard
*/ | 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 [email protected] 2017-12-05 15:20:04 2018-03-03 03:33:05 None
2 9 Louvenia Fatima Hansen 1-247-673-8446 [email protected] 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 [email protected] None
2 7 Sid Tremayne Brakus 1 202.626.1698x9242 [email protected] 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 [email protected] 07278206718 861-638-9797
2 10 Bad Customer 2015-11-16 22:52:14 1995-07-17 12:13:16 Genevieve Terry 7256.0 [email protected] +14(5)2351480248 578-518-4785x612
*/
CREATE TABLE "Lessons" (
lesson_id INTEGER,
customer_id INTEGER NOT NULL,
lesson_status_code VARCHAR(15) NOT NULL,
staff_id INTEGER,
vehicle_id INTEGER NOT NULL,
lesson_date DATETIME,
lesson_time VARCHAR(10),
price DOUBLE,
PRIMARY KEY (lesson_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(vehicle_id) REFERENCES "Vehicles" (vehicle_id)
)
/*
2 rows from Lessons table:
lesson_id customer_id lesson_status_code staff_id vehicle_id lesson_date lesson_time price
1 6 Cancelled 8 3 2018-02-28 10:55:36 5 199.0
2 8 Cancelled 14 3 2018-03-07 16:12:36 6 167.0
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_address_id INTEGER NOT NULL,
nickname VARCHAR(80),
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
date_of_birth DATETIME,
date_joined_staff DATETIME,
date_left_staff DATETIME,
PRIMARY KEY (staff_id),
FOREIGN KEY(staff_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Staff table:
staff_id staff_address_id nickname first_name middle_name last_name date_of_birth date_joined_staff date_left_staff
1 14 thompson.constantin Janessa Amara Sawayn 2010-12-08 16:55:14 2017-04-27 03:21:26 2018-03-23 22:53:12
2 3 santos45 Camylle Icie Weissnat 2015-08-01 13:22:43 2016-06-06 08:54:28 2018-03-10 15:25:00
*/
CREATE TABLE "Vehicles" (
vehicle_id INTEGER,
vehicle_details VARCHAR(255),
PRIMARY KEY (vehicle_id)
)
/*
2 rows from Vehicles table:
vehicle_id vehicle_details
1 Van
2 Truck
*/ | 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 [email protected] 07278206718 861-638-9797
2 10 Bad Customer 2015-11-16 22:52:14 1995-07-17 12:13:16 Genevieve Terry 7256.0 [email protected] +14(5)2351480248 578-518-4785x612
*/
CREATE TABLE "Lessons" (
lesson_id INTEGER,
customer_id INTEGER NOT NULL,
lesson_status_code VARCHAR(15) NOT NULL,
staff_id INTEGER,
vehicle_id INTEGER NOT NULL,
lesson_date DATETIME,
lesson_time VARCHAR(10),
price DOUBLE,
PRIMARY KEY (lesson_id),
FOREIGN KEY(customer_id) REFERENCES "Customers" (customer_id),
FOREIGN KEY(staff_id) REFERENCES "Staff" (staff_id),
FOREIGN KEY(vehicle_id) REFERENCES "Vehicles" (vehicle_id)
)
/*
2 rows from Lessons table:
lesson_id customer_id lesson_status_code staff_id vehicle_id lesson_date lesson_time price
1 6 Cancelled 8 3 2018-02-28 10:55:36 5 199.0
2 8 Cancelled 14 3 2018-03-07 16:12:36 6 167.0
*/
CREATE TABLE "Staff" (
staff_id INTEGER,
staff_address_id INTEGER NOT NULL,
nickname VARCHAR(80),
first_name VARCHAR(80),
middle_name VARCHAR(80),
last_name VARCHAR(80),
date_of_birth DATETIME,
date_joined_staff DATETIME,
date_left_staff DATETIME,
PRIMARY KEY (staff_id),
FOREIGN KEY(staff_address_id) REFERENCES "Addresses" (address_id)
)
/*
2 rows from Staff table:
staff_id staff_address_id nickname first_name middle_name last_name date_of_birth date_joined_staff date_left_staff
1 14 thompson.constantin Janessa Amara Sawayn 2010-12-08 16:55:14 2017-04-27 03:21:26 2018-03-23 22:53:12
2 3 santos45 Camylle Icie Weissnat 2015-08-01 13:22:43 2016-06-06 08:54:28 2018-03-10 15:25:00
*/
CREATE TABLE "Vehicles" (
vehicle_id INTEGER,
vehicle_details VARCHAR(255),
PRIMARY KEY (vehicle_id)
)
/*
2 rows from Vehicles table:
vehicle_id vehicle_details
1 Van
2 Truck
*/ | What 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': '[email protected]'}, {'phone_number': '374-483-2758x85087', 'email_address': '[email protected]'}, {'phone_number': '218.550.1362', 'email_address': '[email protected]'}, {'phone_number': '1-618-535-9750', 'email_address': '[email protected]'}, {'phone_number': '1-673-962-8158x7646', 'email_address': '[email protected]'}, {'phone_number': '(662)490-3108', 'email_address': '[email protected]'}, {'phone_number': '206-054-0689x05861', 'email_address': '[email protected]'}, {'phone_number': '753.921.0871', 'email_address': '[email protected]'}, {'phone_number': '(297)122-0086', 'email_address': '[email protected]'}, {'phone_number': '417.136.2900x672', 'email_address': '[email protected]'}, {'phone_number': '192-395-2411', 'email_address': '[email protected]'}, {'phone_number': '1-875-045-0806', 'email_address': '[email protected]'}, {'phone_number': '(729)396-4354x3576', 'email_address': '[email protected]'}] | 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 |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
Use the Edit dataset card button to edit it.
- Downloads last month
- 40