brief_instruction
stringlengths
16
224
instruction
stringlengths
687
8.77k
output
stringlengths
18
577
What is the largest payment amount?
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 largest payment amount?` to a syntactically-correct PostgreSQL query.
SELECT amount FROM payment ORDER BY amount DESC LIMIT 1
Return the amount of the largest payment.
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 amount of the largest payment.` to a syntactically-correct PostgreSQL query.
SELECT amount FROM payment ORDER BY amount DESC LIMIT 1
Where does the staff member with the first name Elsa live?
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 `Where does the staff member with the first name Elsa live?` to a syntactically-correct PostgreSQL query.
SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE T1.first_name = 'Elsa'
Give the address of the staff member who has the first name Elsa.
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 `Give the address of the staff member who has the first name Elsa.` to a syntactically-correct PostgreSQL query.
SELECT T2.address FROM staff AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE T1.first_name = 'Elsa'
What are the first names of customers who have not rented any films after '2005-08-23 02:06:01'?
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 customers who have not rented any films after '2005-08-23 02:06:01'?` to a syntactically-correct PostgreSQL query.
SELECT first_name FROM customer WHERE customer_id NOT IN( SELECT customer_id FROM rental WHERE rental_date > '2005-08-23 02:06:01' )
Return the first names of customers who did not rented a film after the date '2005-08-23 02:06:01'.
-- Language PostgreSQL -- Tables: -- Table: actor columns : [['actor id', 'number'], ['first name', 'text'], ['last name', 'text'], ['last update', 'time']] -- Table: address columns : [['address id', 'number'], ['address', 'text'], ['address2', 'text'], ['district', 'text'], ['city id', 'number'], ['postal code', 'text'], ['phone', 'text'], ['last update', 'time']] -- Table: category columns : [['category id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: city columns : [['city id', 'number'], ['city', 'text'], ['country id', 'number'], ['last update', 'time']] -- Table: country columns : [['country id', 'number'], ['country', 'text'], ['last update', 'time']] -- Table: customer columns : [['customer id', 'number'], ['store id', 'number'], ['first name', 'text'], ['last name', 'text'], ['email', 'text'], ['address id', 'number'], ['active', 'boolean'], ['create date', 'time'], ['last update', 'time']] -- Table: film columns : [['film id', 'number'], ['title', 'text'], ['description', 'text'], ['release year', 'time'], ['language id', 'number'], ['original language id', 'number'], ['rental duration', 'number'], ['rental rate', 'number'], ['length', 'number'], ['replacement cost', 'number'], ['rating', 'text'], ['special features', 'text'], ['last update', 'time']] -- Table: film actor columns : [['actor id', 'number'], ['film id', 'number'], ['last update', 'time']] -- Table: film category columns : [['film id', 'number'], ['category id', 'number'], ['last update', 'time']] -- Table: film text columns : [['film id', 'number'], ['title', 'text'], ['description', 'text']] -- Table: inventory columns : [['inventory id', 'number'], ['film id', 'number'], ['store id', 'number'], ['last update', 'time']] -- Table: language columns : [['language id', 'number'], ['name', 'text'], ['last update', 'time']] -- Table: payment columns : [['payment id', 'number'], ['customer id', 'number'], ['staff id', 'number'], ['rental id', 'number'], ['amount', 'number'], ['payment date', 'time'], ['last update', 'time']] -- Table: rental columns : [['rental id', 'number'], ['rental date', 'time'], ['inventory id', 'number'], ['customer id', 'number'], ['return date', 'time'], ['staff id', 'number'], ['last update', 'time']] -- Table: staff columns : [['staff id', 'number'], ['first name', 'text'], ['last name', 'text'], ['address id', 'number'], ['picture', 'others'], ['email', 'text'], ['store id', 'number'], ['active', 'boolean'], ['username', 'text'], ['password', 'text'], ['last update', 'time']] -- Table: store columns : [['store id', 'number'], ['manager staff id', 'number'], ['address id', 'number'], ['last update', 'time']] You are a SQL code translator. You have been given the Table data above. Your role is to translate natural language to PostgreSQL. You should not select columns that are not part of the 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 first names of customers who did not rented a film after the date '2005-08-23 02:06:01'.` to a syntactically-correct PostgreSQL query.
SELECT first_name FROM customer WHERE customer_id NOT IN( SELECT customer_id FROM rental WHERE rental_date > '2005-08-23 02:06:01' )
How many bank branches are there?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branches are there?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM bank
Count the number of bank branches.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branches.` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM bank
How many customers are there?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 sum(no_of_customers) FROM bank
What is the total number of customers across banks?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 total number of customers across banks?` to a syntactically-correct PostgreSQL query.
SELECT sum(no_of_customers) FROM bank
Find the number of customers in the banks at New York City.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers in the banks at New York City.` to a syntactically-correct PostgreSQL query.
SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'
What is the total number of customers who use banks in New York City?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 total number of customers who use banks in New York City?` to a syntactically-correct PostgreSQL query.
SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'
Find the average number of customers in all banks of Utah state.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 number of customers in all banks of Utah state.` to a syntactically-correct PostgreSQL query.
SELECT avg(no_of_customers) FROM bank WHERE state = 'Utah'
What is the average number of customers across banks in the state of Utah?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 number of customers across banks in the state of Utah?` to a syntactically-correct PostgreSQL query.
SELECT avg(no_of_customers) FROM bank WHERE state = 'Utah'
Find the average number of customers cross all banks.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 number of customers cross all banks.` to a syntactically-correct PostgreSQL query.
SELECT avg(no_of_customers) FROM bank
What is the average number of bank customers?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 number of bank customers?` to a syntactically-correct PostgreSQL query.
SELECT avg(no_of_customers) FROM bank
Find the city and state of the bank branch named morningside.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 city and state of the bank branch named morningside.` to a syntactically-correct PostgreSQL query.
SELECT city , state FROM bank WHERE bname = 'morningside'
What city and state is the bank with the name morningside in?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 city and state is the bank with the name morningside in?` to a syntactically-correct PostgreSQL query.
SELECT city , state FROM bank WHERE bname = 'morningside'
Find the branch names of banks in the New York state.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 branch names of banks in the New York state.` to a syntactically-correct PostgreSQL query.
SELECT bname FROM bank WHERE state = 'New York'
What are the names of banks in the state of New York?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 banks in the state of New York?` to a syntactically-correct PostgreSQL query.
SELECT bname FROM bank WHERE state = 'New York'
List the name of all customers sorted by their account balance in ascending order.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers sorted by their account balance in ascending order.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer ORDER BY acc_bal
What are the names of all customers, ordered by account balance?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 all customers, ordered by account balance?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer ORDER BY acc_bal
List the name of all different customers who have some loan sorted by their total loan amount.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different customers who have some loan sorted by their total loan amount.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount)
What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different customers who have taken out a loan, ordered by the total amount that they have taken?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount)
Find the state, account type, and credit score of the customer whose number of loan is 0.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 state, account type, and credit score of the customer whose number of loan is 0.` to a syntactically-correct PostgreSQL query.
SELECT state , acc_type , credit_score FROM customer WHERE no_of_loans = 0
What are the states, account types, and credit scores for customers who have 0 loans?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 states, account types, and credit scores for customers who have 0 loans?` to a syntactically-correct PostgreSQL query.
SELECT state , acc_type , credit_score FROM customer WHERE no_of_loans = 0
Find the number of different cities which banks are located at.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different cities which banks are located at.` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT city) FROM bank
In how many different cities are banks located?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 `In how many different cities are banks located?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT city) FROM bank
Find the number of different states which banks are located at.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different states which banks are located at.` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT state) FROM bank
In how many different states are banks located?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 `In how many different states are banks located?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT state) FROM bank
How many distinct types of accounts are there?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 distinct types of accounts are there?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT acc_type) FROM customer
Count the number of different account types.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different account types.` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT acc_type) FROM customer
Find the name and account balance of the customer whose name includes the letter ‘a’.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account balance of the customer whose name includes the letter ‘a’.` to a syntactically-correct PostgreSQL query.
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
What are the names and account balances of customers with the letter a in their names?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 and account balances of customers with the letter a in their names?` to a syntactically-correct PostgreSQL query.
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
Find the total account balance of each customer from Utah or Texas.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account balance of each customer from Utah or Texas.` to a syntactically-correct PostgreSQL query.
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
What are the total account balances for each customer from Utah or Texas?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account balances for each customer from Utah or Texas?` to a syntactically-correct PostgreSQL query.
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
Find the name of customers who have both saving and checking account types.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have both saving and checking account types.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
What are the names of customers who have both savings and checking accounts?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have both savings and checking accounts?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
Find the name of customers who do not have an saving account.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who do not have an saving account.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
What are the names of customers who do not have saving accounts?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who do not have saving accounts?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
Find the name of customers who do not have a loan with a type of Mortgages.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who do not have a loan with a type of Mortgages.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'
What are the names of customers who have not taken a Mortage loan?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have not taken a Mortage loan?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer EXCEPT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE T2.loan_type = 'Mortgages'
Find the name of customers who have loans of both Mortgages and Auto.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have loans of both Mortgages and Auto.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'
What are the names of customers who have taken both Mortgage and Auto loans?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have taken both Mortgage and Auto loans?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Mortgages' INTERSECT SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE loan_type = 'Auto'
Find the name of customers whose credit score is below the average credit scores of all customers.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers whose credit score is below the average credit scores of all customers.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer WHERE credit_score < (SELECT avg(credit_score) FROM customer)
What are the names of customers with credit score less than the average credit score across customers?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers with credit score less than the average credit score across customers?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer WHERE credit_score < (SELECT avg(credit_score) FROM customer)
Find the branch name of the bank that has the most number of customers.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 branch name of the bank that has the most number of customers.` to a syntactically-correct PostgreSQL query.
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
What is the name of the bank branch with the greatest number of customers?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branch with the greatest number of customers?` to a syntactically-correct PostgreSQL query.
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
Find the name of customer who has the lowest credit score.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customer who has the lowest credit score.` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
What is the name of the customer with the worst credit score?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customer with the worst credit score?` to a syntactically-correct PostgreSQL query.
SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
Find the name, account type, and account balance of the customer who has the highest credit score.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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, account type, and account balance of the customer who has the highest credit score.` to a syntactically-correct PostgreSQL query.
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
What is the name, account type, and account balance corresponding to the customer with the highest credit score?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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, account type, and account balance corresponding to the customer with the highest credit score?` to a syntactically-correct PostgreSQL query.
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
Find the name of customer who has the highest amount of loans.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customer who has the highest amount of loans.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount) DESC LIMIT 1
What is the name of the customer who has greatest total loan amount?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customer who has greatest total loan amount?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name ORDER BY sum(T2.amount) DESC LIMIT 1
Find the state which has the most number of customers.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 state which has the most number of customers.` to a syntactically-correct PostgreSQL query.
SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
Which state has the greatest total number of bank customers?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 state has the greatest total number of bank customers?` to a syntactically-correct PostgreSQL query.
SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
For each account type, find the average account balance of customers with credit score lower than 50.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account type, find the average account balance of customers with credit score lower than 50.` to a syntactically-correct PostgreSQL query.
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
What is the average account balance of customers with credit score below 50 for the different account types?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account balance of customers with credit score below 50 for the different account types?` to a syntactically-correct PostgreSQL query.
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
For each state, find the total account balance of customers whose credit score is above 100.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 state, find the total account balance of customers whose credit score is above 100.` to a syntactically-correct PostgreSQL query.
SELECT sum(acc_bal) , state FROM customer WHERE credit_score > 100 GROUP BY state
What is the total account balance for customers with a credit score of above 100 for the different states?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 total account balance for customers with a credit score of above 100 for the different states?` to a syntactically-correct PostgreSQL query.
SELECT sum(acc_bal) , state FROM customer WHERE credit_score > 100 GROUP BY state
Find the total amount of loans offered by each bank branch.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 amount of loans offered by each bank branch.` to a syntactically-correct PostgreSQL query.
SELECT sum(amount) , T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname
What are the names of the different bank branches, and what are their total loan amounts?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different bank branches, and what are their total loan amounts?` to a syntactically-correct PostgreSQL query.
SELECT sum(amount) , T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname
Find the name of customers who have more than one loan.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have more than one loan.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING count(*) > 1
What are the names of customers who have taken out more than one loan?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have taken out more than one loan?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING count(*) > 1
Find the name and account balance of the customers who have loans with a total amount of more than 5000.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 account balance of the customers who have loans with a total amount of more than 5000.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000
What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 and account balances for customers who have taken a total amount of more than 5000 in loans?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name , T1.acc_type FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id GROUP BY T1.cust_name HAVING sum(T2.amount) > 5000
Find the name of bank branch that provided the greatest total amount of loans.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branch that provided the greatest total amount of loans.` to a syntactically-correct PostgreSQL query.
SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY sum(T2.amount) DESC LIMIT 1
What is the name of the bank branch that has lent the greatest amount?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branch that has lent the greatest amount?` to a syntactically-correct PostgreSQL query.
SELECT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname ORDER BY sum(T2.amount) DESC LIMIT 1
Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.` to a syntactically-correct PostgreSQL query.
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY sum(T1.amount) DESC LIMIT 1
What is the name of the bank branch that has lended the largest total amount in loans, specifically to customers with credit scores below 100?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branch that has lended the largest total amount in loans, specifically to customers with credit scores below 100?` to a syntactically-correct PostgreSQL query.
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100 GROUP BY T2.bname ORDER BY sum(T1.amount) DESC LIMIT 1
Find the name of bank branches that provided some loans.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 bank branches that provided some loans.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id
What are the names of the different banks that have provided loans?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 different banks that have provided loans?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id
Find the name and credit score of the customers who have some loans.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 credit score of the customers who have some loans.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.cust_name , T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id
What are the different names and credit scores of customers who have taken a loan?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 names and credit scores of customers who have taken a loan?` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT T1.cust_name , T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id
Find the the name of the customers who have a loan with amount more than 3000.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 the name of the customers who have a loan with amount more than 3000.` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000
What are the names of customers who have a loan of more than 3000 in amount?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 customers who have a loan of more than 3000 in amount?` to a syntactically-correct PostgreSQL query.
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000
Find the city and name of bank branches that provide business loans.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 city and name of bank branches that provide business loans.` to a syntactically-correct PostgreSQL query.
SELECT T1.bname , T1.city FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T2.loan_type = 'Business'
What are the names and cities of bank branches that offer loans for business?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 and cities of bank branches that offer loans for business?` to a syntactically-correct PostgreSQL query.
SELECT T1.bname , T1.city FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T2.loan_type = 'Business'
Find the names of bank branches that have provided a loan to any customer whose credit score is below 100.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 names of bank branches that have provided a loan to any customer whose credit score is below 100.` to a syntactically-correct PostgreSQL query.
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100
What are the names of banks that have loaned money to customers with credit scores below 100?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 banks that have loaned money to customers with credit scores below 100?` to a syntactically-correct PostgreSQL query.
SELECT T2.bname FROM loan AS T1 JOIN bank AS T2 ON T1.branch_id = T2.branch_id JOIN customer AS T3 ON T1.cust_id = T3.cust_id WHERE T3.credit_score < 100
Find the total amount of loans provided by bank branches in the state of New York.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 amount of loans provided by bank branches in the state of New York.` to a syntactically-correct PostgreSQL query.
SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'
What is the total amount of money loaned by banks in New York state?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 total amount of money loaned by banks in New York state?` to a syntactically-correct PostgreSQL query.
SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'
Find the average credit score of the customers who have some loan.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 credit score of the customers who have some loan.` to a syntactically-correct PostgreSQL query.
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
What is the average credit score for customers who have taken a loan?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 credit score for customers who have taken a loan?` to a syntactically-correct PostgreSQL query.
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
Find the average credit score of the customers who do not have any loan.
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 credit score of the customers who do not have any loan.` to a syntactically-correct PostgreSQL query.
SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan)
What is the average credit score for customers who have never taken a loan?
-- Language PostgreSQL -- Tables: -- Table: bank columns : [['branch id', 'number'], ['bname', 'text'], ['no of customers', 'number'], ['city', 'text'], ['state', 'text']] -- Table: customer columns : [['customer id', 'text'], ['customer name', 'text'], ['account type', 'text'], ['account balance', 'number'], ['number of loans', 'number'], ['credit score', 'number'], ['branch id', 'number'], ['state', 'text']] -- Table: loan columns : [['loan id', 'text'], ['loan type', 'text'], ['customer id', 'text'], ['branch id', 'text'], ['amount', '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 credit score for customers who have never taken a loan?` to a syntactically-correct PostgreSQL query.
SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan)
How many assessment notes are there in total?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 assessment notes are there in total?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM ASSESSMENT_NOTES
What are the dates of the assessment notes?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 dates of the assessment notes?` to a syntactically-correct PostgreSQL query.
SELECT date_of_notes FROM Assessment_Notes
How many addresses have zip code 197?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 addresses have zip code 197?` to a syntactically-correct PostgreSQL query.
SELECT count(*) FROM ADDRESSES WHERE zip_postcode = "197"
How many distinct incident type codes are there?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 distinct incident type codes are there?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT incident_type_code) FROM Behavior_Incident
Return all distinct detention type codes.
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 all distinct detention type codes.` to a syntactically-correct PostgreSQL query.
SELECT DISTINCT detention_type_code FROM Detention
What are the start and end dates for incidents with incident type code "NOISE"?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 start and end dates for incidents with incident type code "NOISE"?` to a syntactically-correct PostgreSQL query.
SELECT date_incident_start , date_incident_end FROM Behavior_Incident WHERE incident_type_code = "NOISE"
Return all detention summaries.
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 all detention summaries.` to a syntactically-correct PostgreSQL query.
SELECT detention_summary FROM Detention
Return the cell phone number and email address for all students.
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 cell phone number and email address for all students.` to a syntactically-correct PostgreSQL query.
SELECT cell_mobile_number , email_address FROM STUDENTS
What is the email of the student with first name "Emma" and last name "Rohan"?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 email of the student with first name "Emma" and last name "Rohan"?` to a syntactically-correct PostgreSQL query.
SELECT email_address FROM Students WHERE first_name = "Emma" AND last_name = "Rohan"
How many distinct students have been in detention?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 distinct students have been in detention?` to a syntactically-correct PostgreSQL query.
SELECT count(DISTINCT student_id) FROM Students_in_Detention
What is the gender of the teacher with last name "Medhurst"?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 gender of the teacher with last name "Medhurst"?` to a syntactically-correct PostgreSQL query.
SELECT gender FROM TEACHERS WHERE last_name = "Medhurst"
What is the incident type description for the incident type with code "VIOLENCE"?
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 incident type description for the incident type with code "VIOLENCE"?` to a syntactically-correct PostgreSQL query.
SELECT incident_type_description FROM Ref_Incident_Type WHERE incident_type_code = "VIOLENCE"
Find the maximum and minimum monthly rental for all student addresses.
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 maximum and minimum monthly rental for all student addresses.` to a syntactically-correct PostgreSQL query.
SELECT max(monthly_rental) , min(monthly_rental) FROM Student_Addresses
Find the first names of teachers whose email address contains the word "man".
-- Language PostgreSQL -- Tables: -- Table: reference address types columns : [['address type code', 'text'], ['address type description', 'text']] -- Table: reference detention type columns : [['detention type code', 'text'], ['detention type description', 'text']] -- Table: reference incident type columns : [['incident type code', 'text'], ['incident type description', 'text']] -- Table: addresses columns : [['address id', 'number'], ['line 1', 'text'], ['line 2', 'text'], ['line 3', 'text'], ['city', 'text'], ['zip postcode', 'text'], ['state province county', 'text'], ['country', 'text'], ['other address details', 'text']] -- Table: students columns : [['student id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['date first rental', 'time'], ['date left university', 'time'], ['other student details', 'text']] -- Table: teachers columns : [['teacher id', 'number'], ['address id', 'number'], ['first name', 'text'], ['middle name', 'text'], ['last name', 'text'], ['gender', 'text'], ['cell mobile number', 'text'], ['email address', 'text'], ['other details', 'text']] -- Table: assessment notes columns : [['notes id', 'number'], ['student id', 'number'], ['teacher id', 'number'], ['date of notes', 'time'], ['text of notes', 'text'], ['other details', 'text']] -- Table: behavior incident columns : [['incident id', 'number'], ['incident type code', 'text'], ['student id', 'number'], ['date incident start', 'time'], ['date incident end', 'time'], ['incident summary', 'text'], ['recommendations', 'text'], ['other details', 'text']] -- Table: detention columns : [['detention id', 'number'], ['detention type code', 'text'], ['teacher id', 'number'], ['datetime detention start', 'time'], ['datetime detention end', 'time'], ['detention summary', 'text'], ['other details', 'text']] -- Table: student addresses columns : [['student id', 'number'], ['address id', 'number'], ['date address from', 'time'], ['date address to', 'time'], ['monthly rental', 'number'], ['other details', 'text']] -- Table: students in detention columns : [['student id', 'number'], ['detention id', 'number'], ['incident 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 first names of teachers whose email address contains the word "man".` to a syntactically-correct PostgreSQL query.
SELECT first_name FROM Teachers WHERE email_address LIKE '%man%'