db_id stringclasses 146
values | question stringlengths 3 224 | sql stringlengths 18 577 | database_schema stringclasses 146
values |
|---|---|---|---|
cre_Doc_Control_Systems | What document type codes do we have? | SELECT document_type_code FROM Ref_Document_Types; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the description of document type 'Paper'? | SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What are the shipping agent names? | SELECT shipping_agent_name FROM Ref_Shipping_Agents; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the shipping agent code of shipping agent UPS? | SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What are all role codes? | SELECT role_code FROM ROLES; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the description of role code ED? | SELECT role_description FROM ROLES WHERE role_code = "ED"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | How many employees do we have? | SELECT count(*) FROM Employees; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the role of the employee named Koby? | SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List all document ids and receipt dates of documents. | SELECT document_id , receipt_date FROM Documents; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | How many employees does each role have? List role description, id and number of employees. | SELECT T1.role_description , T2.role_code , count(*) FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code GROUP BY T2.role_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)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List roles that have more than one employee. List the role description and number of employees. | SELECT Roles.role_description , count(Employees.employee_id) FROM ROLES JOIN Employees ON Employees.role_code = Roles.role_code GROUP BY Employees.role_code HAVING count(Employees.employee_id) > 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the document status description of the document with id 1? | SELECT Ref_Document_Status.document_status_description FROM Ref_Document_Status JOIN Documents ON Documents.document_status_code = Ref_Document_Status.document_status_code WHERE Documents.document_id = 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | How many documents have the status code done? | SELECT count(*) FROM Documents WHERE document_status_code = "done"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List the document type code for the document with the id 2. | SELECT document_type_code FROM Documents WHERE document_id = 2; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List the document ids for any documents with the status code done and the type code paper. | SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the name of the shipping agent of the document with id 2? | SELECT Ref_Shipping_Agents.shipping_agent_name FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Documents.document_id = 2; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | How many documents were shipped by USPS? | SELECT count(*) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | Which shipping agent shipped the most documents? List the shipping agent name and the number of documents. | SELECT Ref_Shipping_Agents.shipping_agent_name , count(Documents.document_id) FROM Ref_Shipping_Agents JOIN Documents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code GROUP BY Ref_Shipping_Agents.shipping_agent_code ORDER BY count(Documents.document_id) DESC LIMIT 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the receipt date of the document with id 3? | SELECT receipt_date FROM Documents WHERE document_id = 3; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What address was the document with id 4 mailed to? | SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is the mail date of the document with id 7? | SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS. | SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" EXCEPT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS. | SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper" INTERSECT SELECT document_id FROM Documents JOIN Ref_Shipping_Agents ON Documents.shipping_agent_code = Ref_Shipping_Agents.shipping_agent_code WHERE Ref_Shipping_Agents.shipping_agent_name = "USPS"; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | What is draft detail of the document with id 7? | SELECT draft_details FROM Document_Drafts WHERE document_id = 7; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | How many draft copies does the document with id 2 have? | SELECT count(*) FROM Draft_Copies WHERE document_id = 2; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | Which document has the most draft copies? List its document id and number of draft copies. | SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | Which documents have more than 1 draft copies? List document id and number of draft copies. | SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List all employees in the circulation history of the document with id 1. List the employee's name. | SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | List the employees who have not showed up in any circulation history of documents. List the employee's name. | SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies. | SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
cre_Doc_Control_Systems | For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees. | SELECT document_id , count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id; | CREATE TABLE Ref_Document_Types (
document_type_code CHAR(15) NOT NULL,
document_type_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_type_code)
)
3 rows from Ref_Document_Types table:
document_type_code document_type_description
CD b
Paper u
Hard Drive f
CREATE TABLE Roles (
role_code CHAR(15) NOT NULL,
role_description VARCHAR(255),
PRIMARY KEY (role_code)
)
3 rows from Roles table:
role_code role_description
ED Editor
PT Photo
MG Manager
CREATE TABLE Addresses (
address_id INTEGER NOT NULL,
address_details VARCHAR(255),
PRIMARY KEY (address_id)
)
3 rows from Addresses table:
address_id address_details
0 IT
1 MX
2 DE
CREATE TABLE Ref_Document_Status (
document_status_code CHAR(15) NOT NULL,
document_status_description VARCHAR(255) NOT NULL,
PRIMARY KEY (document_status_code)
)
3 rows from Ref_Document_Status table:
document_status_code document_status_description
working currently working on
done mailed
overdue mailed late
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)
)
3 rows from Ref_Shipping_Agents table:
shipping_agent_code shipping_agent_name shipping_agent_description
UP UPS g
US USPS q
AL Airline w
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)
)
3 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
3 done Paper UP 2014-12-25 17:22:44 93 h
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)
)
3 rows from Employees table:
employee_id role_code employee_name other_details
1 ED Koby h
2 ED Kenyon f
3 PR Haley b
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)
)
3 rows from Document_Drafts table:
document_id draft_number draft_details
1 0 e
1 2 k
2 1 v
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)
)
3 rows from Draft_Copies table:
document_id draft_number copy_number
2 8 5
4 9 6
23 9 15
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)
)
3 rows from Circulation_History table:
document_id draft_number copy_number employee_id
20 17 15 8
1 2 5 1
2 1 4 2
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)
)
3 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
4 9 1973-02-21 10:17:01
|
company_1 | List all department names ordered by their starting date. | SELECT dname FROM department ORDER BY mgr_start_date | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | find all dependent names who have a spouse relation with some employee. | SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse' | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | how many female dependents are there? | SELECT count(*) FROM dependent WHERE sex = 'F' | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | Find the names of departments that are located in Houston. | SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston' | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | Return the first names and last names of employees who earn more than 30000 in salary. | SELECT fname , lname FROM employee WHERE salary > 30000 | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | Find the number of employees of each gender whose salary is lower than 50000. | SELECT count(*) , sex FROM employee WHERE salary < 50000 GROUP BY sex | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
company_1 | list the first and last names, and the addresses of all employees in the ascending order of their birth date. | SELECT fname , lname , address FROM employee ORDER BY Bdate | CREATE TABLE works_on(
Essn INTEGER,
Pno INTEGER,
Hours REAL,
PRIMARY KEY(Essn, Pno))
3 rows from works_on table:
Essn Pno Hours
123456789 1 32.5
123456789 2 7.5
666884444 3 40.0
CREATE TABLE employee(
Fname TEXT,
Minit TEXT,
Lname TEXT,
Ssn INTEGER PRIMARY KEY,
Bdate TEXT,
Address TEXT,
Sex TEXT,
Salary INTEGER,
Super_ssn INTEGER,
Dno INTEGER)
3 rows from employee table:
Fname Minit Lname Ssn Bdate Address Sex Salary Super_ssn Dno
Jonh B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5
Franklin T Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5
Joyce A English 453453453 1972-07-31 5631 Rice, Houston, TX F 25000 333445555 5
CREATE TABLE department(
Dname TEXT,
Dnumber INTEGER PRIMARY KEY,
Mgr_ssn INTEGER,
Mgr_start_date TEXT)
3 rows from department table:
Dname Dnumber Mgr_ssn Mgr_start_date
Headquarters 1 888665555 1981-06-19
Administration 4 987654321 1995-01-01
Research 5 333445555 1988-05-22
CREATE TABLE project(
Pname Text,
Pnumber INTEGER PRIMARY KEY,
Plocation TEXT,
Dnum INTEGER)
3 rows from project table:
Pname Pnumber Plocation Dnum
ProductX 1 Bellaire 5
ProductY 2 Sugarland 5
ProductZ 3 Houston 5
CREATE TABLE dependent(
Essn INTEGER,
Dependent_name TEXT,
Sex TEXT,
Bdate TEXT,
Relationship TEXT,
PRIMARY KEY(Essn, Dependent_name))
3 rows from dependent table:
Essn Dependent_name Sex Bdate Relationship
333445555 Alice F 1986-04-05 Daughter
333445555 Theodore M 1983-10-25 Son
333445555 Joy F 1958-05-03 Spouse
CREATE TABLE dept_locations(
Dnumber INTEGER,
Dlocation TEXT,
PRIMARY KEY(Dnumber, Dlocation))
3 rows from dept_locations table:
Dnumber Dlocation
1 Houston
4 Stafford
5 Bellaire
|
local_govt_in_alabama | what are the event details of the services that have the type code 'Marriage'? | SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID = T2.Service_ID WHERE T2.Service_Type_Code = 'Marriage' | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | What are the ids and details of events that have more than one participants? | SELECT T1.event_id , T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID = T2.Event_ID GROUP BY T1.Event_ID HAVING count(*) > 1 | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | How many events have each participants attended? List the participant id, type and the number. | SELECT T1.Participant_ID , T1.Participant_Type_Code , count(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID GROUP BY T1.Participant_ID | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | What are all the the participant ids, type code and details? | SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | How many participants belong to the type 'Organizer'? | SELECT count(*) FROM participants WHERE participant_type_code = 'Organizer' | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | List the type of the services in alphabetical order. | SELECT service_type_code FROM services ORDER BY service_type_code | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | List the service id and details for the events. | SELECT service_id , event_details FROM EVENTS | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | How many events had participants whose details had the substring 'Dr.' | SELECT count(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%' | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | What is the most common participant type? | SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | Which service id and type has the least number of participants? | SELECT T3.service_id , T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID = T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID = T3.Event_ID JOIN services AS T4 ON T3.service_id = T4.service_id GROUP BY T3.service_id ORDER BY count(*) ASC LIMIT 1 | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | What is the id of the event with the most participants? | SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1 | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | Which events id does not have any participant with detail 'Kenyatta Kuhn'? | SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID = T2.Participant_ID WHERE Participant_Details = 'Kenyatta Kuhn' | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | Which services type had both successful and failure event details? | SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id = T2.service_id WHERE T2.event_details = 'Fail' | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | How many events did not have any participants? | SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events) | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
local_govt_in_alabama | What are all the distinct participant ids who attended any events? | SELECT count(DISTINCT participant_id) FROM participants_in_Events | CREATE TABLE Services (
Service_ID INTEGER NOT NULL,
Service_Type_Code CHAR(15) NOT NULL,
PRIMARY KEY (Service_ID)
)
3 rows from Services table:
Service_ID Service_Type_Code
2 Marriage
5 Death Proof
6 Birth Proof
CREATE TABLE Participants (
Participant_ID INTEGER NOT NULL,
Participant_Type_Code CHAR(15) NOT NULL,
Participant_Details VARCHAR(255),
PRIMARY KEY (Participant_ID)
)
3 rows from Participants table:
Participant_ID Participant_Type_Code Participant_Details
9 Organizer Karlee Batz
26 Organizer Vilma Schinner
28 Organizer Lupe Deckow
CREATE TABLE Events (
Event_ID INTEGER NOT NULL,
Service_ID INTEGER NOT NULL,
Event_Details VARCHAR(255),
PRIMARY KEY (Event_ID),
FOREIGN KEY (Service_ID) REFERENCES Services (Service_ID)
)
3 rows from Events table:
Event_ID Service_ID Event_Details
3 5 Success
8 8 Success
13 8 Fail
CREATE TABLE Participants_in_Events (
Event_ID INTEGER NOT NULL,
Participant_ID INTEGER NOT NULL,
PRIMARY KEY (Event_ID, Participant_ID),
FOREIGN KEY (Participant_ID) REFERENCES Participants (Participant_ID),
FOREIGN KEY (Event_ID) REFERENCES Events (Event_ID)
)
3 rows from Participants_in_Events table:
Event_ID Participant_ID
3 26
3 66
8 86
|
formula_1 | What is the name of the race held most recently? | SELECT name FROM races ORDER BY date DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the name of the race that occurred most recently? | SELECT name FROM races ORDER BY date DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the name and date of the most recent race? | SELECT name , date FROM races ORDER BY date DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the name and date of the race that occurred most recently? | SELECT name , date FROM races ORDER BY date DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the names of all races held in 2017. | SELECT name FROM races WHERE YEAR = 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the names of all the races that occurred in the year 2017? | SELECT name FROM races WHERE YEAR = 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the distinct names of all races held between 2014 and 2017? | SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the unique names of all race held between 2014 and 2017? | SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds? | SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the forenames and surnames of all unique drivers who had a lap time of less than 93000 milliseconds? | SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds? | SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds? | SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the forename and surname of the driver who has the smallest laptime? | SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the forename and surname of the driver with the shortest laptime? | SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id and family name of the driver who has the longest laptime? | SELECT T1.driverid , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id and last name of the driver with the longest laptime? | SELECT T1.driverid , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds DESC LIMIT 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice? | SELECT T1.driverid , T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING count(*) >= 2 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id, first name, and last name of the driver who was in the first position for laptime at least twice? | SELECT T1.driverid , T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE POSITION = '1' GROUP BY T1.driverid HAVING count(*) >= 2 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | How many drivers participated in the race Australian Grand Prix held in 2009? | SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | How many drivers were in the Australian Grand Prix held in 2009? | SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | How many drivers did not participate in the races held in 2009? | SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 ) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | How many drivers did not race in 2009? | SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 ) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Give me a list of names and years of races that had any driver whose forename is Lewis? | SELECT T2.name , T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the names and years of all races that had a driver with the last name Lewis? | SELECT T2.name , T2.year FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T1.driverid = T3.driverid WHERE T3.forename = "Lewis" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the forename and surname of drivers whose nationality is German? | SELECT forename , surname FROM drivers WHERE nationality = "German" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the first and last name of all the German drivers? | SELECT forename , surname FROM drivers WHERE nationality = "German" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the id and forenames of drivers who participated both the races with name Australian Grand Prix and the races with name Chinese Grand Prix? | SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix? | SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" INTERSECT SELECT T2.driverid , T3.forename FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the forenames and surnames of drivers who participated in the races named Australian Grand Prix but not the races named Chinese Grand Prix? | SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix? | SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Australian Grand Prix" EXCEPT SELECT T3.forename , T3.surname FROM races AS T1 JOIN results AS T2 ON T1.raceid = T2.raceid JOIN drivers AS T3 ON T2.driverid = T3.driverid WHERE T1.name = "Chinese Grand Prix" | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find all the forenames of distinct drivers who was in position 1 as standing and won? | SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are all the different first names of the drivers who are in position as standing and won? | SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points? | SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the first names of the different drivers who won in position 1 as driver standing and had more than 20 points? | SELECT DISTINCT T1.forename FROM drivers AS T1 JOIN driverstandings AS T2 ON T1.driverid = T2.driverid WHERE T2.position = 1 AND T2.wins = 1 AND T2.points > 20 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the numbers of constructors for different nationalities? | SELECT count(*) , nationality FROM constructors GROUP BY nationality | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | For each nationality, how many different constructors are there? | SELECT count(*) , nationality FROM constructors GROUP BY nationality | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the numbers of races for each constructor id? | SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | For each constructor id, how many races are there? | SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the names of races that were held after 2017 and the circuits were in the country of Spain? | SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the names of the races held after 2017 in Spain? | SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the unique names of races that held after 2000 and the circuits were in Spain? | SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the names of all races held after 2000 in Spain? | SELECT DISTINCT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2000 | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the distinct driver id and the stop number of all drivers that have a shorter pit stop duration than some drivers in the race with id 841. | SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What is the id and stop number for each driver that has a shorter pit stop than the driver in the race with id 841? | SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841? | SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | What are the different ids and stop durations of all the drivers whose stop lasted longer than the driver in the race with the id 841? | SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841) | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
formula_1 | List the forenames of all distinct drivers in alphabetical order? | SELECT DISTINCT forename FROM drivers ORDER BY forename ASC | CREATE TABLE "circuits" (
"circuitId" INTEGER PRIMARY KEY,
"circuitRef" TEXT,
"name" TEXT,
"location" TEXT,
"country" TEXT,
"lat" REAL,
"lng" REAL,
"alt" TEXT,
"url" TEXT
)
3 rows from circuits table:
circuitId circuitRef name location country lat lng alt url
1 albert_park Albert Park Grand Prix Circuit Melbourne Australia -37.84970 144.9680 10 http://en.wikipedia.org/wiki/Melbourne_Grand_Prix_Circuit
2 sepang Sepang International Circuit Kuala Lumpur Malaysia 2.76083 101.7380 http://en.wikipedia.org/wiki/Sepang_International_Circuit
3 bahrain Bahrain International Circuit Sakhir Bahrain 26.03250 50.5106 http://en.wikipedia.org/wiki/Bahrain_International_Circuit
CREATE TABLE "races" (
"raceId" INTEGER PRIMARY KEY,
"year" INTEGER,
"round" INTEGER,
"circuitId" INTEGER,
"name" TEXT,
"date" TEXT,
"time" TEXT,
"url" TEXT,
FOREIGN KEY ("circuitId") REFERENCES "circuits"("circuitId")
)
3 rows from races table:
raceId year round circuitId name date time url
1 2009 1 1 Australian Grand Prix 2009-03-29 06:00:00 http://en.wikipedia.org/wiki/2009_Australian_Grand_Prix
2 2009 2 2 Malaysian Grand Prix 2009-04-05 09:00:00 http://en.wikipedia.org/wiki/2009_Malaysian_Grand_Prix
3 2009 3 17 Chinese Grand Prix 2009-04-19 07:00:00 http://en.wikipedia.org/wiki/2009_Chinese_Grand_Prix
CREATE TABLE "drivers" (
"driverId" INTEGER PRIMARY KEY,
"driverRef" TEXT,
"number" TEXT,
"code" TEXT,
"forename" TEXT,
"surname" TEXT,
"dob" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from drivers table:
driverId driverRef number code forename surname dob nationality url
1 hamilton 44 HAM Lewis Hamilton 07/01/1985 British http://en.wikipedia.org/wiki/Lewis_Hamilton
2 heidfeld HEI Nick Heidfeld 10/05/1977 German http://en.wikipedia.org/wiki/Nick_Heidfeld
3 rosberg 6 ROS Nico Rosberg 27/06/1985 German http://en.wikipedia.org/wiki/Nico_Rosberg
CREATE TABLE "status" (
"statusId" INTEGER PRIMARY KEY,
"status" TEXT
)
3 rows from status table:
statusId status
1 Finished
2 Disqualified
3 Accident
CREATE TABLE "seasons" (
"year" INTEGER PRIMARY KEY,
"url" TEXT
)
3 rows from seasons table:
year url
1950 http://en.wikipedia.org/wiki/1950_Formula_One_season
1951 http://en.wikipedia.org/wiki/1951_Formula_One_season
1952 http://en.wikipedia.org/wiki/1952_Formula_One_season
CREATE TABLE "constructors" (
"constructorId" INTEGER PRIMARY KEY,
"constructorRef" TEXT,
"name" TEXT,
"nationality" TEXT,
"url" TEXT
)
3 rows from constructors table:
constructorId constructorRef name nationality url
1 mclaren McLaren British http://en.wikipedia.org/wiki/McLaren
2 bmw_sauber BMW Sauber German http://en.wikipedia.org/wiki/BMW_Sauber
3 williams Williams British http://en.wikipedia.org/wiki/Williams_Grand_Prix_Engineering
CREATE TABLE "constructorStandings" (
"constructorStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorStandings table:
constructorStandingsId raceId constructorId points position positionText wins
1 18 1 14.0 1 1 1
2 18 2 8.0 3 3 0
3 18 3 9.0 2 2 0
CREATE TABLE "results" (
"resultId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"grid" INTEGER,
"position" TEXT,
"positionText" TEXT,
"positionOrder" INTEGER,
"points" REAL,
"laps" TEXT,
"time" TEXT,
"milliseconds" TEXT,
"fastestLap" TEXT,
"rank" TEXT,
"fastestLapTime" TEXT,
"fastestLapSpeed" TEXT,
"statusId" INTEGER,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from results table:
resultId raceId driverId constructorId number grid position positionText positionOrder points laps time milliseconds fastestLap rank fastestLapTime fastestLapSpeed statusId
1 18 1 1 22 1 1 1 1 10.0 58 34:50.6 5690616 39 2 01:27.5 218.3 1
2 18 2 2 3 5 2 2 2 8.0 58 5.478 5696094 41 3 01:27.7 217.586 1
3 18 3 3 7 7 3 3 3 6.0 58 8.163 5698779 41 5 01:28.1 216.719 1
CREATE TABLE "driverStandings" (
"driverStandingsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"points" REAL,
"position" INTEGER,
"positionText" TEXT,
"wins" INTEGER,
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from driverStandings table:
driverStandingsId raceId driverId points position positionText wins
1 18 1 10.0 1 1 1
2 18 2 8.0 2 2 0
3 18 3 6.0 3 3 0
CREATE TABLE "constructorResults" (
"constructorResultsId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"constructorId" INTEGER,
"points" REAL,
"status" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId")
)
3 rows from constructorResults table:
constructorResultsId raceId constructorId points status
1 18 1 14.0 NULL
2 18 2 8.0 NULL
3 18 3 9.0 NULL
CREATE TABLE "qualifying" (
"qualifyId" INTEGER PRIMARY KEY,
"raceId" INTEGER,
"driverId" INTEGER,
"constructorId" INTEGER,
"number" INTEGER,
"position" INTEGER,
"q1" TEXT,
"q2" TEXT,
"q3" TEXT,
FOREIGN KEY("constructorId") REFERENCES "constructors"("constructorId"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from qualifying table:
qualifyId raceId driverId constructorId number position q1 q2 q3
1 18 1 1 22 1 1:26.572 1:25.187 1:26.714
2 18 9 2 4 2 1:26.103 1:25.315 1:26.869
3 18 5 1 23 3 1:25.664 1:25.452 1:27.079
CREATE TABLE "pitStops" (
"raceId" INTEGER,
"driverId" INTEGER,
"stop" INTEGER,
"lap" INTEGER,
"time" TEXT,
"duration" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY ("raceId", "driverId", "stop"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from pitStops table:
Empty DataFrame
Columns: [raceId, driverId, stop, lap, time, duration, milliseconds]
Index: []
CREATE TABLE "lapTimes" (
"raceId" INTEGER,
"driverId" INTEGER,
"lap" INTEGER,
"position" INTEGER,
"time" TEXT,
"milliseconds" INTEGER,
PRIMARY KEY("raceId", "driverId", "lap"),
FOREIGN KEY("raceId") REFERENCES "races"("raceId"),
FOREIGN KEY ("driverId") REFERENCES "drivers"("driverId")
)
3 rows from lapTimes table:
Empty DataFrame
Columns: [raceId, driverId, lap, position, time, milliseconds]
Index: []
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.