SQL
stringlengths 18
577
| question
stringlengths 317
11.5k
|
---|---|
SELECT first_name FROM customer WHERE customer_id NOT IN( SELECT customer_id FROM rental WHERE rental_date > '2005-08-23 02:06:01' )
|
Given the Table actor having columns as actor_id has datatype number, first_name has datatype text, last_name has datatype text, last_update has datatype time which has actor_id and Given the Table address having columns as address_id has datatype number, address has datatype text, address2 has datatype text, district has datatype text, city_id has datatype number, postal_code has datatype text, phone has datatype text, last_update has datatype time which has address_id and Given the Table category having columns as category_id has datatype number, name has datatype text, last_update has datatype time which has category_id and Given the Table city having columns as city_id has datatype number, city has datatype text, country_id has datatype number, last_update has datatype time which has city_id and Given the Table country having columns as country_id has datatype number, country has datatype text, last_update has datatype time which has country_id and Given the Table customer having columns as customer_id has datatype number, store_id has datatype number, first_name has datatype text, last_name has datatype text, email has datatype text, address_id has datatype number, active has datatype boolean, create_date has datatype time, last_update has datatype time which has customer_id and Given the Table film having columns as film_id has datatype number, title has datatype text, description has datatype text, release_year has datatype time, language_id has datatype number, original_language_id has datatype number, rental_duration has datatype number, rental_rate has datatype number, length has datatype number, replacement_cost has datatype number, rating has datatype text, special_features has datatype text, last_update has datatype time which has film_id and Given the Table film actor having columns as actor_id has datatype number, film_id has datatype number, last_update has datatype time which has actor_id and Given the Table film category having columns as film_id has datatype number, category_id has datatype number, last_update has datatype time which has film_id and Given the Table film text having columns as film_id has datatype number, title has datatype text, description has datatype text which has film_id and Given the Table inventory having columns as inventory_id has datatype number, film_id has datatype number, store_id has datatype number, last_update has datatype time which has inventory_id and Given the Table language having columns as language_id has datatype number, name has datatype text, last_update has datatype time which has language_id and Given the Table payment having columns as payment_id has datatype number, customer_id has datatype number, staff_id has datatype number, rental_id has datatype number, amount has datatype number, payment_date has datatype time, last_update has datatype time which has payment_id and Given the Table rental having columns as rental_id has datatype number, rental_date has datatype time, inventory_id has datatype number, customer_id has datatype number, return_date has datatype time, staff_id has datatype number, last_update has datatype time which has rental_id and Given the Table staff having columns as staff_id has datatype number, first_name has datatype text, last_name has datatype text, address_id has datatype number, picture has datatype others, email has datatype text, store_id has datatype number, active has datatype boolean, username has datatype text, password has datatype text, last_update has datatype time which has staff_id and Given the Table store having columns as store_id has datatype number, manager_staff_id has datatype number, address_id has datatype number, last_update has datatype time which has store_id. Answer the question by writing the appropriate SQL code. Return the first names of customers who did not rented a film after the date '2005-08-23 02:06:01'.
|
SELECT count(*) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. How many bank branches are there?
|
SELECT count(*) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Count the number of bank branches.
|
SELECT sum(no_of_customers) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. How many customers are there?
|
SELECT sum(no_of_customers) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the total number of customers across banks?
|
SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the number of customers in the banks at New York City.
|
SELECT sum(no_of_customers) FROM bank WHERE city = 'New York City'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the total number of customers who use banks in New York City?
|
SELECT avg(no_of_customers) FROM bank WHERE state = 'Utah'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the average number of customers in all banks of Utah state.
|
SELECT avg(no_of_customers) FROM bank WHERE state = 'Utah'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the average number of customers across banks in the state of Utah?
|
SELECT avg(no_of_customers) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the average number of customers cross all banks.
|
SELECT avg(no_of_customers) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the average number of bank customers?
|
SELECT city , state FROM bank WHERE bname = 'morningside'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the city and state of the bank branch named morningside.
|
SELECT city , state FROM bank WHERE bname = 'morningside'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What city and state is the bank with the name morningside in?
|
SELECT bname FROM bank WHERE state = 'New York'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the branch names of banks in the New York state.
|
SELECT bname FROM bank WHERE state = 'New York'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of banks in the state of New York?
|
SELECT cust_name FROM customer ORDER BY acc_bal
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. List the name of all customers sorted by their account balance in ascending order.
|
SELECT cust_name FROM customer ORDER BY acc_bal
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of all customers, ordered by account balance?
|
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)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. List the name of all different customers who have some loan sorted by their total loan amount.
|
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)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of the different customers who have taken out a loan, ordered by the total amount that they have taken?
|
SELECT state , acc_type , credit_score FROM customer WHERE no_of_loans = 0
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the state, account type, and credit score of the customer whose number of loan is 0.
|
SELECT state , acc_type , credit_score FROM customer WHERE no_of_loans = 0
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the states, account types, and credit scores for customers who have 0 loans?
|
SELECT count(DISTINCT city) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the number of different cities which banks are located at.
|
SELECT count(DISTINCT city) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. In how many different cities are banks located?
|
SELECT count(DISTINCT state) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the number of different states which banks are located at.
|
SELECT count(DISTINCT state) FROM bank
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. In how many different states are banks located?
|
SELECT count(DISTINCT acc_type) FROM customer
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. How many distinct types of accounts are there?
|
SELECT count(DISTINCT acc_type) FROM customer
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Count the number of different account types.
|
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name and account balance of the customer whose name includes the letter ‘a’.
|
SELECT cust_name , acc_bal FROM customer WHERE cust_name LIKE '%a%'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names and account balances of customers with the letter a in their names?
|
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the total account balance of each customer from Utah or Texas.
|
SELECT sum(acc_bal) FROM customer WHERE state = 'Utah' OR state = 'Texas'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the total account balances for each customer from Utah or Texas?
|
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers who have both saving and checking account types.
|
SELECT cust_name FROM customer WHERE acc_type = 'saving' INTERSECT SELECT cust_name FROM customer WHERE acc_type = 'checking'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who have both savings and checking accounts?
|
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers who do not have an saving account.
|
SELECT cust_name FROM customer EXCEPT SELECT cust_name FROM customer WHERE acc_type = 'saving'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who do not have saving accounts?
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers who do not have a loan with a type of Mortgages.
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who have not taken a Mortage loan?
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers who have loans of both Mortgages and Auto.
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who have taken both Mortgage and Auto loans?
|
SELECT cust_name FROM customer WHERE credit_score < (SELECT avg(credit_score) FROM customer)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers whose credit score is below the average credit scores of all customers.
|
SELECT cust_name FROM customer WHERE credit_score < (SELECT avg(credit_score) FROM customer)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers with credit score less than the average credit score across customers?
|
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the branch name of the bank that has the most number of customers.
|
SELECT bname FROM bank ORDER BY no_of_customers DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the name of the bank branch with the greatest number of customers?
|
SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customer who has the lowest credit score.
|
SELECT cust_name FROM customer ORDER BY credit_score LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the name of the customer with the worst credit score?
|
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name, account type, and account balance of the customer who has the highest credit score.
|
SELECT cust_name , acc_type , acc_bal FROM customer ORDER BY credit_score DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the name, account type, and account balance corresponding to the customer with the highest credit score?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customer who has the highest amount of loans.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the name of the customer who has greatest total loan amount?
|
SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the state which has the most number of customers.
|
SELECT state FROM bank GROUP BY state ORDER BY sum(no_of_customers) DESC LIMIT 1
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Which state has the greatest total number of bank customers?
|
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. For each account type, find the average account balance of customers with credit score lower than 50.
|
SELECT avg(acc_bal) , acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the average account balance of customers with credit score below 50 for the different account types?
|
SELECT sum(acc_bal) , state FROM customer WHERE credit_score > 100 GROUP BY state
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. For each state, find the total account balance of customers whose credit score is above 100.
|
SELECT sum(acc_bal) , state FROM customer WHERE credit_score > 100 GROUP BY state
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the total account balance for customers with a credit score of above 100 for the different states?
|
SELECT sum(amount) , T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the total amount of loans offered by each bank branch.
|
SELECT sum(amount) , T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id GROUP BY T1.bname
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of the different bank branches, and what are their total loan amounts?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of customers who have more than one loan.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who have taken out more than one loan?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name and account balance of the customers who have loans with a total amount of more than 5000.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names and account balances for customers who have taken a total amount of more than 5000 in loans?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of bank branch that provided the greatest total amount of loans.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the name of the bank branch that has lent the greatest amount?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of bank branch that provided the greatest total amount of loans to customers with credit score is less than 100.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. 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?
|
SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name of bank branches that provided some loans.
|
SELECT DISTINCT T1.bname FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of the different banks that have provided loans?
|
SELECT DISTINCT T1.cust_name , T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the name and credit score of the customers who have some loans.
|
SELECT DISTINCT T1.cust_name , T1.credit_score FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the different names and credit scores of customers who have taken a loan?
|
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the the name of the customers who have a loan with amount more than 3000.
|
SELECT T1.cust_name FROM customer AS T1 JOIN loan AS T2 ON T1.cust_id = T2.cust_id WHERE amount > 3000
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of customers who have a loan of more than 3000 in amount?
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the city and name of bank branches that provide business loans.
|
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'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names and cities of bank branches that offer loans for business?
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the names of bank branches that have provided a loan to any customer whose credit score is below 100.
|
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
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What are the names of banks that have loaned money to customers with credit scores below 100?
|
SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the total amount of loans provided by bank branches in the state of New York.
|
SELECT sum(T2.amount) FROM bank AS T1 JOIN loan AS T2 ON T1.branch_id = T2.branch_id WHERE T1.state = 'New York'
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the total amount of money loaned by banks in New York state?
|
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the average credit score of the customers who have some loan.
|
SELECT avg(credit_score) FROM customer WHERE cust_id IN (SELECT cust_id FROM loan)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the average credit score for customers who have taken a loan?
|
SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. Find the average credit score of the customers who do not have any loan.
|
SELECT avg(credit_score) FROM customer WHERE cust_id NOT IN (SELECT cust_id FROM loan)
|
Given the Table bank having columns as branch_ID has datatype number, bname has datatype text, no_of_customers has datatype number, city has datatype text, state has datatype text which has branch_ID and Given the Table customer having columns as cust_ID has datatype text, cust_name has datatype text, acc_type has datatype text, acc_bal has datatype number, no_of_loans has datatype number, credit_score has datatype number, branch_ID has datatype number, state has datatype text which has cust_ID and Given the Table loan having columns as loan_ID has datatype text, loan_type has datatype text, cust_ID has datatype text, branch_ID has datatype text, amount has datatype number which has loan_ID. Answer the question by writing the appropriate SQL code. What is the average credit score for customers who have never taken a loan?
|
SELECT count(*) FROM ASSESSMENT_NOTES
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many assessment notes are there in total?
|
SELECT date_of_notes FROM Assessment_Notes
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the dates of the assessment notes?
|
SELECT count(*) FROM ADDRESSES WHERE zip_postcode = "197"
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many addresses have zip code 197?
|
SELECT count(DISTINCT incident_type_code) FROM Behavior_Incident
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many distinct incident type codes are there?
|
SELECT DISTINCT detention_type_code FROM Detention
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return all distinct detention type codes.
|
SELECT date_incident_start , date_incident_end FROM Behavior_Incident WHERE incident_type_code = "NOISE"
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What are the start and end dates for incidents with incident type code "NOISE"?
|
SELECT detention_summary FROM Detention
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return all detention summaries.
|
SELECT cell_mobile_number , email_address FROM STUDENTS
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Return the cell phone number and email address for all students.
|
SELECT email_address FROM Students WHERE first_name = "Emma" AND last_name = "Rohan"
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the email of the student with first name "Emma" and last name "Rohan"?
|
SELECT count(DISTINCT student_id) FROM Students_in_Detention
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. How many distinct students have been in detention?
|
SELECT gender FROM TEACHERS WHERE last_name = "Medhurst"
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the gender of the teacher with last name "Medhurst"?
|
SELECT incident_type_description FROM Ref_Incident_Type WHERE incident_type_code = "VIOLENCE"
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. What is the incident type description for the incident type with code "VIOLENCE"?
|
SELECT max(monthly_rental) , min(monthly_rental) FROM Student_Addresses
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the maximum and minimum monthly rental for all student addresses.
|
SELECT first_name FROM Teachers WHERE email_address LIKE '%man%'
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the first names of teachers whose email address contains the word "man".
|
SELECT * FROM Assessment_Notes ORDER BY date_of_notes ASC
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. List all information about the assessment notes sorted by date in ascending order.
|
SELECT city FROM Addresses ORDER BY city
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. List all cities of addresses in alphabetical order.
|
SELECT first_name , last_name FROM Teachers ORDER BY last_name
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the first names and last names of teachers in alphabetical order of last name.
|
SELECT * FROM Student_Addresses ORDER BY monthly_rental DESC
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find all information about student addresses, and sort by monthly rental in descending order.
|
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
|
Given the Table reference address types having columns as address_type_code has datatype text, address_type_description has datatype text which has address_type_code and Given the Table reference detention type having columns as detention_type_code has datatype text, detention_type_description has datatype text which has detention_type_code and Given the Table reference incident type having columns as incident_type_code has datatype text, incident_type_description has datatype text which has incident_type_code and Given the Table addresses having columns as address_id has datatype number, line_1 has datatype text, line_2 has datatype text, line_3 has datatype text, city has datatype text, zip_postcode has datatype text, state_province_county has datatype text, country has datatype text, other_address_details has datatype text which has address_id and Given the Table students having columns as student_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, cell_mobile_number has datatype text, email_address has datatype text, date_first_rental has datatype time, date_left_university has datatype time, other_student_details has datatype text which has student_id and Given the Table teachers having columns as teacher_id has datatype number, address_id has datatype number, first_name has datatype text, middle_name has datatype text, last_name has datatype text, gender has datatype text, cell_mobile_number has datatype text, email_address has datatype text, other_details has datatype text which has teacher_id and Given the Table assessment notes having columns as notes_id has datatype number, student_id has datatype number, teacher_id has datatype number, date_of_notes has datatype time, text_of_notes has datatype text, other_details has datatype text which has incident_id and Given the Table behavior incident having columns as incident_id has datatype number, incident_type_code has datatype text, student_id has datatype number, date_incident_start has datatype time, date_incident_end has datatype time, incident_summary has datatype text, recommendations has datatype text, other_details has datatype text which has detention_id and Given the Table detention having columns as detention_id has datatype number, detention_type_code has datatype text, teacher_id has datatype number, datetime_detention_start has datatype time, datetime_detention_end has datatype time, detention_summary has datatype text, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table student addresses having columns as student_id has datatype number, address_id has datatype number, date_address_from has datatype time, date_address_to has datatype time, monthly_rental has datatype number, other_details has datatype text which has NO_PRIMARY_KEY and Given the Table students in detention having columns as student_id has datatype number, detention_id has datatype number, incident_id has datatype number which has NO_PRIMARY_KEY. Answer the question by writing the appropriate SQL code. Find the id and first name of the student that has the most number of assessment notes?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.