sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: document types 
columns : [['document type code', 'text'], ['document description', 'text']]

 -- Table: documents 
columns : [['document id', 'number'], ['document type code', 'text'], ['grant id', 'number'], ['sent date', 'time'], ['response received date', 'time'], ['other details', 'text']]

 -- Table: grants 
columns : [['grant id', 'number'], ['organisation id', 'number'], ['grant amount', 'number'], ['grant start date', 'time'], ['grant end date', 'time'], ['other details', 'text']]

 -- Table: organisation types 
columns : [['organisation type', 'text'], ['organisation type description', 'text']]

 -- Table: organisations 
columns : [['organisation id', 'number'], ['organisation type', 'text'], ['organisation details', 'text']]

 -- Table: project outcomes 
columns : [['project id', 'number'], ['outcome code', 'text'], ['outcome details', 'text']]

 -- Table: project staff 
columns : [['staff id', 'number'], ['project id', 'number'], ['role code', 'text'], ['date from', 'time'], ['date to', 'time'], ['other details', 'text']]

 -- Table: projects 
columns : [['project id', 'number'], ['organisation id', 'number'], ['project details', 'text']]

 -- Table: research outcomes 
columns : [['outcome code', 'text'], ['outcome description', 'text']]

 -- Table: research staff 
columns : [['staff id', 'number'], ['employer organisation id', 'number'], ['staff details', 'text']]

 -- Table: staff roles 
columns : [['role code', 'text'], ['role description', 'text']]

 -- Table: tasks 
