Documente Academic
Documente Profesional
Documente Cultură
(
ACTNO VARCHAR2(5),
CNAME VARCHAR2 (18),
BNAME VARCHAR2(18),
AMOUNT NUMBER(8,2),
ADATE DATE
);
CREATE TABLE BRANCH
(
BNAME VARCHAR2(18),
CITY VARCHAR2(18)
);
CREATE TABLE CUSTOMER
(
CNAME VARCHAR2(19),
CITY VARCHAR2 (18)
);
CREATE TABLE BORROW
(
LOANNO VARCHAR2(5),
CNAME VARCHAR2(18),
BNAME VARCHAR2(18),
AMOUNT NUMBER(8,2)
);
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
DEPOSIT
VALUES ('100','ANIL','VRCE',1000.00,'1-MAR-95');
VALUES ('101','SUNIL','AJNI',5000.00, '4-JAN-96');
VALUES ('102','MEHUL','KAROLBAGH',3500.00,'17-NOV-95');
VALUES ('104','MADHURI','CHANDNI',1200.00,'17-DEC-95');
VALUES ('105','PRAMOD','M.G.ROAD',3000.00,'27-MAR-96');
VALUES ('106','SANDIP','ANDHERI',2000.00,'31-MAR-96');
VALUES ('107','SHIVANI','VIRAR',1000.00,'5-SEP-95');
VALUES ('108','KRANTI','NEHRU PLACE',5000.00,'2-JUL-95');
VALUES('109','NAREN','POWAI',7000.00,'10-AUG-95');
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
INTO
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
BRANCH
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INSERT
INTO
INTO
INTO
INTO
INTO
INTO
INTO
CUSTOMER
CUSTOMER
CUSTOMER
CUSTOMER
CUSTOMER
CUSTOMER
CUSTOMER
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
('VRCE','NAGPUR');
('AJNI','NAGPUR');
('KAROLBAGH','DELHI');
('CHANDNI','DELHI');
('DHARAMPETH','NAGPUR');
('M.G.ROAD','BANGLORE');
('ANDHERI','MUMBAI');
('VIRAR','MUMBAI');
('NEHRU PLACE','DELHI');
('POWAI','MUMBAI');
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
('ANIL','KOLKATA');
('SUNIL','DELHI');
('MEHUL','BARODA');
('MANDAR','PATNA');
('MADHURI','NAGPUR');
('PRAMOD','NAGPUR');
('SANDIP','SURAT');
INTO
INTO
INTO
INTO
INTO
INTO
BORROW
BORROW
BORROW
BORROW
BORROW
BORROW
VALUES
VALUES
VALUES
VALUES
VALUES
VALUES
('201','ANIL','VRCE',1000.00);
('206','MEHUL','AJNI',5000.00);
('311','SUNIL','DHARAMPETH',3000.00);
('321','MADHURI','ANDHERI',2000.00);
('375','PRAMOD','VIRAR',8000.00);
('481','KRANTI','NEHRU PLACE',3000.00);
ANIL
SUNIL
MEHUL
MADHURI
PRAMOD
SANDIP
SHIVANI
KRANTI
NAREN
VRCE
1000.00
AJNI
5000.00
KAROLBAGH
CHANDNI 1200.00
M.G.ROAD
ANDHERI 2000.00
VIRAR 1000.00
NEHRU PLACE
POWAI 7000.00
1995-MAR-01
1996-JAN-04
3500.00 1995-NOV-17
1995-DEC-17
3000.00 1996-MAR-27
1996-MAR-31
1995-SEP-05
5000.00 1995-JUL-02
1995-AUG-10
ANIL
MEHUL
SUNIL
MADHURI
PRAMOD
KRANTI
VRCE
1000.00
AJNI
5000.00
DHARAMPETH
3000.00
ANDHERI 2000.00
VIRAR 8000.00
NEHRU PLACE
3000.00
KOLKATA
DELHI
BARODA
PATNA
NAGPUR
NAGPUR
SURAT
MUMBAI
MUMBAI
MUMBAI
DHARAMPETH
NAGPUR
M.G.ROAD
BANGLORE
ANDHERI MUMBAI
VIRAR MUMBAI
NEHRU PLACE
DELHI
POWAI MUMBAI
--(5)-- list account no. and amount of depositors
select ACTNO, AMOUNT from DEPOSIT;
100
101
102
104
105
106
107
108
109
1000.00
5000.00
3500.00
1200.00
3000.00
2000.00
1000.00
5000.00
7000.00
1000.00
5000.00
3500.00
1200.00
3000.00
2000.00
1000.00
5000.00
7000.00
ANDHERI
VIRAR
NEHRU PLACE
POWAI
--(9)-- list name of borrowers
select CNAME from BORROW;
ANIL
MEHUL
SUNIL
MADHURI
PRAMOD
KRANTI
--(10)-- list name of customer living in nagpur city
select CNAME from CUSTOMER
where CITY='NAGPUR';
MADHURI
PRAMOD
--(11)-- list name of depositors having amount greater than 4000
select CNAME from DEPOSIT
where AMOUNT>=4000;
SUNIL
KRANTI
NAREN
--(12)-- list account date of customer ANIL
select ADATE from DEPOSIT
where CNAME='ANIL';
1995-MAR-01
--(13)-- list name of all branches located at MUMBAI city
select BNAME from BRANCH
where CITY='MUMBAI';
ANDHERI
VIRAR
POWAI
--(14)-- list name of borrower having loan no. 206
select CNAME from BORROW
where LOANNO=206;
MEHUL
--(15)-- list name of depositor having account at VRCE
select CNAME from DEPOSIT
where BNAME='VRCE';
ANIL
--(16)-- list name of all branches located at delhi city
select BNAME from BRANCH
where CITY='DELHI';
KAROLBAGH
CHANDNI
NEHRU PLACE
--(17)-- list name of customer who open account after 1-dec-95
select CNAME from DEPOSIT
where ADATE>'1-dec-95'
SUNIL
MADHURI
PRAMOD
SANDIP
--(18)-- list account no. and deposit amount of customer having account opened b
etween dates 1-12-95 and 1-6-95
select ACTNO, AMOUNT,ADATE from DEPOSIT
where ADATE between '01-JUN-95' and '01-DEC-95'
102
107
108
109
3500.00
1000.00
5000.00
7000.00
1995-NOV-17
1995-SEP-05
1995-JUL-02
1995-AUG-10
ANIL
VRCE
1000.00 1995-MAR-01
--(21)-- list name customer having leaving in mumbai and branch city DELHI
select d.CNAME
from DEPOSIT d
join BRANCH b
on d.BNAME=b.BNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where c.CITY='MUMBAI' and b.CITY='DELHI'
KRANTI
--(22)-- list name of customer having leaving city as their branch city
select d.CNAME
from DEPOSIT d
join BRANCH b
on d.BNAME=b.BNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where c.CITY=b.CITY
SHIVANI
NAREN
--(23)-- list names of customer who are BORROWERS as well as Depositors and havi
ng living city NAGPUR
select d.CNAME
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where c.CITY='NAGPUR';
MADHURI
PRAMOD
-dddd-(24)-- list names of customers who are depositors and have same branch cit
y as that of Sunil
select d.CNAME
from DEPOSIT d
join BRANCH b
on d.BNAME=b.BNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where b.CITY=(select city from CUSTOMER where CNAME='SUNIL');
MEHUL
MADHURI
KRANTI
-dddd-(25)-- list names of depositors having same living city as that of SHIVANI
and having Depositors Amount Greater than 2000
select d.CNAME
from DEPOSIT d
join BRANCH b
on d.BNAME=b.BNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where b.CITY=(select CITY from CUSTOMER where CNAME='SHIVANI')
AND D.AMOUNT>2000;
NAREN
--(26)-- list names of Borrowers having deposit amount greater than 1000 and loa
n amount greater than 2000
select b.CNAME
from BORROW b
join DEPOSIT d
on b.CNAME=d.CNAME
where d.AMOUNT>1000 and b.AMOUNT>2000;
SUNIL
MEHUL
PRAMOD
KRANTI
-dddd-(27)-- list names of depositors having the same branch as branch of SUNIL
select d.CNAME
from DEPOSIT d
join BRANCH b
on d.BNAME=b.BNAME
where b.BNAME=(select BNAME from DEPOSIT where CNAME='SUNIL');
SUNIL
--(28)-- list names of BORROWERS having LOAn Amount Greater than the Loan Amount
of Anil
select CNAME
from BORROW
where AMOUNT>(select AMOUNT
from BORROW
where CNAME='ANIL');
MEHUL
SUNIL
MADHURI
PRAMOD
KRANTI
-dddd-(29)-- list names of customer living in the city where branch of depositor
s sunil is located
--(30)-- list LOANNO and LOAN AMOUNT of borrowers having the same branch as that
of depositors Sunil
select b.LOANNO,b.AMOUNT
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where b.BNAME=(select BNAME
from DEPOSIT
where CNAME='SUNIL');
LOANNO AMOUNT
206
5000.00
--(31)-- list LOANNO loan Amount ACCOUNT NO and Deposit AMOUNT of customer livin
g in Nagpur
select b.LOANNO as 'Loan No', b.AMOUNT as 'Loan Amount',d.ACTNO as 'Deposite Acc
ount No',d.AMOUNT as 'Deposite Amount'
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where c.CITY='NAGPUR';
Loan No Loan Amount
Deposite Account No
321
2000.00
104
375
8000.00
105
Deposite Amount
1200.00
3000.00
--(32)-- list loanno loan amount account no and deposit amount of customer havin
g deposit branch located in DELHI
select b.LOANNO as 'Loan No', b.AMOUNT as 'Loan Amount',d.AMOUNT as 'Deposite Am
ount'
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
join BRANCH bb
on d.BNAME=bb.BNAME
where bb.CITY='DELHI';
Loan No Loan Amount
Deposite Amount
206
5000.00
3500.00
321
2000.00
1200.00
481
3000.00
5000.00
-dddd-(33)-- list loanno loan amount account no and deposit amount branch name b
ranch city and living city of PRAMOD
select b.LOANNO as 'Loan No', b.AMOUNT as 'Loan Amount',d.ACTNO as 'Deposite No'
,d.AMOUNT as 'Deposite Amount' ,
d.BNAME as 'Deposite Branch', bb.CITY as 'Branch City', c.CITY as 'Customer City
'
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
join BRANCH bb
on d.BNAME=bb.BNAME
where c.CITY=(select CITY
from CUSTOMER
where CNAME='PRAMOD') and bb.BNAME=(select bb1.CITY fr
om DEPOSIT d1
join CUSTOMER c1
on d1.CNAME=c1.CNAME
join BRANCH bb1
on d1.BNAME=bb1.BNAME
where c1.CNAME='PRAMOD');
--(34)-- list deposit details and loan details of customer in the city where PRA
MOD is living
select d.ACTNO as 'Loan No',d.ADATE,d.AMOUNT as 'Deposite Amount' ,
d.CNAME,d.BNAME as 'Deposite Branch',b.LOANNO as 'Loan No',b.AMOUNT as 'Loan Amo
unt',
b.BNAME 'Borrow Branch'
from DEPOSIT d
join BORROW b
on d.CNAME=b.CNAME
join CUSTOMER c
on d.CNAME=c.CNAME
where c.CITY=(select CITY from CUSTOMER where CNAME='PRAMOD');
Deposite No
Loan Amount
104
2000.00
105
8000.00
ADATE
Deposite Amount
Borrow Branch
1995-12-17
1200.00
ANDHERI
1996-03-27
3000.00
VIRAR
CNAME
MADHURI CHANDNI
PRAMOD M.G.ROAD
321
375
--(35)-- list name of depositors having amount greater than 1000 and having the
same living city as PRAMOD
select d.CNAME
from DEPOSIT d
join CUSTOMER c
on d.CNAME=c.CNAME
where d.AMOUNT>1000 and c.city=(select CITY from CUSTOMER where CNAME='PRAMOD');
MADHURI
PRAMOD