You are on page 1of 2

ASSIGNMENT 3

CREATE TABLE cust_mastr16(


cust_no number(10) primary key,
fname varchar(10),
Iname varchar(10)
);

INSERT INTO cust_mastr16 VALUES(1, 'prg' ,'g');


INSERT INTO cust_mastr16 VALUES(2, 'aaa' ,'b');

CREATE TABLE add_dets161(


code_no number(10),
add1 varchar(13),
add2 varchar(13),
state varchar(10),
city varchar(10),
pincode number(8)
);

INSERT INTO add_dets161 VALUES(1,'SAI P','town','maha','pune',411061);

select * from add_dets161;

Q1) Retrieve the address of customer Fname as 'xyz' and Lname as 'pqr'
select fname, lname, add1, add2, state,city,pincode from cust_mastr16
inner join
add_dets161 on cust_mastr16.cust_no = add_dets161.cust_no
where fname =’xyz’ and lname = ‘pqr’;

CREATE TABLE acc_fd_cust_dets(


code_no number PRIMARY KEY,
acc_fd_no number,
Foreign key (code_no) references cust_mastr16(cust_no)
);

insert into acc_fd_cust_dets values(1, 1);

select * from acc_fd_cust_dets;

Create table fd_dets(


Fd_sr_no number(10) primary key,
amt number (10)
);
insert into fd_dets values(1, 4000);
3. List the customer holding fixed deposit of amount more than 5000
select cust_no, fname, Iname, amt from cust_mastr16
inner join acc_fd_cust_dets on cust_mastr16.cust_no = acc_fd_cust_dets.code_no
inner join fd_dets on acc_fd_cust_dets.acc_fd_no = fd_dets.fd_sr_no
where amt > 5000;

CREATE TABLE emp_mstr(


e_mpno number(10) PRIMARY KEY,
f_name varchar(10),
l_name varchar(10),
m_name varchar(10),
dept varchar(10),
desg varchar(10),
branch_no number(10));
insert into emp_mstr values (1,'P','G','R','CS','CC',11);

CREATE TABLE branch_mstr(


b_no number(10) primary key,
name varchar(10)
);
insert into branch_mstr VALUES(11,'xyz');

CREATE TABLE emp_mstr2(


e_mpno number(10) PRIMARY KEY,
f_name varchar(10),
I_name varchar(10),
m_name varchar(10),
dept varchar(10)
);
insert into cntc_dets2 values(2,'a','c');
insert into emp_mstr2 values(2,'b','e','f','cs');

select * from emp_mstr2 left join cntc_dets2 on emp_mstr2.e_mpno


=cntc_dets2.code_no;
select * from emp_mstr2 right join cntc_dets2 on emp_mstr2.e_mpno
=cntc_dets2.code_no;

CREATE TABLE cust_mstr2 (


cust_no number(10) PRIMARY KEY,
fname VARCHAR(10),
Iname VARCHAR(10)
);

CREATE TABLE add_dets2 (


code_no number(10) PRIMARY KEY,
pincode number(10)
);
INSERT INTO cust_mstr2 VALUES (1, 'xyz','pqr');

INSERT INTO add_dets2 VALUES (1,411061);

You might also like