Assignment-5
Assignment-5
1. Write the expression for the following set of queries in SQL, based on the set of schemas
of Assignment (4), using concept of sub query.
a) Find out the name, phone_no and cust_no of customer having Account_no “A0004”.
b) Find out the loan_amount and branch code of customer named “YASH SARAF”.
c) Find out the name of the customer who has not taken any loan.
d) Find out the account_no and Balance of customer with cust_no = “C0010”.
e) Find out the branch_city where “ASLESHA TIWARI” has taken a loan.
f) Find out the installment details of customer named “ANKITA SINGH”.
g) Find out the branch name and branch city, in which “ABHIJIT MISHRA” has an account.
h) Create a table named ACCOUNT_TYPE from ACCOUNT table with two columns named
as ACCOUNT_NO and TYPE without taking any records from ACCOUNT table.
i) Insert the account no and type from ACCOUNT table into the ACCOUNT_TYPE table
whose balance is less than 50000.
j) UPDTAE the account type to FD in ACCOUNT_TYPE table for the customer with
CUST_NO equal to C0007.
k) Delete from ACCOUNT_TYPE table the details of account whose balance is less than
20000.
l) Find out the name of the customers who have both an account and loan at the bank.
m) Find out the name of all customers who have a loan at the bank but don’t have an account
at the bank.
n) Find out the name of the customers having more than one account.
o) Find out the details of the account having same type and branch_code as the account_no
A0001.
p) Display the customer number and the number of accounts, which has more than one
account without using having clause. (Use sub query in the form clause)
q) Display the name of the customers and their number of accounts. (Use scalar subquey)
r) Display the branch codes and average account balance of those branches where the
average account balance is greater than 60000. (Use sub query in the form clause)
s) Find out the account_no that has grater balance than some accounts of type FD. (Use
>some clause)
t) Find out the account_no that has grater balance than all accounts of type FD. (Use >all
clause)
u) Display the details of the branch in which some loans are taken. (Use exist clause)
v) Display the details of the loan for which no instalments are paid. (Use not exist clause)
w) Increase all accounts with balance over 80000 by 6%, and all other accounts receive 5%.
(Use case statement)
2. Write the expression for the following set of queries in SQL, based on the set of schemas
of Assignment (4), using concept of join.
a) Find out the Loan_nos where the loans are taken from any branch with branch_city
=MUMBAI.
b) Find the Type of the accounts available in any branch with branch_city =DELHI.
c) Find out the Name and Ph_no of customers who have account balance more than 100000.
d) Find out Installment_no and Installment amount of customer with Name= RAJ ANAND
SINGH.
e) Find out the Name of the customers who do not have account of Type=SB.
f) Find out the Name of the customers who have paid installments of Amount 50000 against
his/her loan.
g) Find out the Ph_no of customers having account at branch with Branch_name equal to
SALTLAKE.
h) Find out the Branch_name and Branch_city where customer with Name=ABHIJIT
MISHRA has his account.
i) Find out the Types of account and the account Balance of customer with
Name=’SWAROOP RAY’
j) Display the name and the number of accounts of the customers, who have more than one
account.
k) Find all the account_no with the maximum balance. (use with clause)
l) Find all branch codes where the total balance is greater than the average of the total
balance at all departments. (use with clause)
3. Write the expression for the following set of queries in SQL, based on the set of schemas
of Assignment (4), using concept of view.
b) Create a View BRANCH_LOCATE having columns Branch Name and Branch City
having branch city not in KOLKATA.
c) Create a view LOAN_M with column customer name, loan no. and loan amount
representing the details of all customers having loan in any branch of MUMBAI.
Display the name of the customers taking loan amount between 50000 to 500000
in any branch of MUMBAI. (Write the query using the view LOAN_M and
without using the view)