0% found this document useful (0 votes)
8 views

Assignment-5

The document outlines Laboratory Assignment 5 for the subject 'Introduction to Databases' (CSE 3151), focusing on SQL queries involving subqueries, joins, and views. It includes a series of tasks requiring the creation and manipulation of SQL queries to extract and manage data related to customers, accounts, and loans. The assignment emphasizes practical application of SQL concepts through various query scenarios and database operations.

Uploaded by

Milind Jha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Assignment-5

The document outlines Laboratory Assignment 5 for the subject 'Introduction to Databases' (CSE 3151), focusing on SQL queries involving subqueries, joins, and views. It includes a series of tasks requiring the creation and manipulation of SQL queries to extract and manage data related to customers, accounts, and loans. The assignment emphasizes practical application of SQL concepts through various query scenarios and database operations.

Uploaded by

Milind Jha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Laboratory Assignments

Subject: Introduction to Databases


Subject code: CSE 3151

Assignment 5: Subqueries, Joins and View

Objective of this Assignment:

 To write SQL query using concept of sub query, join, view.

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.

a) Create a view CUSTOMER_ACC_DETAILS consisting of Customer_No, Name with


Account number and Balance.
 Check the structure of the view.
 Access the data from the view.
 Delete the information of the customer having CUST_NO C0004 from the view.
Check whether the deletion has done any changes in the base tables.
 Insert the information of the customer having CUST_NO C0004 to the view
again.
 Update the view CUSTOMER_ACC_DETAILS to include customer’s phone no.
 Delete the view with its structure.

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)

d) Create a view ALL_CUSTOMERS consisting of branches and their customers.


 Find all customers WHO HAVE AN ACCOUNT OR LOAN IN JUHU
BRANCH.
 Display the number of customers of each branch.

You might also like