sert121/SpiderSQL huggingface dataset:
-- 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.



Question: Which employee has showed up in most circulation history documents. List the employee's name and the number of drafts and copies.
SQL: SELECT Employees.employee_name , count(*) FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id GROUP BY Circulation_History.document_id , Circulation_History.draft_number , Circulation_History.copy_number ORDER BY count(*) DESC LIMIT 1;
-- 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.



Question: For each document, list the number of employees who have showed up in the circulation history of that document. List the document ids and number of employees.
SQL: SELECT document_id ,  count(DISTINCT employee_id) FROM Circulation_History GROUP BY document_id;
-- 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.



Question: List all department names ordered by their starting date.
SQL: SELECT dname FROM department ORDER BY mgr_start_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.



Question: find all dependent names who have a spouse relation with some employee.
SQL: SELECT Dependent_name FROM dependent WHERE relationship  =  'Spouse'
-- 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.



Question: how many female dependents are there?
SQL: SELECT count(*) FROM dependent WHERE sex  =  'F'
-- 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.



Question: Find the names of departments that are located in Houston.
SQL: SELECT t1.dname FROM department AS t1 JOIN dept_locations AS t2 ON t1.dnumber  =  t2.dnumber WHERE t2.dlocation  =  'Houston'
-- 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.



Question: Return the first names and last names of employees who earn more than 30000 in salary.
SQL: SELECT fname ,  lname FROM employee WHERE salary  >  30000
-- 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.



Question: Find the number of employees of each gender whose salary is lower than 50000.
SQL: SELECT count(*) ,  sex FROM employee WHERE salary  <  50000 GROUP BY sex
-- 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.



Question: list the first and last names, and the addresses of all employees in the ascending order of their birth date.
SQL: SELECT fname ,  lname ,  address FROM employee ORDER BY Bdate
-- 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.



Question: what are the event details of the services that have the type code 'Marriage'?
SQL: SELECT T1.event_details FROM EVENTS AS T1 JOIN Services AS T2 ON T1.Service_ID  =  T2.Service_ID WHERE T2.Service_Type_Code  =  'Marriage'
-- 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.



Question: What are the ids and details of events that have more than one participants?
SQL: SELECT T1.event_id ,  T1.event_details FROM EVENTS AS T1 JOIN Participants_in_Events AS T2 ON T1.Event_ID  =  T2.Event_ID GROUP BY T1.Event_ID HAVING count(*)  >  1
-- 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.



Question: How many events have each participants attended? List the participant id, type and the number.
SQL: SELECT T1.Participant_ID ,  T1.Participant_Type_Code ,  count(*) FROM Participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID  =  T2.Participant_ID GROUP BY T1.Participant_ID
-- 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.



Question: What are all the the participant ids, type code and details?
SQL: SELECT Participant_ID ,  Participant_Type_Code ,  Participant_Details FROM  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.



Question: How many participants belong to the type 'Organizer'?
SQL: SELECT count(*) FROM participants WHERE participant_type_code  =  '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.



Question: List the type of the services in alphabetical order.
SQL: SELECT service_type_code FROM services ORDER BY service_type_code
-- 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.



Question: List the service id and details for the events.
SQL: SELECT service_id ,  event_details FROM 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.



Question: How many events had participants whose details had the substring 'Dr.'
SQL: SELECT count(*) FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID  =  T2.Participant_ID WHERE T1.participant_details LIKE '%Dr.%'
-- 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.



Question: What is the most common participant type?
SQL: SELECT participant_type_code FROM participants GROUP BY participant_type_code ORDER BY count(*) DESC LIMIT 1
-- 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.



Question: Which service id and type has the least number of participants?
SQL: SELECT T3.service_id ,  T4.Service_Type_Code FROM participants AS T1 JOIN Participants_in_Events AS T2 ON T1.Participant_ID  =  T2.Participant_ID JOIN EVENTS AS T3 ON T2.Event_ID   =  T3.Event_ID JOIN services AS T4 ON T3.service_id  =  T4.service_id GROUP BY T3.service_id ORDER BY count(*) ASC LIMIT 1
-- 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.



Question: What is the id of the event with the most participants?
SQL: SELECT Event_ID FROM Participants_in_Events GROUP BY Event_ID ORDER BY count(*) DESC LIMIT 1
-- 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.



Question: Which events id does not have any participant with detail 'Kenyatta Kuhn'?
SQL: SELECT event_id FROM EVENTS EXCEPT SELECT T1.event_id FROM Participants_in_Events AS T1 JOIN Participants AS T2 ON T1.Participant_ID  =  T2.Participant_ID WHERE Participant_Details  =  'Kenyatta Kuhn'
-- 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.



Question: Which services type had both successful and failure event details?
SQL: SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id  =  T2.service_id WHERE T2.event_details  =  'Success' INTERSECT SELECT T1.service_type_code FROM services AS T1 JOIN EVENTS AS T2 ON T1.service_id  =  T2.service_id WHERE T2.event_details  =  'Fail'
-- 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.



Question: How many events did not have any participants?
SQL: SELECT count(*) FROM EVENTS WHERE event_id NOT IN (SELECT event_id FROM Participants_in_Events)
-- 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.



Question: What are all the distinct participant ids who attended any events?
SQL: SELECT count(DISTINCT participant_id) FROM participants_in_Events
-- 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.



Question: What is the name of the race held most recently?
SQL: SELECT name FROM races ORDER BY date DESC LIMIT 1
-- 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.



Question: What is the name of the race that occurred most recently?
SQL: SELECT name FROM races ORDER BY date DESC LIMIT 1
-- 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.



Question: What is the name and date of the most recent race?
SQL: SELECT name ,  date FROM races ORDER BY date DESC LIMIT 1
-- 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.



Question: What is the name and date of the race that occurred most recently?
SQL: SELECT name ,  date FROM races ORDER BY date DESC LIMIT 1
-- 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.



Question: Find the names of all races held in 2017.
SQL: SELECT name FROM races WHERE 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.



Question: What are the names of all the races that occurred in the year 2017?
SQL: SELECT name FROM races WHERE YEAR = 2017