sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students live in each city?
SQL: SELECT city_code ,  count(*) FROM Student GROUP BY city_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Show all advisors and corresponding number of students.
SQL: SELECT advisor ,  count(*) FROM Student GROUP BY advisor
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students does each advisor have?
SQL: SELECT advisor ,  count(*) FROM Student GROUP BY advisor
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 advisor has most number of students?
SQL: SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Give the advisor with the most students.
SQL: SELECT advisor FROM Student GROUP BY advisor ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students have cat allergies?
SQL: SELECT count(*) FROM Has_allergy WHERE Allergy  =  "Cat"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students are affected by cat allergies?
SQL: SELECT count(*) FROM Has_allergy WHERE Allergy  =  "Cat"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Show all student IDs who have at least two allergies.
SQL: SELECT StuID FROM Has_allergy GROUP BY StuID HAVING count(*)  >=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students ids of students who have more than one allergy?
SQL: SELECT StuID FROM Has_allergy GROUP BY StuID HAVING count(*)  >=  2
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 student ids of students who don't have any allergies?
SQL: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students are unaffected by allergies?
SQL: SELECT StuID FROM Student EXCEPT SELECT StuID FROM Has_allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 female students have milk or egg allergies?
SQL: SELECT count(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID  =  T2.StuID WHERE T2.sex  =  "F" AND T1.allergy  =  "Milk" OR T1.allergy  =  "Eggs"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students who are female are allergic to milk or eggs?
SQL: SELECT count(*) FROM has_allergy AS T1 JOIN Student AS T2 ON T1.StuID  =  T2.StuID WHERE T2.sex  =  "F" AND T1.allergy  =  "Milk" OR T1.allergy  =  "Eggs"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students have a food allergy?
SQL: SELECT count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy WHERE T2.allergytype  =  "food"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students are affected by food related allergies?
SQL: SELECT count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy WHERE T2.allergytype  =  "food"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 allergy has most number of students affected?
SQL: SELECT Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 allergy is the most common?
SQL: SELECT Allergy FROM Has_allergy GROUP BY Allergy ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Show all allergies with number of students affected.
SQL: SELECT Allergy ,  count(*) FROM Has_allergy GROUP BY Allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students have each different allergy?
SQL: SELECT Allergy ,  count(*) FROM Has_allergy GROUP BY Allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Show all allergy type with number of students affected.
SQL: SELECT T2.allergytype ,  count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy GROUP BY T2.allergytype
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students are affected by each allergy type?
SQL: SELECT T2.allergytype ,  count(*) FROM Has_allergy AS T1 JOIN Allergy_type AS T2 ON T1.allergy  =  T2.allergy GROUP BY T2.allergytype
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the last name and age of the student who has allergy to both milk and cat.
SQL: SELECT lname ,  age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 last names and ages of the students who are allergic to milk and cat?
SQL: SELECT lname ,  age FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" INTERSECT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 allergies and their types that the student with first name Lisa has? And order the result by name of allergies.
SQL: SELECT T1.Allergy ,  T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy  =  T2.Allergy JOIN Student AS T3 ON T3.StuID  =  T2.StuID WHERE T3.Fname  =  "Lisa" ORDER BY T1.Allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 allergies the girl named Lisa has? And what are the types of them? Order the result by allergy names.
SQL: SELECT T1.Allergy ,  T1.AllergyType FROM Allergy_type AS T1 JOIN Has_allergy AS T2 ON T1.Allergy  =  T2.Allergy JOIN Student AS T3 ON T3.StuID  =  T2.StuID WHERE T3.Fname  =  "Lisa" ORDER BY T1.Allergy
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the first name and gender of the student who has allergy to milk but not cat.
SQL: SELECT fname ,  sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 first name and gender of the students who have allergy to milk but can put up with cats?
SQL: SELECT fname ,  sex FROM Student WHERE StuID IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Milk" EXCEPT SELECT StuID FROM Has_allergy WHERE Allergy  =  "Cat")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the average age of the students who have allergies with food and animal types.
SQL: SELECT avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "animal")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 old are the students with allergies to food and animal types on average?
SQL: SELECT avg(age) FROM Student WHERE StuID IN ( SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" INTERSECT SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "animal")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 first and last name of the students who do not have any food type allergy.
SQL: SELECT fname ,  lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 full name of each student who is not allergic to any type of food.
SQL: SELECT fname ,  lname FROM Student WHERE StuID NOT IN (SELECT T1.StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the number of male (sex is 'M') students who have some food type allery.
SQL: SELECT count(*) FROM Student WHERE sex  =  "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 male students (sex is 'M') are allergic to any type of food?
SQL: SELECT count(*) FROM Student WHERE sex  =  "M" AND StuID IN (SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the different first names and cities of the students who have allergy to milk or cat.
SQL: SELECT DISTINCT T1.fname ,  T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid  =  T2.stuid WHERE T2.Allergy  =  "Milk" OR T2.Allergy  =  "Cat"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 first names and cities of the students who have allergy either to milk or to cat?
SQL: SELECT DISTINCT T1.fname ,  T1.city_code FROM Student AS T1 JOIN Has_Allergy AS T2 ON T1.stuid  =  T2.stuid WHERE T2.Allergy  =  "Milk" OR T2.Allergy  =  "Cat"
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the number of students who are older than 18 and do not have allergy to either food or animal.
SQL: SELECT count(*) FROM Student WHERE age  >  18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" OR T2.allergytype  =  "animal")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 students are over 18 and do not have allergy to food type or animal type?
SQL: SELECT count(*) FROM Student WHERE age  >  18 AND StuID NOT IN ( SELECT StuID FROM Has_allergy AS T1 JOIN Allergy_Type AS T2 ON T1.Allergy  =  T2.Allergy WHERE T2.allergytype  =  "food" OR T2.allergytype  =  "animal")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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: Find the first name and major of the students who are not allegry to soy.
SQL: SELECT fname ,  major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Soy")
-- Language PostgreSQL
        -- Tables: 
             -- Table: allergy type 
columns : [['allergy name', 'text'], ['allergy type', 'text']]

 -- Table: has allergy 
columns : [['stuid', 'number'], ['allergy', 'text']]

 -- Table: student 
columns : [['stuid', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city 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 first name and major of the students who are able to consume soy?
SQL: SELECT fname ,  major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy  =  "Soy")
-- Language PostgreSQL
        -- Tables: 
             -- Table: sqlite sequence 
columns : [['name', 'number'], ['seq', 'text']]

 -- Table: artists 
columns : [['id', 'text'], ['name', 'text']]

 -- Table: albums 
columns : [['id', 'number'], ['title', 'text'], ['artist id', 'number']]

 -- Table: employees 
columns : [['id', 'number'], ['last name', 'text'], ['first name', 'text'], ['title', 'text'], ['reports to', 'number'], ['birth date', 'time'], ['hire date', 'time'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text']]

 -- Table: customers 
columns : [['id', 'number'], ['first name', 'text'], ['last name', 'text'], ['company', 'text'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text'], ['support rep id', 'number']]

 -- Table: genres 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: invoices 
columns : [['id', 'number'], ['customer id', 'number'], ['invoice date', 'time'], ['billing address', 'text'], ['billing city', 'text'], ['billing state', 'text'], ['billing country', 'text'], ['billing postal code', 'text'], ['total', 'number']]

 -- Table: media types 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: tracks 
columns : [['id', 'number'], ['name', 'text'], ['album id', 'number'], ['media type id', 'number'], ['genre id', 'number'], ['composer', 'text'], ['milliseconds', 'number'], ['bytes', 'number'], ['unit price', 'number']]

 -- Table: invoice lines 
columns : [['id', 'number'], ['invoice id', 'number'], ['track id', 'number'], ['unit price', 'number'], ['quantity', 'number']]

 -- Table: playlists 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: playlist tracks 
columns : [['playlist id', 'number'], ['track 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: A list of the top 5 countries by number of invoices. List country name and number of invoices.
SQL: SELECT billing_country ,  COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5;
-- Language PostgreSQL
        -- Tables: 
             -- Table: sqlite sequence 
columns : [['name', 'number'], ['seq', 'text']]

 -- Table: artists 
columns : [['id', 'text'], ['name', 'text']]

 -- Table: albums 
columns : [['id', 'number'], ['title', 'text'], ['artist id', 'number']]

 -- Table: employees 
columns : [['id', 'number'], ['last name', 'text'], ['first name', 'text'], ['title', 'text'], ['reports to', 'number'], ['birth date', 'time'], ['hire date', 'time'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text']]

 -- Table: customers 
columns : [['id', 'number'], ['first name', 'text'], ['last name', 'text'], ['company', 'text'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text'], ['support rep id', 'number']]

 -- Table: genres 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: invoices 
columns : [['id', 'number'], ['customer id', 'number'], ['invoice date', 'time'], ['billing address', 'text'], ['billing city', 'text'], ['billing state', 'text'], ['billing country', 'text'], ['billing postal code', 'text'], ['total', 'number']]

 -- Table: media types 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: tracks 
columns : [['id', 'number'], ['name', 'text'], ['album id', 'number'], ['media type id', 'number'], ['genre id', 'number'], ['composer', 'text'], ['milliseconds', 'number'], ['bytes', 'number'], ['unit price', 'number']]

 -- Table: invoice lines 
columns : [['id', 'number'], ['invoice id', 'number'], ['track id', 'number'], ['unit price', 'number'], ['quantity', 'number']]

 -- Table: playlists 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: playlist tracks 
columns : [['playlist id', 'number'], ['track 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 top 5 countries by number of invoices and how many do they have?
SQL: SELECT billing_country ,  COUNT(*) FROM invoices GROUP BY billing_country ORDER BY count(*) DESC LIMIT 5;
-- Language PostgreSQL
        -- Tables: 
             -- Table: sqlite sequence 
columns : [['name', 'number'], ['seq', 'text']]

 -- Table: artists 
columns : [['id', 'text'], ['name', 'text']]

 -- Table: albums 
columns : [['id', 'number'], ['title', 'text'], ['artist id', 'number']]

 -- Table: employees 
columns : [['id', 'number'], ['last name', 'text'], ['first name', 'text'], ['title', 'text'], ['reports to', 'number'], ['birth date', 'time'], ['hire date', 'time'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text']]

 -- Table: customers 
columns : [['id', 'number'], ['first name', 'text'], ['last name', 'text'], ['company', 'text'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text'], ['support rep id', 'number']]

 -- Table: genres 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: invoices 
columns : [['id', 'number'], ['customer id', 'number'], ['invoice date', 'time'], ['billing address', 'text'], ['billing city', 'text'], ['billing state', 'text'], ['billing country', 'text'], ['billing postal code', 'text'], ['total', 'number']]

 -- Table: media types 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: tracks 
columns : [['id', 'number'], ['name', 'text'], ['album id', 'number'], ['media type id', 'number'], ['genre id', 'number'], ['composer', 'text'], ['milliseconds', 'number'], ['bytes', 'number'], ['unit price', 'number']]

 -- Table: invoice lines 
columns : [['id', 'number'], ['invoice id', 'number'], ['track id', 'number'], ['unit price', 'number'], ['quantity', 'number']]

 -- Table: playlists 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: playlist tracks 
columns : [['playlist id', 'number'], ['track 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: A list of the top 8 countries by gross/total invoice size. List country name and gross invoice size.
SQL: SELECT billing_country ,  SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8;
-- Language PostgreSQL
        -- Tables: 
             -- Table: sqlite sequence 
columns : [['name', 'number'], ['seq', 'text']]

 -- Table: artists 
columns : [['id', 'text'], ['name', 'text']]

 -- Table: albums 
columns : [['id', 'number'], ['title', 'text'], ['artist id', 'number']]

 -- Table: employees 
columns : [['id', 'number'], ['last name', 'text'], ['first name', 'text'], ['title', 'text'], ['reports to', 'number'], ['birth date', 'time'], ['hire date', 'time'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text']]

 -- Table: customers 
columns : [['id', 'number'], ['first name', 'text'], ['last name', 'text'], ['company', 'text'], ['address', 'text'], ['city', 'text'], ['state', 'text'], ['country', 'text'], ['postal code', 'text'], ['phone', 'text'], ['fax', 'text'], ['email', 'text'], ['support rep id', 'number']]

 -- Table: genres 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: invoices 
columns : [['id', 'number'], ['customer id', 'number'], ['invoice date', 'time'], ['billing address', 'text'], ['billing city', 'text'], ['billing state', 'text'], ['billing country', 'text'], ['billing postal code', 'text'], ['total', 'number']]

 -- Table: media types 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: tracks 
columns : [['id', 'number'], ['name', 'text'], ['album id', 'number'], ['media type id', 'number'], ['genre id', 'number'], ['composer', 'text'], ['milliseconds', 'number'], ['bytes', 'number'], ['unit price', 'number']]

 -- Table: invoice lines 
columns : [['id', 'number'], ['invoice id', 'number'], ['track id', 'number'], ['unit price', 'number'], ['quantity', 'number']]

 -- Table: playlists 
columns : [['id', 'number'], ['name', 'text']]

 -- Table: playlist tracks 
columns : [['playlist id', 'number'], ['track 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 top 8 countries by total invoice size and what are those sizes?
SQL: SELECT billing_country ,  SUM(total) FROM invoices GROUP BY billing_country ORDER BY SUM(total) DESC LIMIT 8;