db_name
stringclasses 146
values | prompt
stringlengths 310
4.81k
|
---|---|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What document type codes do we have?
#
### SQL:
#
# SELECT document_type_code FROM Ref_Document_Types;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the description of document type 'Paper'?
#
### SQL:
#
# SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What are the shipping agent names?
#
### SQL:
#
# SELECT shipping_agent_name FROM Ref_Shipping_Agents;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the shipping agent code of shipping agent UPS?
#
### SQL:
#
# SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What are all role codes?
#
### SQL:
#
# SELECT role_code FROM ROLES;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the description of role code ED?
#
### SQL:
#
# SELECT role_description FROM ROLES WHERE role_code = "ED";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# How many employees do we have?
#
### SQL:
#
# SELECT count(*) FROM Employees;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the role of the employee named Koby?
#
### SQL:
#
# SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List all document ids and receipt dates of documents.
#
### SQL:
#
# SELECT document_id , receipt_date FROM Documents;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# How many employees does each role have? List role description, id and number of employees.
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List roles that have more than one employee. List the role description and number of employees.
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the document status description of the document with id 1?
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# How many documents have the status code done?
#
### SQL:
#
# SELECT count(*) FROM Documents WHERE document_status_code = "done";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List the document type code for the document with the id 2.
#
### SQL:
#
# SELECT document_type_code FROM Documents WHERE document_id = 2;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List the document ids for any documents with the status code done and the type code paper.
#
### SQL:
#
# SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the name of the shipping agent of the document with id 2?
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# How many documents were shipped by USPS?
#
### SQL:
#
# 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";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the receipt date of the document with id 3?
#
### SQL:
#
# SELECT receipt_date FROM Documents WHERE document_id = 3;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What address was the document with id 4 mailed to?
#
### SQL:
#
# SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is the mail date of the document with id 7?
#
### SQL:
#
# SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.
#
### SQL:
#
# 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";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.
#
### SQL:
#
# 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";
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# What is draft detail of the document with id 7?
#
### SQL:
#
# SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# How many draft copies does the document with id 2 have?
#
### SQL:
#
# SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# Which document has the most draft copies? List its document id and number of draft copies.
#
### SQL:
#
# SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# Which documents have more than 1 draft copies? List document id and number of draft copies.
#
### SQL:
#
# SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List all employees in the circulation history of the document with id 1. List the employee's name.
#
### SQL:
#
# SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# List the employees who have not showed up in any circulation history of documents. List the employee's name.
#
### SQL:
#
# SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
#
### SQL:
#
# 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;
#
### End.
|
cre_Doc_Control_Systems
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Ref_Document_Types ( document_type_code, document_type_description )
# Roles ( role_code, role_description )
# Addresses ( address_id, address_details )
# Ref_Document_Status ( document_status_code, document_status_description )
# Ref_Shipping_Agents ( shipping_agent_code, shipping_agent_name, shipping_agent_description )
# Documents ( document_id, document_status_code, document_type_code, shipping_agent_code, receipt_date, receipt_number, other_details )
# Employees ( employee_id, role_code, employee_name, other_details )
# Document_Drafts ( document_id, draft_number, draft_details )
# Draft_Copies ( document_id, draft_number, copy_number )
# Circulation_History ( document_id, draft_number, copy_number, employee_id )
# Documents_Mailed ( document_id, mailed_to_address_id, mailing_date )
#
# Documents.shipping_agent_code can be joined with Ref_Shipping_Agents.shipping_agent_code
# Documents.document_status_code can be joined with Ref_Document_Status.document_status_code
# Documents.document_type_code can be joined with Ref_Document_Types.document_type_code
# Employees.role_code can be joined with Roles.role_code
# Document_Drafts.document_id can be joined with Documents.document_id
# Draft_Copies.document_id can be joined with Document_Drafts.document_id
# Draft_Copies.draft_number can be joined with Document_Drafts.draft_number
# Circulation_History.employee_id can be joined with Employees.employee_id
# Circulation_History.document_id can be joined with Draft_Copies.document_id
# Circulation_History.draft_number can be joined with Draft_Copies.draft_number
# Circulation_History.copy_number can be joined with Draft_Copies.copy_number
# Documents_Mailed.mailed_to_address_id can be joined with Addresses.address_id
# Documents_Mailed.document_id can be joined with Documents.document_id
#
### Question:
#
# 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.
#
### SQL:
#
# SELECT document_id , count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id;
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# List all department names ordered by their starting date.
#
### SQL:
#
# SELECT dname FROM department ORDER BY mgr_start_date
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# find all dependent names who have a spouse relation with some employee.
#
### SQL:
#
# SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse'
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# how many female dependents are there?
#
### SQL:
#
# SELECT count(*) FROM dependent WHERE sex = 'F'
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# Find the names of departments that are located in Houston.
#
### SQL:
#
# SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston'
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# Return the first names and last names of employees who earn more than 30000 in salary.
#
### SQL:
#
# SELECT fname , lname FROM employee WHERE salary > 30000
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# Find the number of employees of each gender whose salary is lower than 50000.
#
### SQL:
#
# SELECT count(*) , sex FROM employee WHERE salary < 50000 GROUP BY sex
#
### End.
|
company_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# works_on ( Essn, Pno, Hours )
# employee ( Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno )
# department ( Dname, Dnumber, Mgr_ssn, Mgr_start_date )
# project ( Pname, Pnumber, Plocation, Dnum )
# dependent ( Essn, Dependent_name, Sex, Bdate, Relationship )
# dept_locations ( Dnumber, Dlocation )
#
#
### Question:
#
# list the first and last names, and the addresses of all employees in the ascending order of their birth date.
#
### SQL:
#
# SELECT fname , lname , address FROM employee ORDER BY Bdate
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# what are the event details of the services that have the type code 'Marriage'?
#
### SQL:
#
# 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'
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# What are the ids and details of events that have more than one participants?
#
### SQL:
#
# 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
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# How many events have each participants attended? List the participant id, type and the number.
#
### SQL:
#
# 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
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# What are all the the participant ids, type code and details?
#
### SQL:
#
# SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# How many participants belong to the type 'Organizer'?
#
### SQL:
#
# SELECT count(*) FROM participants WHERE participant_type_code = 'Organizer'
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# List the type of the services in alphabetical order.
#
### SQL:
#
# SELECT service_type_code FROM services ORDER BY service_type_code
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# List the service id and details for the events.
#
### SQL:
#
# SELECT service_id , event_details FROM EVENTS
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# How many events had participants whose details had the substring 'Dr.'
#
### SQL:
#
# 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.%'
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# What is the most common participant type?
#
### SQL:
#
# SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# Which service id and type has the least number of participants?
#
### SQL:
#
# 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
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# What is the id of the event with the most participants?
#
### SQL:
#
# SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# Which events id does not have any participant with detail 'Kenyatta Kuhn'?
#
### SQL:
#
# 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'
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# Which services type had both successful and failure event details?
#
### SQL:
#
# 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'
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# How many events did not have any participants?
#
### SQL:
#
# SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events)
#
### End.
|
local_govt_in_alabama
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# Services ( Service_ID, Service_Type_Code )
# Participants ( Participant_ID, Participant_Type_Code, Participant_Details )
# Events ( Event_ID, Service_ID, Event_Details )
# Participants_in_Events ( Event_ID, Participant_ID )
#
# Events.Service_ID can be joined with Services.Service_ID
# Participants_in_Events.Event_ID can be joined with Events.Event_ID
# Participants_in_Events.Participant_ID can be joined with Participants.Participant_ID
#
### Question:
#
# What are all the distinct participant ids who attended any events?
#
### SQL:
#
# SELECT count(DISTINCT participant_id) FROM participants_in_Events
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the name of the race held most recently?
#
### SQL:
#
# SELECT name FROM races ORDER BY date DESC LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the name of the race that occurred most recently?
#
### SQL:
#
# SELECT name FROM races ORDER BY date DESC LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the name and date of the most recent race?
#
### SQL:
#
# SELECT name , date FROM races ORDER BY date DESC LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the name and date of the race that occurred most recently?
#
### SQL:
#
# SELECT name , date FROM races ORDER BY date DESC LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find the names of all races held in 2017.
#
### SQL:
#
# SELECT name FROM races WHERE YEAR = 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the names of all the races that occurred in the year 2017?
#
### SQL:
#
# SELECT name FROM races WHERE YEAR = 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find the distinct names of all races held between 2014 and 2017?
#
### SQL:
#
# SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the unique names of all race held between 2014 and 2017?
#
### SQL:
#
# SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?
#
### SQL:
#
# SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the forenames and surnames of all unique drivers who had a lap time of less than 93000 milliseconds?
#
### SQL:
#
# SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?
#
### SQL:
#
# SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds?
#
### SQL:
#
# SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the forename and surname of the driver who has the smallest laptime?
#
### SQL:
#
# SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the forename and surname of the driver with the shortest laptime?
#
### SQL:
#
# SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the id and family name of the driver who has the longest laptime?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the id and last name of the driver with the longest laptime?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the id, first name, and last name of the driver who was in the first position for laptime at least twice?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# How many drivers participated in the race Australian Grand Prix held in 2009?
#
### SQL:
#
# SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# How many drivers were in the Australian Grand Prix held in 2009?
#
### SQL:
#
# SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# How many drivers did not participate in the races held in 2009?
#
### SQL:
#
# SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# How many drivers did not race in 2009?
#
### SQL:
#
# SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Give me a list of names and years of races that had any driver whose forename is Lewis?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the names and years of all races that had a driver with the last name Lewis?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find the forename and surname of drivers whose nationality is German?
#
### SQL:
#
# SELECT forename , surname FROM drivers WHERE nationality = "German"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the first and last name of all the German drivers?
#
### SQL:
#
# SELECT forename , surname FROM drivers WHERE nationality = "German"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# 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?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# 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?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix?
#
### SQL:
#
# 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"
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find all the forenames of distinct drivers who was in position 1 as standing and won?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are all the different first names of the drivers who are in position as standing and won?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the first names of the different drivers who won in position 1 as driver standing and had more than 20 points?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the numbers of constructors for different nationalities?
#
### SQL:
#
# SELECT count(*) , nationality FROM constructors GROUP BY nationality
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# For each nationality, how many different constructors are there?
#
### SQL:
#
# SELECT count(*) , nationality FROM constructors GROUP BY nationality
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the numbers of races for each constructor id?
#
### SQL:
#
# SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# For each constructor id, how many races are there?
#
### SQL:
#
# SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the names of races that were held after 2017 and the circuits were in the country of Spain?
#
### SQL:
#
# SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the names of the races held after 2017 in Spain?
#
### SQL:
#
# SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the unique names of races that held after 2000 and the circuits were in Spain?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# What are the names of all races held after 2000 in Spain?
#
### SQL:
#
# 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
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# 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.
#
### SQL:
#
# SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# 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?
#
### SQL:
#
# SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?
#
### SQL:
#
# SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# 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?
#
### SQL:
#
# SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
#
### End.
|
formula_1
|
### Complete SQL query only and with no explanation
### SQL tables followed by foreign key information:
#
# circuits ( circuitId, circuitRef, name, location, country, lat, lng, alt, url )
# races ( raceId, year, round, circuitId, name, date, time, url )
# drivers ( driverId, driverRef, number, code, forename, surname, dob, nationality, url )
# status ( statusId, status )
# seasons ( year, url )
# constructors ( constructorId, constructorRef, name, nationality, url )
# constructorStandings ( constructorStandingsId, raceId, constructorId, points, position, positionText, wins )
# results ( resultId, raceId, driverId, constructorId, number, grid, position, positionText, positionOrder, points, laps, time, milliseconds, fastestLap, rank, fastestLapTime, fastestLapSpeed, statusId )
# driverStandings ( driverStandingsId, raceId, driverId, points, position, positionText, wins )
# constructorResults ( constructorResultsId, raceId, constructorId, points, status )
# qualifying ( qualifyId, raceId, driverId, constructorId, number, position, q1, q2, q3 )
# pitStops ( raceId, driverId, stop, lap, time, duration, milliseconds )
# lapTimes ( raceId, driverId, lap, position, time, milliseconds )
#
# races.circuitId can be joined with circuits.circuitId
# constructorStandings.raceId can be joined with races.raceId
# constructorStandings.constructorId can be joined with constructors.constructorId
# results.driverId can be joined with drivers.driverId
# results.raceId can be joined with races.raceId
# results.constructorId can be joined with constructors.constructorId
# driverStandings.driverId can be joined with drivers.driverId
# driverStandings.raceId can be joined with races.raceId
# constructorResults.raceId can be joined with races.raceId
# constructorResults.constructorId can be joined with constructors.constructorId
# qualifying.driverId can be joined with drivers.driverId
# qualifying.raceId can be joined with races.raceId
# qualifying.constructorId can be joined with constructors.constructorId
# pitStops.driverId can be joined with drivers.driverId
# pitStops.raceId can be joined with races.raceId
# lapTimes.driverId can be joined with drivers.driverId
# lapTimes.raceId can be joined with races.raceId
#
### Question:
#
# List the forenames of all distinct drivers in alphabetical order?
#
### SQL:
#
# SELECT DISTINCT forename FROM drivers ORDER BY forename ASC
#
### End.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.