brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
Find the numbers of different majors and cities.
-- 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. Translate `Find the numbers of different majors and cities.` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student
How many different majors are there and how many different city codes are there for each 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. Translate `How many different majors are there and how many different city codes are there for each student?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT major) , count(DISTINCT city_code) FROM student
Find the name of dorms which have both TV Lounge and Study Room as amenities.
-- 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. Translate `Find the name of dorms which have both TV Lounge and Study Room as amenities.` to a syntactically-correct PostgreSQL query.
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'
What is the name of the dorm with both a TV Lounge and Study Room listed as amenities?
-- 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. Translate `What is the name of the dorm with both a TV Lounge and Study Room listed as amenities?` to a syntactically-correct PostgreSQL query.
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'
Find the name of dorms which have TV Lounge but no Study Room as amenity.
-- 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. Translate `Find the name of dorms which have TV Lounge but no Study Room as amenity.` to a syntactically-correct PostgreSQL query.
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'
What is the name of each dorm that has a TV Lounge but no study rooms?
-- 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. Translate `What is the name of each dorm that has a TV Lounge but no study rooms?` to a syntactically-correct PostgreSQL query.
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'
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.
-- 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. Translate `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.` to a syntactically-correct PostgreSQL query.
SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
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?
-- 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. Translate `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?` to a syntactically-correct PostgreSQL query.
SELECT lname FROM student WHERE sex = 'F' AND city_code = 'BAL' UNION SELECT lname FROM student WHERE sex = 'M' AND age < 20
Find the name of the dorm with the largest capacity.
-- 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. Translate `Find the name of the dorm with the largest capacity.` to a syntactically-correct PostgreSQL query.
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
What are the names of the dorm with the largest capacity?
-- 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. Translate `What are the names of the dorm with the largest capacity?` to a syntactically-correct PostgreSQL query.
SELECT dorm_name FROM dorm ORDER BY student_capacity DESC LIMIT 1
List in alphabetic order all different amenities.
-- 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. Translate `List in alphabetic order all different amenities.` to a syntactically-correct PostgreSQL query.
SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
What are the different dorm amenity names in alphabetical order?
-- 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. Translate `What are the different dorm amenity names in alphabetical order?` to a syntactically-correct PostgreSQL query.
SELECT amenity_name FROM dorm_amenity ORDER BY amenity_name
Find the code of city where most of students are living in.
-- 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. Translate `Find the code of city where most of students are living in.` to a syntactically-correct PostgreSQL query.
SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
What is the code of the city with the most students?
-- 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. Translate `What is the code of the city with the most students?` to a syntactically-correct PostgreSQL query.
SELECT city_code FROM student GROUP BY city_code ORDER BY count(*) DESC LIMIT 1
Find the first and last name of students whose age is younger than the average 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. Translate `Find the first and last name of students whose age is younger than the average age.` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student)
What is the first and last name of all students who are younger than average?
-- 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. Translate `What is the first and last name of all students who are younger than average?` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE age < (SELECT avg(age) FROM student)
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.
-- 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. Translate `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.` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age
What are the first and last names of all students who are not living in the city HKG and order the results 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. Translate `What are the first and last names of all students who are not living in the city HKG and order the results by age?` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE city_code != 'HKG' ORDER BY age
List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.
-- 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. Translate `List name of all amenities which Anonymous Donor Hall has, and sort the results in alphabetic order.` to a syntactically-correct PostgreSQL query.
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
What are the amenities in alphabetical order that Anonymous Donor Hall has?
-- 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. Translate `What are the amenities in alphabetical order that Anonymous Donor Hall has?` to a syntactically-correct PostgreSQL query.
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
Find the number of dorms and total capacity for each 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. Translate `Find the number of dorms and total capacity for each gender.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender
How many dorms are there and what is the total capacity for each 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. Translate `How many dorms are there and what is the total capacity for each gender?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , sum(student_capacity) , gender FROM dorm GROUP BY gender
Find the average and oldest age for students with different 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. Translate `Find the average and oldest age for students with different sex.` to a syntactically-correct PostgreSQL query.
SELECT avg(age) , max(age) , sex FROM student GROUP BY sex
What is the average and oldest age for each gender of 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. Translate `What is the average and oldest age for each gender of student?` to a syntactically-correct PostgreSQL query.
SELECT avg(age) , max(age) , sex FROM student GROUP BY sex
Find the number of students in each 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. Translate `Find the number of students in each major.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , major FROM student GROUP BY major
How many students are there in each 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. Translate `How many students are there in each major?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , major FROM student GROUP BY major
Find the number and average age of students living in each city.
-- 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. Translate `Find the number and average age of students living in each city.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
How many students live in each city and what are their average ages?
-- 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. Translate `How many students live in each city and what are their average ages?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , avg(age) , city_code FROM student GROUP BY city_code
Find the average age and number of male students (with sex M) from each city.
-- 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. Translate `Find the average age and number of male students (with sex M) from each city.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
What is the average age and how many male students are there in each city?
-- 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. Translate `What is the average age and how many male students are there in each city?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , avg(age) , city_code FROM student WHERE sex = 'M' GROUP BY city_code
Find the number of students for the cities where have more than one 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. Translate `Find the number of students for the cities where have more than one student.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
How many students are from each city, and which cities have more than one cities?
-- 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. Translate `How many students are from each city, and which cities have more than one cities?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , city_code FROM student GROUP BY city_code HAVING count(*) > 1
Find the first and last name of students who are not in the largest 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. Translate `Find the first and last name of students who are not in the largest major.` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
What is the first and last name of the students who are not in the largest 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. Translate `What is the first and last name of the students who are not in the largest major?` to a syntactically-correct PostgreSQL query.
SELECT fname , lname FROM student WHERE major != (SELECT major FROM student GROUP BY major ORDER BY count(*) DESC LIMIT 1)
Find the number of students whose age is older than the average age for each 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. Translate `Find the number of students whose age is older than the average age for each gender.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
How many students are older than average for each 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. Translate `How many students are older than average for each gender?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , sex FROM student WHERE age > (SELECT avg(age) FROM student) GROUP BY sex
Find the average age of students living in each dorm and the name of 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. Translate `Find the average age of students living in each dorm and the name of dorm.` to a syntactically-correct PostgreSQL query.
SELECT avg(T1.age) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
What is the average age for each dorm and what are the names of each 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. Translate `What is the average age for each dorm and what are the names of each dorm?` to a syntactically-correct PostgreSQL query.
SELECT avg(T1.age) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid GROUP BY T3.dorm_name
Find the number of amenities for each of the dorms that can accommodate more than 100 students.
-- 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. Translate `Find the number of amenities for each of the dorms that can accommodate more than 100 students.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
For each dorm, how many amenities does it have?
-- 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. Translate `For each dorm, how many amenities does it have?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T1.dormid FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid WHERE T1.student_capacity > 100 GROUP BY T1.dormid
Find the number of students who is older than 20 in each 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. Translate `Find the number of students who is older than 20 in each dorm.` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
How many students are older than 20 in each 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. Translate `How many students are older than 20 in each dorm?` to a syntactically-correct PostgreSQL query.
SELECT count(*) , T3.dorm_name FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T1.age > 20 GROUP BY T3.dorm_name
Find the first name of students who are living in the Smith Hall.
-- 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. Translate `Find the first name of students who are living in the Smith Hall.` to a syntactically-correct PostgreSQL query.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
What are the first names of all students in Smith Hall?
-- 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. Translate `What are the first names of all students in Smith Hall?` to a syntactically-correct PostgreSQL query.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall'
Find the average age of students who are living in the dorm with the largest capacity.
-- 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. Translate `Find the average age of students who are living in the dorm with the largest capacity.` to a syntactically-correct PostgreSQL query.
SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT max(student_capacity) FROM dorm)
What is the average age of students who are living in the dorm with the largest capacity?
-- 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. Translate `What is the average age of students who are living in the dorm with the largest capacity?` to a syntactically-correct PostgreSQL query.
SELECT avg(T1.age) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.student_capacity = (SELECT max(student_capacity) FROM dorm)
Find the total number of students living in the male dorm (with gender M).
-- 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. Translate `Find the total number of students living in the male dorm (with gender M).` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
What are the total number of students who are living in a male 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. Translate `What are the total number of students who are living in a male dorm?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.gender = 'M'
Find the number of female students (with F sex) living in Smith Hall
-- 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. Translate `Find the number of female students (with F sex) living in Smith Hall` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
How many female students live in Smith Hall?
-- 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. Translate `How many female students live in Smith Hall?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid JOIN dorm AS T3 ON T3.dormid = T2.dormid WHERE T3.dorm_name = 'Smith Hall' AND T1.sex = 'F'
Find the name of amenities Smith Hall dorm have.
-- 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. Translate `Find the name of amenities Smith Hall dorm have.` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 T1.dorm_name = 'Smith Hall'
What are the names of the amenities that Smith Hall has?
-- 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. Translate `What are the names of the amenities that Smith Hall has?` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 T1.dorm_name = 'Smith Hall'
Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.
-- 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. Translate `Find the name of amenities Smith Hall dorm have. ordered the results by amenity names.` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name
What amenities does Smith Hall have in alphabetical order?
-- 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. Translate `What amenities does Smith Hall have in alphabetical order?` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 T1.dorm_name = 'Smith Hall' ORDER BY T3.amenity_name
Find the name of amenity that is most common in all dorms.
-- 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. Translate `Find the name of amenity that is most common in all dorms.` to a syntactically-correct PostgreSQL query.
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
What is the most common amenity in the dorms?
-- 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. Translate `What is the most common amenity in the dorms?` to a syntactically-correct PostgreSQL query.
SELECT T1.amenity_name FROM dorm_amenity AS T1 JOIN has_amenity AS T2 ON T1.amenid = T2.amenid GROUP BY T2.amenid ORDER BY count(*) DESC LIMIT 1
Find the first name of students who are living in the dorm that has most number of amenities.
-- 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. Translate `Find the first name of students who are living in the dorm that has most number of amenities.` to a syntactically-correct PostgreSQL query.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
What are the first names of all students who live in the dorm with the most amenities?
-- 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. Translate `What are the first names of all students who live in the dorm with the most amenities?` to a syntactically-correct PostgreSQL query.
SELECT T1.fname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T2.dormid FROM dorm AS T3 JOIN has_amenity AS T4 ON T3.dormid = T4.dormid JOIN dorm_amenity AS T5 ON T4.amenid = T5.amenid GROUP BY T3.dormid ORDER BY count(*) DESC LIMIT 1)
Find the name and capacity of the dorm with least number of amenities.
-- 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. Translate `Find the name and capacity of the dorm with least number of amenities.` to a syntactically-correct PostgreSQL query.
SELECT T1.dorm_name , T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
What is the name and capacity of the dorm with the fewest amount of amenities?
-- 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. Translate `What is the name and capacity of the dorm with the fewest amount of amenities?` to a syntactically-correct PostgreSQL query.
SELECT T1.dorm_name , T1.student_capacity FROM dorm AS T1 JOIN has_amenity AS T2 ON T1.dormid = T2.dormid JOIN dorm_amenity AS T3 ON T2.amenid = T3.amenid GROUP BY T2.dormid ORDER BY count(*) LIMIT 1
Find the name of dorms that do not have amenity TV Lounge.
-- 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. Translate `Find the name of dorms that do not have amenity TV Lounge.` to a syntactically-correct PostgreSQL query.
SELECT dorm_name FROM dorm 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 = 'TV Lounge'
What are the names of the dorm that does not have a TV Lounge?
-- 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. Translate `What are the names of the dorm that does not have a TV Lounge?` to a syntactically-correct PostgreSQL query.
SELECT dorm_name FROM dorm 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 = 'TV Lounge'
Find the first and last name of students who are living in the dorms that have amenity TV Lounge.
-- 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. Translate `Find the first and last name of students who are living in the dorms that have amenity TV Lounge.` to a syntactically-correct PostgreSQL query.
SELECT T1.fname , T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
What are the first and last names of all students who are living in a dorm with a TV Lounge?
-- 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. Translate `What are the first and last names of all students who are living in a dorm with a TV Lounge?` to a syntactically-correct PostgreSQL query.
SELECT T1.fname , T1.lname FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.
-- 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. Translate `Find the first name and age of students who are living in the dorms that do not have amenity TV Lounge.` to a syntactically-correct PostgreSQL query.
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
What is the first name and age of every student who lives in a dorm with a TV Lounge?
-- 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. Translate `What is the first name and age of every student who lives in a dorm with a TV Lounge?` to a syntactically-correct PostgreSQL query.
SELECT T1.fname , T1.age FROM student AS T1 JOIN lives_in AS T2 ON T1.stuid = T2.stuid WHERE T2.dormid NOT IN (SELECT T3.dormid FROM has_amenity AS T3 JOIN dorm_amenity AS T4 ON T3.amenid = T4.amenid WHERE T4.amenity_name = 'TV Lounge')
Find the name of amenities of the dorm where the student with last name Smith is living in.
-- 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. Translate `Find the name of amenities of the dorm where the student with last name Smith is living in.` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
What are the amenities in the dorm that a student who has the last name of Smith lives in?
-- 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. Translate `What are the amenities in the dorm that a student who has the last name of Smith lives in?` to a syntactically-correct PostgreSQL query.
SELECT T3.amenity_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 JOIN lives_in AS T4 ON T4.dormid = T1.dormid JOIN student AS T5 ON T5.stuid = T4.stuid WHERE T5.lname = 'Smith'
How many customers are there?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `How many customers are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM customers
Count the number of customers.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Count the number of customers.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM customers
Find the emails and phone numbers of all the customers, ordered by email address and phone number.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the emails and phone numbers of all the customers, ordered by email address and phone number.` to a syntactically-correct PostgreSQL query.
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
What are the emails and phone numbers of all customers, sorted by email address and phone number?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the emails and phone numbers of all customers, sorted by email address and phone number?` to a syntactically-correct PostgreSQL query.
SELECT email_address , phone_number FROM customers ORDER BY email_address , phone_number
Which city has the least number of customers whose type code is "Good Credit Rating"?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Which city has the least number of customers whose type code is "Good Credit Rating"?` to a syntactically-correct PostgreSQL query.
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
Return the city with the customer type code "Good Credit Rating" that had the fewest customers.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return the city with the customer type code "Good Credit Rating" that had the fewest customers.` to a syntactically-correct PostgreSQL query.
SELECT town_city FROM customers WHERE customer_type_code = "Good Credit Rating" GROUP BY town_city ORDER BY count(*) LIMIT 1
List the name of all products along with the number of complaints that they have received.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `List the name of all products along with the number of complaints that they have received.` to a syntactically-correct PostgreSQL query.
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
What are all the different product names, and how many complains has each received?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are all the different product names, and how many complains has each received?` to a syntactically-correct PostgreSQL query.
SELECT t1.product_name , count(*) FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id GROUP BY t1.product_name
Find the emails of customers who has filed a complaints of the product with the most complaints.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the emails of customers who has filed a complaints of the product with the most complaints.` to a syntactically-correct PostgreSQL query.
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the emails of customers who have filed complaints on the product which has had the greatest number of complaints?` to a syntactically-correct PostgreSQL query.
SELECT t1.email_address FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id GROUP BY t1.customer_id ORDER BY count(*) LIMIT 1
Which products has been complained by the customer who has filed least amount of complaints?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Which products has been complained by the customer who has filed least amount of complaints?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return the names of products that have had complaints filed by the customer who has filed the fewest complaints.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT t1.product_name FROM products AS t1 JOIN complaints AS t2 ON t1.product_id = t2.product_id JOIN customers AS t3 GROUP BY t3.customer_id ORDER BY count(*) LIMIT 1
What is the phone number of the customer who has filed the most recent complaint?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What is the phone number of the customer who has filed the most recent complaint?` to a syntactically-correct PostgreSQL query.
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Return the phone number of the customer who filed the complaint that was raised most recently.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return the phone number of the customer who filed the complaint that was raised most recently.` to a syntactically-correct PostgreSQL query.
SELECT t1.phone_number FROM customers AS t1 JOIN complaints AS t2 ON t1.customer_id = t2.customer_id ORDER BY t2.date_complaint_raised DESC LIMIT 1
Find the email and phone number of the customers who have never filed a complaint before.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the email and phone number of the customers who have never filed a complaint before.` to a syntactically-correct PostgreSQL query.
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
What are the emails and phone numbers of custoemrs who have never filed a complaint?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the emails and phone numbers of custoemrs who have never filed a complaint?` to a syntactically-correct PostgreSQL query.
SELECT email_address , phone_number FROM customers WHERE customer_id NOT IN (SELECT customer_id FROM complaints)
Find the phone number of all the customers and staff.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the phone number of all the customers and staff.` to a syntactically-correct PostgreSQL query.
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What are the phone numbers of all customers and all staff members?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the phone numbers of all customers and all staff members?` to a syntactically-correct PostgreSQL query.
SELECT phone_number FROM customers UNION SELECT phone_number FROM staff
What is the description of the product named "Chocolate"?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What is the description of the product named "Chocolate"?` to a syntactically-correct PostgreSQL query.
SELECT product_description FROM products WHERE product_name = "Chocolate"
Return the description of the product called "Chocolate".
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return the description of the product called "Chocolate".` to a syntactically-correct PostgreSQL query.
SELECT product_description FROM products WHERE product_name = "Chocolate"
Find the name and category of the most expensive product.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the name and category of the most expensive product.` to a syntactically-correct PostgreSQL query.
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
What is the name and category code of the product with the highest price?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What is the name and category code of the product with the highest price?` to a syntactically-correct PostgreSQL query.
SELECT product_name , product_category_code FROM products ORDER BY product_price DESC LIMIT 1
Find the prices of products which has never received a single complaint.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the prices of products which has never received a single complaint.` to a syntactically-correct PostgreSQL query.
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
What are the prices of products that have never gotten a complaint?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the prices of products that have never gotten a complaint?` to a syntactically-correct PostgreSQL query.
SELECT product_price FROM products WHERE product_id NOT IN (SELECT product_id FROM complaints)
What is the average price of the products for each category?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What is the average price of the products for each category?` to a syntactically-correct PostgreSQL query.
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
Return the average price of products that have each category code.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return the average price of products that have each category code.` to a syntactically-correct PostgreSQL query.
SELECT avg(product_price) , product_category_code FROM products GROUP BY product_category_code
Find the last name of the staff member who processed the complaint of the cheapest product.
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the last name of the staff member who processed the complaint of the cheapest product.` to a syntactically-correct PostgreSQL query.
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
What is the last name of the staff member in charge of the complaint on the product with the lowest price?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What is the last name of the staff member in charge of the complaint on the product with the lowest price?` to a syntactically-correct PostgreSQL query.
SELECT t1.last_name FROM staff AS t1 JOIN complaints AS t2 ON t1.staff_id = t2.staff_id JOIN products AS t3 ON t2.product_id = t3.product_id ORDER BY t3.product_price LIMIT 1
Which complaint status has more than 3 records on file?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Which complaint status has more than 3 records on file?` to a syntactically-correct PostgreSQL query.
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Return complaint status codes have more than 3 corresponding complaints?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Return complaint status codes have more than 3 corresponding complaints?` to a syntactically-correct PostgreSQL query.
SELECT complaint_status_code FROM complaints GROUP BY complaint_status_code HAVING count(*) > 3
Find the last name of the staff whose email address contains "wrau".
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `Find the last name of the staff whose email address contains "wrau".` to a syntactically-correct PostgreSQL query.
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"
What are the last names of staff with email addressed containing the substring "wrau"?
-- Language PostgreSQL -- Tables: -- Table: staff columns : [['staff id', 'number'], ['gender', 'text'], ['first name', 'text'], ['last name', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: customers columns : [['customer id', 'number'], ['customer type code', 'text'], ['address line 1', 'text'], ['address line 2', 'text'], ['town city', 'text'], ['state', 'text'], ['email address', 'text'], ['phone number', 'text']] -- Table: products columns : [['product id', 'number'], ['parent product id', 'number'], ['product category code', 'text'], ['date product first available', 'time'], ['date product discontinued', 'time'], ['product name', 'text'], ['product description', 'text'], ['product price', 'number']] -- Table: complaints columns : [['complaint id', 'number'], ['product id', 'number'], ['customer id', 'number'], ['complaint outcome code', 'text'], ['complaint status code', 'text'], ['complaint type code', 'text'], ['date complaint raised', 'time'], ['date complaint closed', 'time'], ['staff 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. Translate `What are the last names of staff with email addressed containing the substring "wrau"?` to a syntactically-correct PostgreSQL query.
SELECT last_name FROM staff WHERE email_address LIKE "%wrau%"