columns : [['task id', 'number'], ['project id', 'number'], ['task details', 'text'], ['eg agree objectives', '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 description of the outcomes for all projects.
SQL: SELECT T1.outcome_description FROM Research_outcomes AS T1 JOIN Project_outcomes AS T2 ON T1.outcome_code  =  T2.outcome_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: document types 
columns : [['document type code', 'text'], ['document description', 'text']]

 -- Table: documents 
columns : [['document id', 'number'], ['document type code', 'text'], ['grant id', 'number'], ['sent date', 'time'], ['response received date', 'time'], ['other details', 'text']]

 -- Table: grants 
columns : [['grant id', 'number'], ['organisation id', 'number'], ['grant amount', 'number'], ['grant start date', 'time'], ['grant end date', 'time'], ['other details', 'text']]

 -- Table: organisation types 
columns : [['organisation type', 'text'], ['organisation type description', 'text']]

 -- Table: organisations 
columns : [['organisation id', 'number'], ['organisation type', 'text'], ['organisation details', 'text']]

 -- Table: project outcomes 
columns : [['project id', 'number'], ['outcome code', 'text'], ['outcome details', 'text']]

 -- Table: project staff 
columns : [['staff id', 'number'], ['project id', 'number'], ['role code', 'text'], ['date from', 'time'], ['date to', 'time'], ['other details', 'text']]

 -- Table: projects 
columns : [['project id', 'number'], ['organisation id', 'number'], ['project details', 'text']]

 -- Table: research outcomes 
columns : [['outcome code', 'text'], ['outcome description', 'text']]

 -- Table: research staff 
columns : [['staff id', 'number'], ['employer organisation id', 'number'], ['staff details', 'text']]

 -- Table: staff roles 
columns : [['role code', 'text'], ['role description', 'text']]

 -- Table: tasks 
columns : [['task id', 'number'], ['project id', 'number'], ['task details', 'text'], ['eg agree objectives', '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 role is most common for the staff?
SQL: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: document types 
columns : [['document type code', 'text'], ['document description', 'text']]

 -- Table: documents 
columns : [['document id', 'number'], ['document type code', 'text'], ['grant id', 'number'], ['sent date', 'time'], ['response received date', 'time'], ['other details', 'text']]

 -- Table: grants 
columns : [['grant id', 'number'], ['organisation id', 'number'], ['grant amount', 'number'], ['grant start date', 'time'], ['grant end date', 'time'], ['other details', 'text']]

 -- Table: organisation types 
columns : [['organisation type', 'text'], ['organisation type description', 'text']]

 -- Table: organisations 
columns : [['organisation id', 'number'], ['organisation type', 'text'], ['organisation details', 'text']]

 -- Table: project outcomes 
columns : [['project id', 'number'], ['outcome code', 'text'], ['outcome details', 'text']]

 -- Table: project staff 
columns : [['staff id', 'number'], ['project id', 'number'], ['role code', 'text'], ['date from', 'time'], ['date to', 'time'], ['other details', 'text']]

 -- Table: projects 
columns : [['project id', 'number'], ['organisation id', 'number'], ['project details', 'text']]

 -- Table: research outcomes 
columns : [['outcome code', 'text'], ['outcome description', 'text']]

 -- Table: research staff 
columns : [['staff id', 'number'], ['employer organisation id', 'number'], ['staff details', 'text']]

 -- Table: staff roles 
columns : [['role code', 'text'], ['role description', 'text']]

 -- Table: tasks 
columns : [['task id', 'number'], ['project id', 'number'], ['task details', 'text'], ['eg agree objectives', '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 most common role for the staff?
SQL: SELECT role_code FROM Project_Staff GROUP BY role_code ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 friends does Dan have?
SQL: SELECT count(T2.friend) FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T1.name  =  'Dan'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 females does this network has?
SQL: SELECT count(*) FROM Person WHERE gender  =  'female'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 females are in the network?
SQL: SELECT count(*) FROM Person WHERE gender  =  'female'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age for all person?
SQL: SELECT avg(age) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age for all people in the table?
SQL: SELECT avg(age) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 different cities are they from?
SQL: SELECT count(DISTINCT city) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 different cities do people originate from?
SQL: SELECT count(DISTINCT city) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 type of jobs do they have?
SQL: SELECT count(DISTINCT job) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 different jobs are listed?
SQL: SELECT count(DISTINCT job) FROM Person
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who is the oldest person?
SQL: SELECT name FROM Person WHERE age  =  (SELECT max(age) FROM person)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person who is the oldest?
SQL: SELECT name FROM Person WHERE age  =  (SELECT max(age) FROM person)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who is the oldest person whose job is student?
SQL: SELECT name FROM Person WHERE job  =  'student' AND age  =  (SELECT max(age) FROM person WHERE job  =  'student' )
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 oldest student?
SQL: SELECT name FROM Person WHERE job  =  'student' AND age  =  (SELECT max(age) FROM person WHERE job  =  'student' )
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who is the youngest male?
SQL: SELECT name FROM Person WHERE gender  =  'male' AND age  =  (SELECT min(age) FROM person WHERE gender  =  'male' )
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 youngest male?
SQL: SELECT name FROM Person WHERE gender  =  'male' AND age  =  (SELECT min(age) FROM person WHERE gender  =  'male' )
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 doctor named Zach?
SQL: SELECT age FROM Person WHERE job  =  'doctor' AND name  =  'Zach'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 age of the doctor named Zach?
SQL: SELECT age FROM Person WHERE job  =  'doctor' AND name  =  'Zach'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who is the person whose age is below 30?
SQL: SELECT name FROM Person WHERE age  <  30
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person whose age is below 30?
SQL: SELECT name FROM Person WHERE age  <  30
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people whose age is greater 30 and job is engineer?
SQL: SELECT count(*) FROM Person WHERE age  >  30 AND job  =  'engineer'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 engineers are older than 30?
SQL: SELECT count(*) FROM Person WHERE age  >  30 AND job  =  'engineer'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age for each gender?
SQL: SELECT avg(age) ,  gender FROM Person GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 each gender, on average?
SQL: SELECT avg(age) ,  gender FROM Person GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age for different job title?
SQL: SELECT avg(age) ,  job FROM Person GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average person for each job?
SQL: SELECT avg(age) ,  job FROM Person GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age of male for different job title?
SQL: SELECT avg(age) ,  job FROM Person WHERE gender  =  'male' GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 average age for a male in each job?
SQL: SELECT avg(age) ,  job FROM Person WHERE gender  =  'male' GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 minimum age for different job title?
SQL: SELECT min(age) ,  job FROM Person GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person for each job?
SQL: SELECT min(age) ,  job FROM Person GROUP BY job
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 number of people who is under 40 for each gender.
SQL: SELECT count(*) ,  gender FROM Person WHERE age  <  40 GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people are under 40 for each gender?
SQL: SELECT count(*) ,  gender FROM Person WHERE age  <  40 GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people whose age is greater than any engineer sorted by their age.
SQL: SELECT name FROM Person WHERE age  >  (SELECT min(age) FROM person WHERE job  =  'engineer') ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 all the people who are older than at least one engineer? Order them by age.
SQL: SELECT name FROM Person WHERE age  >  (SELECT min(age) FROM person WHERE job  =  'engineer') ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 number of people whose age is greater than all engineers.
SQL: SELECT count(*) FROM Person WHERE age  >  (SELECT max(age) FROM person WHERE job  =  'engineer')
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people are older than every engineer?
SQL: SELECT count(*) FROM Person WHERE age  >  (SELECT max(age) FROM person WHERE job  =  'engineer')
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 name, job title of all people ordered by their names.
SQL: SELECT name ,  job FROM Person ORDER BY name
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 and job titles of every person ordered alphabetically by name?
SQL: SELECT name ,  job FROM Person ORDER BY name
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person sorted in the descending order using age.
SQL: SELECT name FROM Person ORDER BY age DESC
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 everybody sorted by age in descending order?
SQL: SELECT name FROM Person ORDER BY age DESC
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 all males in order of their age.
SQL: SELECT name FROM Person WHERE gender  =  'male' ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 every male? Order the results by age.
SQL: SELECT name FROM Person WHERE gender  =  'male' ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person who is a friend of both Dan and Alice.
SQL: SELECT T1.name ,  T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Dan' INTERSECT SELECT T1.name ,   T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Alice'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 and ages of every person who is a friend of both Dan and Alice?
SQL: SELECT T1.name ,  T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Dan' INTERSECT SELECT T1.name ,   T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Alice'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person who is a friend of Dan or Alice.
SQL: SELECT DISTINCT T1.name ,  T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Dan' OR T2.friend  =  'Alice'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 different names and ages of every friend of either Dan or alice?
SQL: SELECT DISTINCT T1.name ,  T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Dan' OR T2.friend  =  'Alice'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 the person who has friends with age above 40 and under age 30?
SQL: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  >  40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  <  30)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 every person who has a friend over 40 and under 30?
SQL: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  >  40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  <  30)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 the person who has friends with age above 40 but not under age 30?
SQL: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  >  40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  <  30)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people who are older 40 but no friends under age 30?
SQL: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  >  40) EXCEPT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age  <  30)
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 the person who has no student friends.
SQL: SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.friend WHERE T1.job  =  'student'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 people who have no friends who are students?
SQL: SELECT name FROM person EXCEPT SELECT T2.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.friend WHERE T1.job  =  'student'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 person who has exactly one friend.
SQL: SELECT name FROM PersonFriend GROUP BY name HAVING count(*)  =  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 everybody who has exactly one friend?
SQL: SELECT name FROM PersonFriend GROUP BY name HAVING count(*)  =  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who are the friends of Bob?
SQL: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T1.name  =  'Bob'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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: Who are Bob's friends?
SQL: SELECT T2.friend FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T1.name  =  'Bob'
-- Language PostgreSQL
        -- Tables: 
             -- Table: person 
columns : [['name', 'text'], ['age', 'number'], ['city', 'text'], ['gender', 'text'], ['job', 'text']]

 -- Table: person friend 
columns : [['name', 'text'], ['friend', 'text'], ['year', '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 persons who are friends with Bob.
SQL: SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name  =  T2.name WHERE T2.friend  =  'Bob'