Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the number of different cities which banks are located at. [/INST]

Output: SELECT count(DISTINCT city) FROM bank;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: In how many different cities are banks located? [/INST]

Output: SELECT count(DISTINCT city) FROM bank;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the number of different states which banks are located at. [/INST]

Output: SELECT count(DISTINCT state) FROM bank;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: In how many different states are banks located? [/INST]

Output: SELECT count(DISTINCT state) FROM bank;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: How many distinct types of accounts are there? [/INST]

Output: SELECT count(DISTINCT acc_type) FROM customer;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Count the number of different account types. [/INST]

Output: SELECT count(DISTINCT acc_type) FROM customer;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name and account balance of the customer whose name includes the letter ‘a’. [/INST]

Output: SELECT cust_name ,  acc_bal FROM customer WHERE cust_name LIKE '%a%';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names and account balances of customers with the letter a in their names? [/INST]

Output: SELECT cust_name ,  acc_bal FROM customer WHERE cust_name LIKE '%a%';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the total account balance of each customer from Utah or Texas. [/INST]

Output: SELECT sum(acc_bal) FROM customer WHERE state  =  'Utah' OR state  =  'Texas';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the total account balances for each customer from Utah or Texas? [/INST]

Output: SELECT sum(acc_bal) FROM customer WHERE state  =  'Utah' OR state  =  'Texas';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers who have both saving and checking account types. [/INST]

Output: SELECT cust_name FROM customer WHERE acc_type  =  'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type  =  'checking';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who have both savings and checking accounts? [/INST]

Output: SELECT cust_name FROM customer WHERE acc_type  =  'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type  =  'checking';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers who do not have an saving account. [/INST]

Output: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type  =  'saving';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who do not have saving accounts? [/INST]

