brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
What document type codes do we have?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What document type codes do we have?` to a syntactically-correct PostgreSQL query.
SELECT document_type_code FROM Ref_Document_Types;
What is the description of document type 'Paper'?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the description of document type 'Paper'?` to a syntactically-correct PostgreSQL query.
SELECT document_type_description FROM Ref_Document_Types WHERE document_type_code = "Paper";
What are the shipping agent names?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the shipping agent names?` to a syntactically-correct PostgreSQL query.
SELECT shipping_agent_name FROM Ref_Shipping_Agents;
What is the shipping agent code of shipping agent UPS?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the shipping agent code of shipping agent UPS?` to a syntactically-correct PostgreSQL query.
SELECT shipping_agent_code FROM Ref_Shipping_Agents WHERE shipping_agent_name = "UPS";
What are all role codes?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are all role codes?` to a syntactically-correct PostgreSQL query.
SELECT role_code FROM ROLES;
What is the description of role code ED?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the description of role code ED?` to a syntactically-correct PostgreSQL query.
SELECT role_description FROM ROLES WHERE role_code = "ED";
How many employees do we have?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many employees do we have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Employees;
What is the role of the employee named Koby?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the role of the employee named Koby?` to a syntactically-correct PostgreSQL query.
SELECT T1.role_description FROM ROLES AS T1 JOIN Employees AS T2 ON T1.role_code = T2.role_code WHERE T2.employee_name = "Koby";
List all document ids and receipt dates of documents.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List all document ids and receipt dates of documents.` to a syntactically-correct PostgreSQL query.
SELECT document_id , receipt_date FROM Documents;
How many employees does each role have? List role description, id and number of employees.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many employees does each role have? List role description, id and number of employees.` to a syntactically-correct PostgreSQL query.
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;
List roles that have more than one employee. List the role description and number of employees.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List roles that have more than one employee. List the role description and number of employees.` to a syntactically-correct PostgreSQL query.
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;
What is the document status description of the document with id 1?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the document status description of the document with id 1?` to a syntactically-correct PostgreSQL query.
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;
How many documents have the status code done?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many documents have the status code done?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Documents WHERE document_status_code = "done";
List the document type code for the document with the id 2.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the document type code for the document with the id 2.` to a syntactically-correct PostgreSQL query.
SELECT document_type_code FROM Documents WHERE document_id = 2;
List the document ids for any documents with the status code done and the type code paper.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the document ids for any documents with the status code done and the type code paper.` to a syntactically-correct PostgreSQL query.
SELECT document_id FROM Documents WHERE document_status_code = "done" AND document_type_code = "Paper";
What is the name of the shipping agent of the document with id 2?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name of the shipping agent of the document with id 2?` to a syntactically-correct PostgreSQL query.
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;
How many documents were shipped by USPS?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many documents were shipped by USPS?` to a syntactically-correct PostgreSQL query.
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";
Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which shipping agent shipped the most documents? List the shipping agent name and the number of documents.` to a syntactically-correct PostgreSQL query.
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;
What is the receipt date of the document with id 3?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the receipt date of the document with id 3?` to a syntactically-correct PostgreSQL query.
SELECT receipt_date FROM Documents WHERE document_id = 3;
What address was the document with id 4 mailed to?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What address was the document with id 4 mailed to?` to a syntactically-correct PostgreSQL query.
SELECT Addresses.address_details FROM Addresses JOIN Documents_Mailed ON Documents_Mailed.mailed_to_address_id = Addresses.address_id WHERE document_id = 4;
What is the mail date of the document with id 7?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the mail date of the document with id 7?` to a syntactically-correct PostgreSQL query.
SELECT mailing_date FROM Documents_Mailed WHERE document_id = 7;
List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the document ids of documents with the status done and type Paper, which not shipped by the shipping agent named USPS.` to a syntactically-correct PostgreSQL query.
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";
List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List document id of documents status is done and document type is Paper and the document is shipped by shipping agent named USPS.` to a syntactically-correct PostgreSQL query.
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";
What is draft detail of the document with id 7?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is draft detail of the document with id 7?` to a syntactically-correct PostgreSQL query.
SELECT draft_details FROM Document_Drafts WHERE document_id = 7;
How many draft copies does the document with id 2 have?
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many draft copies does the document with id 2 have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM Draft_Copies WHERE document_id = 2;
Which document has the most draft copies? List its document id and number of draft copies.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which document has the most draft copies? List its document id and number of draft copies.` to a syntactically-correct PostgreSQL query.
SELECT document_id , count(copy_number) FROM Draft_Copies GROUP BY document_id ORDER BY count(copy_number) DESC LIMIT 1;
Which documents have more than 1 draft copies? List document id and number of draft copies.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which documents have more than 1 draft copies? List document id and number of draft copies.` to a syntactically-correct PostgreSQL query.
SELECT document_id , count(*) FROM Draft_Copies GROUP BY document_id HAVING count(*) > 1;
List all employees in the circulation history of the document with id 1. List the employee's name.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List all employees in the circulation history of the document with id 1. List the employee's name.` to a syntactically-correct PostgreSQL query.
SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1;
List the employees who have not showed up in any circulation history of documents. List the employee's name.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the employees who have not showed up in any circulation history of documents. List the employee's name.` to a syntactically-correct PostgreSQL query.
SELECT employee_name FROM Employees EXCEPT SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id
Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.` to a syntactically-correct PostgreSQL query.
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;
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.
-- Language PostgreSQL -- Tables: -- Table: reference document types columns : [['document type code', 'text'], ['document type description', 'text']] -- Table: roles columns : [['role code', 'text'], ['role description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['address details', 'text']] -- Table: reference document status columns : [['document status code', 'text'], ['document status description', 'text']] -- Table: reference shipping agents columns : [['shipping agent code', 'text'], ['shipping agent name', 'text'], ['shipping agent description', 'text']] -- Table: documents columns : [['document id', 'number'], ['document status code', 'text'], ['document type code', 'text'], ['shipping agent code', 'text'], ['receipt date', 'time'], ['receipt number', 'text'], ['other details', 'text']] -- Table: employees columns : [['employee id', 'number'], ['role code', 'text'], ['employee name', 'text'], ['other details', 'text']] -- Table: document drafts columns : [['document id', 'number'], ['draft number', 'number'], ['draft details', 'text']] -- Table: draft copies columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number']] -- Table: circulation history columns : [['document id', 'number'], ['draft number', 'number'], ['copy number', 'number'], ['employee id', 'number']] -- Table: documents mailed columns : [['document id', 'number'], ['mailed to address id', 'number'], ['mailing date', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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.` to a syntactically-correct PostgreSQL query.
SELECT document_id , count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id;
List all department names ordered by their starting date.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List all department names ordered by their starting date.` to a syntactically-correct PostgreSQL query.
SELECT dname FROM department ORDER BY mgr_start_date
find all dependent names who have a spouse relation with some employee.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `find all dependent names who have a spouse relation with some employee.` to a syntactically-correct PostgreSQL query.
SELECT Dependent_name FROM dependent WHERE relationship = 'Spouse'
how many female dependents are there?
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `how many female dependents are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM dependent WHERE sex = 'F'
Find the names of departments that are located in Houston.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the names of departments that are located in Houston.` to a syntactically-correct PostgreSQL query.
SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber = t2.dnumber WHERE t2.dlocation = 'Houston'
Return the first names and last names of employees who earn more than 30000 in salary.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Return the first names and last names of employees who earn more than 30000 in salary.` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM employee WHERE salary > 30000
Find the number of employees of each gender whose salary is lower than 50000.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the number of employees of each gender whose salary is lower than 50000.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , sex FROM employee WHERE salary < 50000 GROUP BY sex
list the first and last names, and the addresses of all employees in the ascending order of their birth date.
-- Language PostgreSQL -- Tables: -- Table: works on columns : [['employee ssn', 'number'], ['project number', 'number'], ['hours', 'number']] -- Table: employee columns : [['first name', 'text'], ['minit', 'text'], ['last name', 'text'], ['ssn', 'number'], ['birth date', 'text'], ['address', 'text'], ['sex', 'text'], ['salary', 'number'], ['super ssn', 'number'], ['department no', 'number']] -- Table: department columns : [['department name', 'text'], ['department number', 'number'], ['manager ssn', 'number'], ['manager start date', 'text']] -- Table: project columns : [['dependent name', 'text'], ['dependent number', 'number'], ['dependent location', 'text'], ['department number', 'number']] -- Table: dependent columns : [['employee ssn', 'number'], ['dependent name', 'text'], ['sex', 'text'], ['birth date', 'text'], ['relationship', 'text']] -- Table: department locations columns : [['department number', 'number'], ['department location', 'text']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `list the first and last names, and the addresses of all employees in the ascending order of their birth date.` to a syntactically-correct PostgreSQL query.
SELECT fname , lname , address FROM employee ORDER BY Bdate
what are the event details of the services that have the type code 'Marriage'?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `what are the event details of the services that have the type code 'Marriage'?` to a syntactically-correct PostgreSQL query.
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'
What are the ids and details of events that have more than one participants?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the ids and details of events that have more than one participants?` to a syntactically-correct PostgreSQL query.
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
How many events have each participants attended? List the participant id, type and the number.
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many events have each participants attended? List the participant id, type and the number.` to a syntactically-correct PostgreSQL query.
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
What are all the the participant ids, type code and details?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are all the the participant ids, type code and details?` to a syntactically-correct PostgreSQL query.
SELECT Participant_ID , Participant_Type_Code , Participant_Details FROM Participants
How many participants belong to the type 'Organizer'?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many participants belong to the type 'Organizer'?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM participants WHERE participant_type_code = 'Organizer'
List the type of the services in alphabetical order.
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the type of the services in alphabetical order.` to a syntactically-correct PostgreSQL query.
SELECT service_type_code FROM services ORDER BY service_type_code
List the service id and details for the events.
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the service id and details for the events.` to a syntactically-correct PostgreSQL query.
SELECT service_id , event_details FROM EVENTS
How many events had participants whose details had the substring 'Dr.'
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many events had participants whose details had the substring 'Dr.'` to a syntactically-correct PostgreSQL query.
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.%'
What is the most common participant type?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the most common participant type?` to a syntactically-correct PostgreSQL query.
SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1
Which service id and type has the least number of participants?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which service id and type has the least number of participants?` to a syntactically-correct PostgreSQL query.
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
What is the id of the event with the most participants?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id of the event with the most participants?` to a syntactically-correct PostgreSQL query.
SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1
Which events id does not have any participant with detail 'Kenyatta Kuhn'?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which events id does not have any participant with detail 'Kenyatta Kuhn'?` to a syntactically-correct PostgreSQL query.
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'
Which services type had both successful and failure event details?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Which services type had both successful and failure event details?` to a syntactically-correct PostgreSQL query.
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'
How many events did not have any participants?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many events did not have any participants?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events)
What are all the distinct participant ids who attended any events?
-- Language PostgreSQL -- Tables: -- Table: services columns : [['service id', 'number'], ['service type code', 'text']] -- Table: participants columns : [['participant id', 'number'], ['participant type code', 'text'], ['participant details', 'text']] -- Table: events columns : [['event id', 'number'], ['service id', 'number'], ['event details', 'text']] -- Table: participants in events columns : [['event id', 'number'], ['participant id', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are all the distinct participant ids who attended any events?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT participant_id) FROM participants_in_Events
What is the name of the race held most recently?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name of the race held most recently?` to a syntactically-correct PostgreSQL query.
SELECT name FROM races ORDER BY date DESC LIMIT 1
What is the name of the race that occurred most recently?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name of the race that occurred most recently?` to a syntactically-correct PostgreSQL query.
SELECT name FROM races ORDER BY date DESC LIMIT 1
What is the name and date of the most recent race?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name and date of the most recent race?` to a syntactically-correct PostgreSQL query.
SELECT name , date FROM races ORDER BY date DESC LIMIT 1
What is the name and date of the race that occurred most recently?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the name and date of the race that occurred most recently?` to a syntactically-correct PostgreSQL query.
SELECT name , date FROM races ORDER BY date DESC LIMIT 1
Find the names of all races held in 2017.
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the names of all races held in 2017.` to a syntactically-correct PostgreSQL query.
SELECT name FROM races WHERE YEAR = 2017
What are the names of all the races that occurred in the year 2017?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names of all the races that occurred in the year 2017?` to a syntactically-correct PostgreSQL query.
SELECT name FROM races WHERE YEAR = 2017
Find the distinct names of all races held between 2014 and 2017?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the distinct names of all races held between 2014 and 2017?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
What are the unique names of all race held between 2014 and 2017?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the unique names of all race held between 2014 and 2017?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT name FROM races WHERE YEAR BETWEEN 2014 AND 2017
List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the forename and surname of all distinct drivers who once had laptime less than 93000 milliseconds?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
What are the forenames and surnames of all unique drivers who had a lap time of less than 93000 milliseconds?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the forenames and surnames of all unique drivers who had a lap time of less than 93000 milliseconds?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds < 93000
Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find all the distinct id and nationality of drivers who have had laptime more than 100000 milliseconds?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the different driver ids and nationalities of all drivers who had a laptime of more than 100000 milliseconds?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.driverid , T1.nationality FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid WHERE T2.milliseconds > 100000
What are the forename and surname of the driver who has the smallest laptime?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the forename and surname of the driver who has the smallest laptime?` to a syntactically-correct PostgreSQL query.
SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
What is the forename and surname of the driver with the shortest laptime?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the forename and surname of the driver with the shortest laptime?` to a syntactically-correct PostgreSQL query.
SELECT T1.forename , T1.surname FROM drivers AS T1 JOIN laptimes AS T2 ON T1.driverid = T2.driverid ORDER BY T2.milliseconds LIMIT 1
What is the id and family name of the driver who has the longest laptime?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id and family name of the driver who has the longest laptime?` to a syntactically-correct PostgreSQL query.
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
What is the id and last name of the driver with the longest laptime?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id and last name of the driver with the longest laptime?` to a syntactically-correct PostgreSQL query.
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
What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id, forname and surname of the driver who had the first position in terms of laptime at least twice?` to a syntactically-correct PostgreSQL query.
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
What is the id, first name, and last name of the driver who was in the first position for laptime at least twice?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id, first name, and last name of the driver who was in the first position for laptime at least twice?` to a syntactically-correct PostgreSQL query.
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
How many drivers participated in the race Australian Grand Prix held in 2009?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many drivers participated in the race Australian Grand Prix held in 2009?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
How many drivers were in the Australian Grand Prix held in 2009?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many drivers were in the Australian Grand Prix held in 2009?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM results AS T1 JOIN races AS T2 ON T1.raceid = T2.raceid WHERE T2.name = "Australian Grand Prix" AND YEAR = 2009
How many drivers did not participate in the races held in 2009?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many drivers did not participate in the races held in 2009?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
How many drivers did not race in 2009?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `How many drivers did not race in 2009?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT driverId) FROM results WHERE raceId NOT IN( SELECT raceId FROM races WHERE YEAR != 2009 )
Give me a list of names and years of races that had any driver whose forename is Lewis?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Give me a list of names and years of races that had any driver whose forename is Lewis?` to a syntactically-correct PostgreSQL query.
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"
What are the names and years of all races that had a driver with the last name Lewis?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names and years of all races that had a driver with the last name Lewis?` to a syntactically-correct PostgreSQL query.
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"
Find the forename and surname of drivers whose nationality is German?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the forename and surname of drivers whose nationality is German?` to a syntactically-correct PostgreSQL query.
SELECT forename , surname FROM drivers WHERE nationality = "German"
What is the first and last name of all the German drivers?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the first and last name of all the German drivers?` to a syntactically-correct PostgreSQL query.
SELECT forename , surname FROM drivers WHERE nationality = "German"
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?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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?` to a syntactically-correct PostgreSQL query.
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"
What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What is the id and first name of all the drivers who participated in the Australian Grand Prix and the Chinese Grand Prix?` to a syntactically-correct PostgreSQL query.
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"
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?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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?` to a syntactically-correct PostgreSQL query.
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"
What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the first and last names of all drivers who participated in the Australian Grand Prix but not the Chinese Grand Prix?` to a syntactically-correct PostgreSQL query.
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"
Find all the forenames of distinct drivers who was in position 1 as standing and won?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find all the forenames of distinct drivers who was in position 1 as standing and won?` to a syntactically-correct PostgreSQL query.
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
What are all the different first names of the drivers who are in position as standing and won?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are all the different first names of the drivers who are in position as standing and won?` to a syntactically-correct PostgreSQL query.
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
Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find all the forenames of distinct drivers who won in position 1 as driver standing and had more than 20 points?` to a syntactically-correct PostgreSQL query.
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
What are the first names of the different drivers who won in position 1 as driver standing and had more than 20 points?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the first names of the different drivers who won in position 1 as driver standing and had more than 20 points?` to a syntactically-correct PostgreSQL query.
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
What are the numbers of constructors for different nationalities?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the numbers of constructors for different nationalities?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , nationality FROM constructors GROUP BY nationality
For each nationality, how many different constructors are there?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `For each nationality, how many different constructors are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , nationality FROM constructors GROUP BY nationality
What are the numbers of races for each constructor id?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the numbers of races for each constructor id?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
For each constructor id, how many races are there?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `For each constructor id, how many races are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , constructorid FROM constructorStandings GROUP BY constructorid
What are the names of races that were held after 2017 and the circuits were in the country of Spain?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names of races that were held after 2017 and the circuits were in the country of Spain?` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
What are the names of the races held after 2017 in Spain?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names of the races held after 2017 in Spain?` to a syntactically-correct PostgreSQL query.
SELECT T1.name FROM races AS T1 JOIN circuits AS T2 ON T1.circuitid = T2.circuitid WHERE T2.country = "Spain" AND T1.year > 2017
What are the unique names of races that held after 2000 and the circuits were in Spain?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the unique names of races that held after 2000 and the circuits were in Spain?` to a syntactically-correct PostgreSQL query.
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
What are the names of all races held after 2000 in Spain?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `What are the names of all races held after 2000 in Spain?` to a syntactically-correct PostgreSQL query.
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
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.
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
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?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration < (SELECT max(duration) FROM pitstops WHERE raceid = 841)
Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `Find the distinct driver id of all drivers that have a longer stop duration than some drivers in the race whose id is 841?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
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?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `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?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT driverid , STOP FROM pitstops WHERE duration > (SELECT min(duration) FROM pitstops WHERE raceid = 841)
List the forenames of all distinct drivers in alphabetical order?
-- Language PostgreSQL -- Tables: -- Table: circuits columns : [['circuit id', 'number'], ['circuit reference', 'text'], ['name', 'text'], ['location', 'text'], ['country', 'text'], ['latitude', 'number'], ['longitude', 'number'], ['altitude', 'number'], ['url', 'text']] -- Table: races columns : [['race id', 'number'], ['year', 'number'], ['round', 'number'], ['circuit id', 'number'], ['name', 'text'], ['date', 'text'], ['time', 'text'], ['url', 'text']] -- Table: drivers columns : [['driver id', 'number'], ['driver reference', 'text'], ['number', 'number'], ['code', 'text'], ['forename', 'text'], ['surname', 'text'], ['dob', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: status columns : [['status id', 'number'], ['status', 'text']] -- Table: seasons columns : [['year', 'number'], ['url', 'text']] -- Table: constructors columns : [['constructor id', 'number'], ['constructor reference', 'text'], ['name', 'text'], ['nationality', 'text'], ['url', 'text']] -- Table: constructor standings columns : [['constructor standings id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: results columns : [['result id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['grid', 'number'], ['position', 'number'], ['position text', 'text'], ['position order', 'number'], ['points', 'number'], ['laps', 'number'], ['time', 'text'], ['milliseconds', 'number'], ['fastest lap', 'number'], ['rank', 'number'], ['fastest lap time', 'text'], ['fastest lap speed', 'text'], ['status id', 'number']] -- Table: driver standings columns : [['driver standings id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['points', 'number'], ['position', 'number'], ['position text', 'text'], ['wins', 'number']] -- Table: constructor results columns : [['constructor results id', 'number'], ['race id', 'number'], ['constructor id', 'number'], ['points', 'number'], ['status', 'number']] -- Table: qualifying columns : [['qualify id', 'number'], ['race id', 'number'], ['driver id', 'number'], ['constructor id', 'number'], ['number', 'number'], ['position', 'number'], ['q1', 'text'], ['q2', 'text'], ['q3', 'text']] -- Table: pit stops columns : [['race id', 'number'], ['driver id', 'number'], ['stop', 'number'], ['lap', 'number'], ['time', 'text'], ['duration', 'text'], ['milliseconds', 'number']] -- Table: lap times columns : [['race id', 'number'], ['driver id', 'number'], ['lap', 'number'], ['position', 'number'], ['time', 'text'], ['milliseconds', 'number']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the tables provided to you. Think step by step. Your only output should be SQL code. Do not include any other text. Only SQL code. Translate `List the forenames of all distinct drivers in alphabetical order?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT forename FROM drivers ORDER BY forename ASC