sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 all the information on the airport with the largest number of international passengers?
SQL: SELECT * FROM airport ORDER BY International_Passengers DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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: find the name and age of the pilot who has won the most number of times among the pilots who are younger than 30.
SQL: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot WHERE t1.age  <  30 GROUP BY t2.winning_pilot ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 name and age of the pilot younger than 30 who has won the most number of times?
SQL: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot WHERE t1.age  <  30 GROUP BY t2.winning_pilot ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 name and age of the youngest winning pilot?
SQL: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot ORDER BY t1.age LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 old is the youngest winning pilot and what is their name?
SQL: SELECT t1.name ,  t1.age FROM pilot AS t1 JOIN MATCH AS t2 ON t1.pilot_id  =  t2.winning_pilot ORDER BY t1.age LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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: find the name of pilots who did not win the matches held in the country of Australia.
SQL: SELECT name FROM pilot WHERE pilot_id NOT IN (SELECT Winning_Pilot  FROM MATCH WHERE country  =  'Australia')
-- Language PostgreSQL
        -- Tables: 
             -- Table: pilot 
columns : [['pilot id', 'number'], ['name', 'text'], ['age', 'number']]

 -- Table: aircraft 
columns : [['aircraft id', 'number'], ['aircraft', 'text'], ['description', 'text'], ['max gross weight', 'text'], ['total disk area', 'text'], ['max disk loading', 'text']]

 -- Table: match 
columns : [['round', 'number'], ['location', 'text'], ['country', 'text'], ['date', 'text'], ['fastest qualifying', 'text'], ['winning pilot', 'text'], ['winning aircraft', 'text']]

 -- Table: airport 
columns : [['airport id', 'number'], ['airport name', 'text'], ['total passengers', 'number'], ['% change 2007', 'text'], ['international passengers', 'number'], ['domestic passengers', 'number'], ['transit passengers', 'number'], ['aircraft movements', 'number'], ['freight metric tonnes', 'number']]

 -- Table: airport aircraft 
columns : [['id', 'number'], ['airport id', 'number'], ['aircraft 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 names of the pilots that have not won any matches in Australia?
SQL: SELECT name FROM pilot WHERE pilot_id NOT IN (SELECT Winning_Pilot  FROM MATCH WHERE country  =  'Australia')
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 residents does each property have? List property id and resident count.
SQL: SELECT T1.property_id ,  count(*) FROM properties AS T1 JOIN residents AS T2 ON T1.property_id  =  T2.property_id GROUP BY T1.property_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What is the distinct service types that are provided by the organization which has detail 'Denesik and Sons Party'?
SQL: SELECT DISTINCT T1.service_type_code FROM services AS T1 JOIN organizations AS T2 ON T1.organization_id  =  T2.organization_id WHERE T2.organization_details  =  'Denesik and Sons Party'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 services has each resident requested? List the resident id, details, and the count in descending order of the count.
SQL: SELECT T1.resident_id ,  T1.other_details ,  count(*) FROM Residents AS T1 JOIN Residents_Services AS T2 ON T1.resident_id  =  T2.resident_id GROUP BY T1.resident_id ORDER BY count(*) DESC
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What is the maximum number that a certain service is provided? List the service id, details and number.
SQL: SELECT T1.service_id ,  T1.service_details ,  count(*) FROM Services AS T1 JOIN Residents_Services AS T2 ON T1.service_id  =  T2.service_id GROUP BY T1.service_id ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 id and type of each thing, and the details of the organization that owns it.
SQL: SELECT T1.thing_id ,  T1.type_of_Thing_Code ,  T2.organization_details FROM Things AS T1 JOIN Organizations AS T2 ON T1.organization_id  =  T2.organization_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What are the id and details of the customers who have at least 3 events?
SQL: SELECT T1.customer_id ,  T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id  =  T2.customer_id GROUP BY T1.customer_id HAVING count(*)  >=  3
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What is each customer's move in date, and the corresponding customer id and details?
SQL: SELECT T2.date_moved_in ,  T1.customer_id ,  T1.customer_details FROM Customers AS T1 JOIN Customer_Events AS T2 ON T1.customer_id  =  T2.customer_id
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: Which events have the number of notes between one and three? List the event id and the property id.
SQL: SELECT T1.Customer_Event_ID  ,  T1.property_id FROM Customer_Events AS T1 JOIN Customer_Event_Notes AS T2 ON T1.Customer_Event_ID  =  T2.Customer_Event_ID GROUP BY T1.customer_event_id HAVING count(*) BETWEEN 1 AND 3
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What are the distinct id and type of the thing that has the status 'Close' or has a status record before the date '2017-06-19 02:59:21'
SQL: SELECT DISTINCT T2.thing_id ,  T2.Type_of_Thing_Code FROM Timed_Status_of_Things AS T1 JOIN Things AS T2 ON T1.thing_id  =  T2.thing_id WHERE T1.Status_of_Thing_Code  =  'Close' OR T1.Date_and_Date  <  '2017-06-19 02:59:21'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 distinct locations have the things with service detail 'Unsatisfied' been located in?
SQL: SELECT count(DISTINCT T2.Location_Code) FROM Things AS T1 JOIN Timed_Locations_of_Things AS T2 ON T1.thing_id  =  T2.thing_id WHERE T1.service_details  =  'Unsatisfied'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 different status codes of things are there?
SQL: SELECT count(DISTINCT Status_of_Thing_Code) FROM Timed_Status_of_Things
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: Which organizations are not a parent organization of others? List the organization id.
SQL: SELECT organization_id FROM organizations EXCEPT SELECT parent_organization_id FROM organizations
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: When is the last day any resident moved in?
SQL: SELECT max(date_moved_in) FROM Residents
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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: What are the resident details containing the substring 'Miss'?
SQL: SELECT other_details FROM Residents WHERE other_details LIKE '%Miss%'
-- Language PostgreSQL
        -- Tables: 
             -- Table: customers 
columns : [['customer id', 'number'], ['customer details', 'text']]

 -- Table: properties 
columns : [['property id', 'number'], ['property type code', 'text'], ['property address', 'text'], ['other details', 'text']]

 -- Table: residents 
columns : [['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time'], ['date moved out', 'time'], ['other details', 'text']]

 -- Table: organizations 
columns : [['organization id', 'number'], ['parent organization id', 'number'], ['organization details', 'text']]

 -- Table: services 
columns : [['service id', 'number'], ['organization id', 'number'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: residents services 
columns : [['resident id', 'number'], ['service id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['date requested', 'time'], ['date provided', 'time'], ['other details', 'text']]

 -- Table: things 
columns : [['thing id', 'number'], ['organization id', 'number'], ['type of thing code', 'text'], ['service type code', 'text'], ['service details', 'text']]

 -- Table: customer events 
columns : [['customer event id', 'number'], ['customer id', 'number'], ['date moved in', 'time'], ['property id', 'number'], ['resident id', 'number'], ['thing id', 'number']]

 -- Table: customer event notes 
columns : [['customer event note id', 'number'], ['customer event id', 'number'], ['service type code', 'text'], ['resident id', 'number'], ['property id', 'number'], ['date moved in', 'time']]

 -- Table: timed status of things 
columns : [['thing id', 'number'], ['date and date', 'time'], ['status of thing code', 'text']]

 -- Table: timed locations of things 
columns : [['thing id', 'number'], ['date and time', 'time'], ['location code', '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 customer event id and the corresponding move in date and property id.
SQL: SELECT customer_event_id ,  date_moved_in ,  property_id FROM customer_events