Assignment No 2 SQL
Assignment No 2 SQL
SQL> create table branch_36 , branch varchar(25) primary key, branch_city varchar(15), assets
varchar(10));
SQL> create table branch_36 (branch_name varchar(25) primary key, branch_city varchar(15),assets
varchar(10));
1 Nigdi 12664
2 Akurdi 46532
CUST_NAME ACC_NO
------------------------------ ----------
Gaurav Jagtap 2
Aditya Joshi 1
Maheshwar3
CUST_NAME LOAN_NO
------------------------------ ---------------
Maheshwar456
BRANCH_NAME
-------------------------
Nigdi
Akurdi
GAdityain Bank
Q.2 Find all loan numbers for loans made at Akurdi Branch with loan amount > 12000
no rows selected
no rows selected
LOAN_NO
---------------
123
456
1169
Q3. Find all customers who have a loan from bank. Find their names,loan_no and loan
amount.
2 from customer_36 c
Maheshwar456 12645
2 from customer_36 c
6 order by c.cust_name;
Q6. Find all customers who have an account or loan or both at bank.
SQL> select distinct cust_name from depositor_36 union select distinct cust_name from
borrower_36;
CUST_NAME
------------------------------
Aditya Joshi
Mahesh
Gaurav Jagtap
2 from depositor_36 d
CUST_NAME
------------------------------
Gaurav Jagtap
Mahesh
Aditya Joshi
Q7. Find all customer who have account but no loan at the bank.
2 from depositor_36 d
no rows selected
2 from account_36 a
AVG_BALANCE
-----------
46532
2 from account_36
3 group by branch_name;
BRANCH_NAME AVG_BALANCE
------------------------- -----------
Nigdi 12664
GAdityain Bank 79536
Akurdi 46532
2 from account_36 a
4 group by a.branch_name;
BRANCH_NAME NUM_DEPOSITORS
------------------------- --------------
Nigdi 1
GAdityain Bank 1
Akurdi 1
Q11. Find the branches where average account balance > 12000.
2 from account_36
3 group by branch_name
4 having avg(balance)>12000;
BRANCH_NAME
-------------------------
Nigdi
GAdityain Bank
Akurdi
NUM_TUPLES
----------
TOTAL_AMOUNT
------------
69260
Q14. Delete all loans with loan amount between 1300 and 1500.
SQL> delete from loan_36 where amount between 1300 and 1500;
0 rows deleted.
Synonym created.
Q.17. Create sequence roll_seq and use in student table for roll_no column.
Table created.
ROLL_NO NAME
---------- --------------------
1 Aditya
2 Shyam
3 Prathmesh
4 Maheshwar
5 Rohan
6 Ganesh
6 rows selected.