sert121/SpiderSQL huggingface dataset:
-- 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.



Question: Find the branch name of the bank that has the most number of customers.
SQL: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
-- 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.



Question: What is the name of the bank branch with the greatest number of customers?
SQL: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
-- 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.



Question: Find the name of customer who has the lowest credit score.
SQL: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
-- 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.



Question: What is the name of the customer with the worst credit score?
SQL: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
-- 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.



Question: Find the name, account type, and account balance of the customer who has the highest credit score.
SQL: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
-- 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.



Question: What is the name, account type, and account balance corresponding to the customer with the highest credit score?
SQL: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
-- 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.



Question: Find the name of customer who has the highest amount of loans.
SQL: 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
-- 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.



Question: What is the name of the customer who has greatest total loan amount?
SQL: 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
-- 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.



Question: Find the state which has the most number of customers.
SQL: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
-- 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.



Question: Which state has the greatest total number of bank customers?
SQL: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
-- 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.



Question: For each account type, find the average account balance of customers with credit score lower than 50.
SQL: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type
-- 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.



Question: What is the average account balance of customers with credit score below 50 for the different account types?
SQL: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type
-- 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.



Question: For each state, find the total account balance of customers whose credit score is above 100.
SQL: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY 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.



Question: What is the total account balance for customers with a credit score of above 100 for the different states?
SQL: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY 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.



Question: Find the total amount of loans offered by each bank branch.
SQL: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname
-- 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.



Question: What are the names of the different bank branches, and what are their total loan amounts?
SQL: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname
-- 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.



Question: Find the name of customers who have more than one loan.
SQL: 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
-- 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.



Question: What are the names of customers who have taken out more than one loan?
SQL: 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
-- 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.



Question: Find the name and account balance of the customers who have loans with a total amount of more than 5000.
SQL: 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
-- 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.



Question: What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?
SQL: 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
-- 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.



Question: Find the name of bank branch that provided the greatest total amount of loans.
SQL: 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
-- 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.



Question: What is the name of the bank branch that has lent the greatest amount?
SQL: 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
-- 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.



Question: Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.
SQL: 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
-- 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.



Question: 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?
SQL: 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
-- 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.



Question: Find the name of bank branches that provided some loans.
SQL: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id
-- 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.



Question: What are the names of the different banks that have provided loans?
SQL: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id
-- 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.



Question: Find the name and credit score of the customers who have some loans.
SQL: SELECT DISTINCT T1.cust_name ,  T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id
-- 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.



Question: What are the different names and credit scores of customers who have taken a loan?
SQL: SELECT DISTINCT T1.cust_name ,  T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id
-- 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.



Question: Find the the name of the customers who have a loan with amount more than 3000.
SQL: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id WHERE amount  >  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.



Question: What are the names of customers who have a loan of more than 3000 in amount?
SQL: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id WHERE amount  >  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.



Question: Find the city and name of bank branches that provide business loans.
SQL: 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'
-- 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.



Question: What are the names and cities of bank branches that offer loans for business?
SQL: 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'
-- 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.



Question: Find the names of bank branches that have provided a loan to any customer whose credit score is below 100.
SQL: 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
-- 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.



Question: What are the names of banks that have loaned money to customers with credit scores below 100?
SQL: 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
-- 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.



Question: Find the total amount of loans provided by bank branches in the state of New York.
SQL: SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id WHERE T1.state  =  '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.



Question: What is the total amount of money loaned by banks in New York state?
SQL: SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id WHERE T1.state  =  '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.



Question: Find the average credit score of the customers who have some loan.
SQL: SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM 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.



Question: What is the average credit score for customers who have taken a loan?
SQL: SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM 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.



Question: Find the average credit score of the customers who do not have any loan.
SQL: SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM 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.



Question: What is the average credit score for customers who have never taken a loan?
SQL: SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan)
-- 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.



Question: How many assessment notes are there in total?
SQL: SELECT count(*) FROM ASSESSMENT_NOTES