Output: SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type  =  'saving';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers who do not have a loan with a type of Mortgages. [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who have not taken a Mortage loan? [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers who have loans of both Mortgages and Auto. [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who have taken both Mortgage and Auto loans? [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers whose credit score is below the average credit scores of all customers. [/INST]

Output: SELECT cust_name FROM customer WHERE credit_score  <  (SELECT avg(credit_score) FROM customer);


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers with credit score less than the average credit score across customers? [/INST]

Output: SELECT cust_name FROM customer WHERE credit_score  <  (SELECT avg(credit_score) FROM customer);


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the branch name of the bank that has the most number of customers. [/INST]

Output: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the bank branch with the greatest number of customers? [/INST]

Output: SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customer who has the lowest credit score. [/INST]

Output: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the customer with the worst credit score? [/INST]

Output: SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name, account type, and account balance of the customer who has the highest credit score. [/INST]

Output: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the name, account type, and account balance corresponding to the customer with the highest credit score? [/INST]

Output: SELECT cust_name ,  acc_type ,  acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customer who has the highest amount of loans. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the customer who has greatest total loan amount? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the state which has the most number of customers. [/INST]

Output: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Which state has the greatest total number of bank customers? [/INST]

Output: SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: For each account type, find the average account balance of customers with credit score lower than 50. [/INST]

Output: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the average account balance of customers with credit score below 50 for the different account types? [/INST]

Output: SELECT avg(acc_bal) ,  acc_type FROM customer WHERE credit_score  <  50 GROUP BY acc_type;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: For each state, find the total account balance of customers whose credit score is above 100. [/INST]

Output: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY state;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the total account balance for customers with a credit score of above 100 for the different states? [/INST]

Output: SELECT sum(acc_bal) ,  state FROM customer WHERE credit_score  >  100 GROUP BY state;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the total amount of loans offered by each bank branch. [/INST]

Output: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the different bank branches, and what are their total loan amounts? [/INST]

Output: SELECT sum(amount) ,  T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id GROUP BY T1.bname;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of customers who have more than one loan. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who have taken out more than one loan? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name and account balance of the customers who have loans with a total amount of more than 5000. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names and account balances for customers who have taken a total amount of more than 5000 in loans? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of bank branch that provided the greatest total amount of loans. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the name of the bank branch that has lent the greatest amount? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following 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? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name of bank branches that provided some loans. [/INST]

Output: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of the different banks that have provided loans? [/INST]

Output: SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the name and credit score of the customers who have some loans. [/INST]

Output: SELECT DISTINCT T1.cust_name ,  T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the different names and credit scores of customers who have taken a loan? [/INST]

Output: SELECT DISTINCT T1.cust_name ,  T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the the name of the customers who have a loan with amount more than 3000. [/INST]

Output: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id WHERE amount  >  3000;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of customers who have a loan of more than 3000 in amount? [/INST]

Output: SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id  =  T2.cust_id WHERE amount  >  3000;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the city and name of bank branches that provide business loans. [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names and cities of bank branches that offer loans for business? [/INST]

Output: 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';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the names of bank branches that have provided a loan to any customer whose credit score is below 100. [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What are the names of banks that have loaned money to customers with credit scores below 100? [/INST]

Output: 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;


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the total amount of loans provided by bank branches in the state of New York. [/INST]

Output: SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id WHERE T1.state  =  'New York';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the total amount of money loaned by banks in New York state? [/INST]

Output: SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id  =  T2.branch_id WHERE T1.state  =  'New York';


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the average credit score of the customers who have some loan. [/INST]

Output: SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan);


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the average credit score for customers who have taken a loan? [/INST]

Output: SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan);


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: Find the average credit score of the customers who do not have any loan. [/INST]

Output: SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan);


Input:
[INST] Here is a database schema:
bank :
branch_ID [ INT ] primary_key
bname [ TEXT ]
no_of_customers [ INT ]
city [ TEXT ]
state [ TEXT ]

customer :
cust_ID [ TEXT ] primary_key
cust_name [ TEXT ]
acc_type [ TEXT ]
acc_bal [ INT ]
no_of_loans [ INT ]
credit_score [ INT ]
branch_ID [ INT ] customer.branch_ID = bank.branch_ID
state [ TEXT ]

loan :
loan_ID [ TEXT ] primary_key
loan_type [ TEXT ]
cust_ID [ TEXT ]
branch_ID [ TEXT ] loan.branch_ID = bank.branch_ID
amount [ INT ]

Please write me a SQL statement that answers the following question: What is the average credit score for customers who have never taken a loan? [/INST]

Output: SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan);


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: How many assessment notes are there in total? [/INST]

Output: SELECT count(*) FROM ASSESSMENT_NOTES;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the dates of the assessment notes? [/INST]

Output: SELECT date_of_notes FROM Assessment_Notes;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: How many addresses have zip code 197? [/INST]

Output: SELECT count(*) FROM ADDRESSES WHERE zip_postcode  =  "197";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: How many distinct incident type codes are there? [/INST]

Output: SELECT count(DISTINCT incident_type_code) FROM Behavior_Incident;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Return all distinct detention type codes. [/INST]

Output: SELECT DISTINCT detention_type_code FROM Detention;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What are the start and end dates for incidents with incident type code "NOISE"? [/INST]

Output: SELECT date_incident_start ,  date_incident_end FROM Behavior_Incident WHERE incident_type_code  =  "NOISE";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Return all detention summaries. [/INST]

Output: SELECT detention_summary FROM Detention;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Return the cell phone number and email address for all students. [/INST]

Output: SELECT cell_mobile_number ,  email_address FROM STUDENTS;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What is the email of the student with first name "Emma" and last name "Rohan"? [/INST]

Output: SELECT email_address FROM Students WHERE first_name  =  "Emma" AND last_name  =  "Rohan";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: How many distinct students have been in detention? [/INST]

Output: SELECT count(DISTINCT student_id) FROM Students_in_Detention;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What is the gender of the teacher with last name "Medhurst"? [/INST]

Output: SELECT gender FROM TEACHERS WHERE last_name  =  "Medhurst";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: What is the incident type description for the incident type with code "VIOLENCE"? [/INST]

Output: SELECT incident_type_description FROM Ref_Incident_Type WHERE incident_type_code  =  "VIOLENCE";


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the maximum and minimum monthly rental for all student addresses. [/INST]

Output: SELECT max(monthly_rental) ,  min(monthly_rental) FROM Student_Addresses;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the first names of teachers whose email address contains the word "man". [/INST]

Output: SELECT first_name FROM Teachers WHERE email_address LIKE '%man%';


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: List all information about the assessment notes sorted by date in ascending order. [/INST]

Output: SELECT * FROM Assessment_Notes ORDER BY date_of_notes ASC;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: List all cities of addresses in alphabetical order. [/INST]

Output: SELECT city FROM Addresses ORDER BY city;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the first names and last names of teachers in alphabetical order of last name. [/INST]

Output: SELECT first_name ,  last_name FROM Teachers ORDER BY last_name;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find all information about student addresses, and sort by monthly rental in descending order. [/INST]

Output: SELECT * FROM Student_Addresses ORDER BY monthly_rental DESC;


Input:
[INST] Here is a database schema:
Ref_Address_Types :
address_type_code [ TEXT ] primary_key
address_type_description [ TEXT ]

Ref_Detention_Type :
detention_type_code [ TEXT ] primary_key
detention_type_description [ TEXT ]

Ref_Incident_Type :
incident_type_code [ TEXT ] primary_key
incident_type_description [ TEXT ]

Addresses :
address_id [ INT ] primary_key
line_1 [ TEXT ]
line_2 [ TEXT ]
line_3 [ TEXT ]
city [ TEXT ]
zip_postcode [ TEXT ]
state_province_county [ TEXT ]
country [ TEXT ]
other_address_details [ TEXT ]

Students :
student_id [ INT ] primary_key
address_id [ INT ] Students.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
date_first_rental [ TEXT ]
date_left_university [ TEXT ]
other_student_details [ TEXT ]

Teachers :
teacher_id [ INT ] primary_key
address_id [ INT ] Teachers.address_id = Addresses.address_id
first_name [ TEXT ]
middle_name [ TEXT ]
last_name [ TEXT ]
gender [ TEXT ]
cell_mobile_number [ TEXT ]
email_address [ TEXT ]
other_details [ TEXT ]

Assessment_Notes :
notes_id [ INT ]
student_id [ INT ] Assessment_Notes.student_id = Students.student_id
teacher_id [ INT ] Assessment_Notes.teacher_id = Teachers.teacher_id
date_of_notes [ TEXT ]
text_of_notes [ TEXT ]
other_details [ TEXT ]

Behavior_Incident :
incident_id [ INT ] primary_key
incident_type_code [ TEXT ] Behavior_Incident.incident_type_code = Ref_Incident_Type.incident_type_code
student_id [ INT ] Behavior_Incident.student_id = Students.student_id
date_incident_start [ TEXT ]
date_incident_end [ TEXT ]
incident_summary [ TEXT ]
recommendations [ TEXT ]
other_details [ TEXT ]

Detention :
detention_id [ INT ] primary_key
detention_type_code [ TEXT ] Detention.detention_type_code = Ref_Detention_Type.detention_type_code
teacher_id [ INT ] Detention.teacher_id = Teachers.teacher_id
datetime_detention_start [ TEXT ]
datetime_detention_end [ TEXT ]
detention_summary [ TEXT ]
other_details [ TEXT ]

Student_Addresses :
student_id [ INT ] Student_Addresses.student_id = Students.student_id
address_id [ INT ] Student_Addresses.address_id = Addresses.address_id
date_address_from [ TEXT ]
date_address_to [ TEXT ]
monthly_rental [ INT ]
other_details [ TEXT ]

Students_in_Detention :
student_id [ INT ] Students_in_Detention.student_id = Students.student_id
detention_id [ INT ] Students_in_Detention.detention_id = Detention.detention_id
incident_id [ INT ] Students_in_Detention.incident_id = Behavior_Incident.incident_id

Please write me a SQL statement that answers the following question: Find the id and first name of the student that has the most number of assessment notes? [/INST]

Output: SELECT T1.student_id ,  T2.first_name FROM Assessment_Notes AS T1 JOIN Students AS T2 ON T1.student_id  =  T2.student_id GROUP BY T1.student_id ORDER BY count(*) DESC LIMIT 1;