sert121/SpiderSQL huggingface dataset:
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 genders are there in the dorms?
SQL: SELECT count(DISTINCT gender) FROM dorm
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 capacity and gender type of the dorm whose name has substring ‘Donor’.
SQL: SELECT student_capacity ,  gender FROM dorm WHERE dorm_name LIKE '%Donor%'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 student capacity and type of gender for the dorm whose name as the phrase Donor in it?
SQL: SELECT student_capacity ,  gender FROM dorm WHERE dorm_name LIKE '%Donor%'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 gender type of the dorms whose capacity is greater than 300 or less than 100.
SQL: SELECT dorm_name ,  gender FROM dorm WHERE student_capacity  >  300 OR student_capacity  <  100
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 types of the dorms that have a capacity greater than 300 or less than 100?
SQL: SELECT dorm_name ,  gender FROM dorm WHERE student_capacity  >  300 OR student_capacity  <  100
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 numbers of different majors and cities.
SQL: SELECT count(DISTINCT major) ,  count(DISTINCT city_code) FROM student
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 majors are there and how many different city codes are there for each student?
SQL: SELECT count(DISTINCT major) ,  count(DISTINCT city_code) FROM student
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorms which have both TV Lounge and Study Room as amenities.
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorm with both a TV Lounge and Study Room listed as amenities?
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' INTERSECT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorms which have TV Lounge but no Study Room as amenity.
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 each dorm that has a TV Lounge but no study rooms?
SQL: SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'TV Lounge' EXCEPT SELECT T1.dorm_name FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid  =  T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid  =  T3.amenid WHERE T3.amenity_name  =  'Study Room'
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 last name of students who is either female (sex is F) and living in the city of code BAL or male (sex is M) and in age of below 20.
SQL: SELECT lname FROM student WHERE sex  =  'F' AND city_code  =  'BAL' UNION SELECT lname FROM student WHERE sex  =  'M' AND age  <  20
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 last name of every student who is either female or living in a city with the code BAL or male and under 20?
SQL: SELECT lname FROM student WHERE sex  =  'F' AND city_code  =  'BAL' UNION SELECT lname FROM student WHERE sex  =  'M' AND age  <  20
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorm with the largest capacity.
SQL: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorm with the largest capacity?
SQL: SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 in alphabetic order all different amenities.
SQL: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorm amenity names in alphabetical order?
SQL: SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 code of city where most of students are living in.
SQL: SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 code of the city with the most students?
SQL: SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last name of students whose age is younger than the average age.
SQL: SELECT fname ,  lname FROM student WHERE age  <  (SELECT avg(age) FROM student)
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last name of all students who are younger than average?
SQL: SELECT fname ,  lname FROM student WHERE age  <  (SELECT avg(age) FROM student)
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last name of students who are not living in the city with code HKG, and sorted the results by their ages.
SQL: SELECT fname ,  lname FROM student WHERE city_code != 'HKG' ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last names of all students who are not living in the city HKG and order the results by age?
SQL: SELECT fname ,  lname FROM student WHERE city_code != 'HKG' ORDER BY age
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid  =  T1.amenid JOIN dorm AS T3 ON T2.dormid  =  T3.dormid WHERE T3.dorm_name  =  'Anonymous Donor Hall' ORDER BY T1.amenity_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 amenities in alphabetical order that Anonymous Donor Hall has?
SQL: SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T2.amenid  =  T1.amenid JOIN dorm AS T3 ON T2.dormid  =  T3.dormid WHERE T3.dorm_name  =  'Anonymous Donor Hall' ORDER BY T1.amenity_name
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorms and total capacity for each gender.
SQL: SELECT count(*) ,  sum(student_capacity) ,  gender FROM dorm GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 dorms are there and what is the total capacity for each gender?
SQL: SELECT count(*) ,  sum(student_capacity) ,  gender FROM dorm GROUP BY gender
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 average and oldest age for students with different sex.
SQL: SELECT avg(age) ,  max(age) ,  sex FROM student GROUP BY sex
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 and oldest age for each gender of student?
SQL: SELECT avg(age) ,  max(age) ,  sex FROM student GROUP BY sex
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students in each major.
SQL: SELECT count(*) ,  major FROM student GROUP BY major
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students are there in each major?
SQL: SELECT count(*) ,  major FROM student GROUP BY major
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 and average age of students living in each city.
SQL: SELECT count(*) ,  avg(age) ,  city_code FROM student GROUP BY city_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students live in each city and what are their average ages?
SQL: SELECT count(*) ,  avg(age) ,  city_code FROM student GROUP BY city_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 average age and number of male students (with sex M) from each city.
SQL: SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 and how many male students are there in each city?
SQL: SELECT count(*) ,  avg(age) ,  city_code FROM student WHERE sex  =  'M' GROUP BY city_code
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students for the cities where have more than one student.
SQL: SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students are from each city, and which cities have more than one cities?
SQL: SELECT count(*) ,  city_code FROM student GROUP BY city_code HAVING count(*)  >  1
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last name of students who are not in the largest major.
SQL: SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 first and last name of the students who are not in the largest major?
SQL: SELECT fname ,  lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students whose age is older than the average age for each gender.
SQL: SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex
-- Language PostgreSQL
        -- Tables: 
             -- Table: student 
columns : [['student id', 'number'], ['last name', 'text'], ['first name', 'text'], ['age', 'number'], ['sex', 'text'], ['major', 'number'], ['advisor', 'number'], ['city code', 'text']]

 -- Table: dorm 
columns : [['dorm id', 'number'], ['dorm name', 'text'], ['student capacity', 'number'], ['gender', 'text']]

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

 -- Table: has amenity 
columns : [['dorm id', 'number'], ['amenity id', 'number']]

 -- Table: lives in 
columns : [['student id', 'number'], ['dorm id', 'number'], ['room number', '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 students are older than average for each gender?
SQL: SELECT count(*) ,  sex FROM student WHERE age  >  (SELECT avg(age) FROM student) GROUP BY sex