Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

1

Roll No:-
Name:-
Slip No:-1
*************************************************************************************
create table Customer (cust_no number(5) primary key, cust_name varchar2(20), address varchar2(20), city
varchar2(20));

insert into Customer values(1,'John','M.G.Road','pune');
insert into Customer values(2,'Raj',' ABC Road','Sangali');
insert into Customer values(3,'Rohit','F.C.Road','Wagoli');
insert into Customer values(4,'Ramesh','5 kandil','nashik');

create table Loan (loan_no number(5) primary key , loan_amt number(6));

insert into Loan values(11,1500000);
insert into Loan values(12,3500000);
insert into Loan values(13,500000);
insert into Loan values(14,900000);

create table Cust_Loan(cust_no number(5) references Customer(cust_no),loan_no number(5) references
Loan(loan_no));

insert into Cust_Loan(1,14);
insert into Cust_Loan values(2,13);
insert into Cust_Loan values(3,12);
insert into Cust_Loan values(4,11);

2

A) Find details of all customers whose loan is greater than 10 lakhs

select cust_name,address,city,loan_amt from Customer,Loan,Cust_Loan
where Cust_Loan.cust_no=Customer.cust_no
and Cust_Loan.loan_no=Loan.loan_no
and loan_amt > 1000000;
B) List all customers whose name starts with 'Ra'.

select cust_name from Customer,Loan,Cust_Loan
where Cust_Loan.cust_no=Customer.cust_no
and Cust_Loan.loan_no=Loan.loan_no
and cust_name like 'Ra%'

C) List names of all customers in descending order who has taken a loan in Nasik city.

select cust_name from Customer,Loan,Cust_Loan
where Cust_Loan.cust_no=Customer.cust_no
and Cust_Loan.loan_no=Loan.loan_no
and city='nashik'
order by cust_name desc;

D) Display customer details having maximum loan amount.

select cust_name,city,address,loan_amt from Customer,Loan,Cust_Loan
where Cust_Loan.cust_no=Customer.cust_no
and Cust_Loan.loan_no=Loan.loan_no
and loan_amt=(select max(loan_amt) from Loan);

E) Calculate total of all loan amount

select sum(loan_amt) from Customer,Loan,Cust_Loan
where Cust_Loan.cust_no=Customer.cust_no
and Cust_Loan.loan_no=Loan.loan_no;

3

Roll No:-
Name:-
Slip No:-02
*************************************************************************************
create table department(dept_no number(5) primary key,dept_name varchar2(20),location varchar2(20));

insert into department values(1,'Computer','shirur');
insert into department values(2,'HR','satara');
insert into department values(3,'SAlES','Pune');


create table Employee(emp_no number(5) primary key, emp_name varchar2(20), address varchar2(20), salary
number(10), designation varchar2(20),dept_no number(10) references department(dept_no));

insert into Employee values(11,'Prashant','shirur',30000,'ABC',2);
insert into Employee values(12,'Pratap','Pimpari',5000,'AB',1);
insert into Employee values(13,'Deepak','Sangali',15000,'AB',1);
insert into Employee values(14,'Manoj','Parner',25000,'ABcd',3);

4

A) Find total salary of all computer department employees.

select sum(salary) from department , Employee
where department.dept_no=Employee.dept_no
and dept_name='Computer';

B) Find the name of department whose salary is above 10000.

select dept_name from department , Employee
where department.dept_no=Employee.dept_no
and salary < 10000;

C) Count the number of employees in each department.

select dept_name,count(emp_name)
from department,Employee
where department.dept_no=Employee.dept_no
group by dept_name;

D) Display the maximum salary of each department.

select dept_name,max(salary)
from department , Employee
where department.dept_no=Employee.dept_no
group by dept_name;

E) Display department wise employee list.

select dept_name,emp_name
from department , Employee
where department.dept_no=Employee.dept_no
order by dept_name;

5

Roll No:-
Name:-
Slip No:-03
*************************************************************************************
create table Department (dno number(5) primary key, dname varchar2(20), HOD varchar2(20));
insert into Department values(1,'COMP','Borase');
insert into Department values(2,'BSC','Sathe');
insert into Department values(3,'CHM','Khod');

create table Project (pno number(5) primary key, pname varchar2(20), start_date date, budget number(7),
status varchar2(20),dno number(5) references Department(dno));
insert into Project values(11,'BUS','10-feb-2009',20000,'complete',1);
insert into Project values(12,'WINE','15-march-2009',25000,'incomplete',1);
insert into Project values(13,'HOSPITAL','10-jan-2009',70000,'complete',2);
insert into Project values(14,'MOTOR','10-feb-2010',45000,'complete',3);


6


A) List the project name and department details worked in projects that are Complete.


select pname,dname,HOD
from Department,Project
where Department.dno=Project.dno
and status='complete';

B) Display total budget of each department.

select dname,sum(budget)
from Department,Project
where Department.dno=Project.dno
Group by dname;

C) Display incomplete project of each department

select pname,dname,HOD,budget
from Department,Project
where Department.dno=Project.dno and status='incomplete';

D) Find the names of departments that have budget greater than 50000

select d_name
from Department,Project
where Department.dno=Project.dno
and budget > 50000;

E) Display all project working under 'Mr.Desai'.

select pname
from Department,Project
where Department.dno=Project.dno
and HOD='Mr.Desai';

7


Roll No:-
Name:-
Slip No:-05
*************************************************************************************
create table Book (Book_no number(5) primary key, title varchar2(20), author varchar2(20), price number(5),
year_published number(10));

insert into Book values(1,'c','dennis',150,2013);
insert into Book values(2,'cpp','john',250,2013);
insert into Book values(3,'java','gomes',350,2011);
insert into Book values(4,'vb','B.Gate',100,2012);

create table Customer1 (cid number(5) primary key, cname varchar2(20), addr varchar2(20));

insert into Customer1 values(11,'prashant','surat');
insert into Customer1 values(12,'Amol','Mumbai');
insert into Customer1 values(13,'Kaushik','Nagpur');
insert into Customer1 values(14,'Shoaib','Nagar');

create table Book_Cust(Book_no number(5)references Book(Book_no),cid number(5) references
Customer1(cid));

insert into Book_Cust values(1,14);
insert into Book_Cust values(2,13);
insert into Book_Cust values(3,12);
insert into Book_Cust values(4,11);


8

A) Display customer details from 'Mumbai'.

select cname,addr,title,author,price,year_published
from Book,Customer1,Book_Cust
where Book_Cust.cid=Customer1.cid
and Book_Cust.Book_no=Book.Book_no
and addr='Mumbai';

B) Display author wise details of book

select title,author,price,year_published from Book,Customer1,Book_Cust
where Book_Cust.cid=Customer1.cid
and Book_Cust.Book_no=Book.Book_no
order by author asc;
C) Display all customers who have purchased the books published in the year 2013.

select distinct(cname),addr from Book,Customer1,Book_Cust
where Book_Cust.cid=Customer1.cid
and Book_Cust.Book_no=Book.Book_no
and year_published=2013;

D) Display customer name that has purchased more than 3 books.

select cname,addr from Book,Customer1,Book_Cust
where Book_Cust.cid=Customer1.cid
and Book_Cust.Book_no=Book.Book_no
and quantity>3;

E) Display book names having price between 100 and 200 and published in the year 2013

select title from Book,Customer1,Book_Cust
where Book_Cust.cid=Customer1.cid
and Book_Cust.Book_no=Book.Book_no
and price between 100 and 200
and year_published=2013;

9


Roll No:-
Name:-
Slip No:-06
*************************************************************************************
Create Table Property(P_No number(7)Primary key,P_Desc Varchar(10),P_Area Varchar(10),
P_Rate Varchar(10));
Insert Into Property Values(1,'Land','Chinchwad','70000');
Insert Into Property Values(2,'Hotel','Shirur','1500');
Insert Into Property Values(3,'Land','Pune','1000');
Insert Into Property Values(4,'Building','Satara','15000');
Insert Into Property Values(5,'Land','Nigadi','50000');

Create Table Owner(O_Id Number(7) Primary key,O_Name Varchar(20),O_Add Varchar(20),O_Ph_No
Varchar(20),P_No Number (7) References Property(P_No));

Insert Into Owner Values(1,'Prashant','Pune','9890094887','5');
Insert Into Owner Values(2,'Vikas','Shirur','9890094885','5');
Insert Into Owner Values(3,'Mr.Patil','Satara','9988778855','3');
Insert Into Owner Values(4,'Arun','Shirur','99994455','1');
Insert Into Owner Values(5,'Sunil','Nighoj','9988754612','4');
Insert Into Owner Values(6,'Prashant','Shirur','9890094885',1);

10

A) Display area wise property details.
Select Distinct(P_Area),P_Desc,P_Rate
From Property,Owner
Where Property.P_No=Owner.P_No
Order by P_Area;

B) Display property owned by 'Mr.Patil' having minimum rate.

Select O_Name,P_Rate
From Property,Owner
Where Property.P_No=Owner.P_No
AND p_rate=(select MIN(P_Rate) from Property);

C) Display all properties with owner name that having highest rate of properties located in Chinchwad area.
Select O_Name,P_Rate,P_Area
From Property,Owner
Where Property.P_No=Owner.P_No
AND P_Area='Chinchwad'
AND P_Rate=(Select MAX(P_Rate)From Property);

D) Display owner wise property detail.

Select O_Name,P_Desc,P_Area,P_Rate
From Owner,Property
Where Property.P_No=Owner.P_No
Order by o_id;

E) Display owner name having maximum no. of properties.

Select O_Name,COUNT(O_Name)
From Property,Owner
Where Property.P_No=Owner.P_No
Group by O_Name
Having O_Name=(select MAX(O_Name)From Owner);

11

Roll No:-
Name:-
Slip No:-07
*************************************************************************************
create table employee31(e_no number(5) primary key,e_name varchar(20),e_skill varchar(20),e_payrate
number(7));
insert into employee31 values(1,'kunal','chef',25000);
insert into employee31 values(2,'kushal','waiter',20000);
insert into employee31 values(3,'ketan','waiter',25000);
insert into employee31 values(4,'sanjeev','chef',50000);
insert into employee31 values(5,'raman','waiter',25000);
create table position(p_no number(5)primary key,skill varchar(20));
insert into position values(201,'chef');
insert into position values(202,'waiter');
insert into position values(203,'chef');
insert into position values(204,'waiter');
insert into position values(205,'chef');
create table emp_post(e_no number(5) references employee31(e_no),p_no number(5) references
position(p_no),shift varchar(10));

insert into emp_post values(1,201,'yes');
insert into emp_post values(2,202,'no');
insert into emp_post values(4,203,'yes');
insert into emp_post values(3,204,'yes');

A) Find the names and rate of pay all employees who allocated a duty.

select e_name,e_payrate
from employee31,position,emp_post
where employee31.e_no=emp_post.e_no
and position.p_no=emp_post.p_no
and shift='yes';

12


B) Give employee number who are working at posting_no. 201, but dont have the skills of waiter.

select e_name,
from employee31,position,emp_post
where employee31.e_no=emp_post.e_no
and position.p_no=emp_post.p_no
and p_no=201;

C) Display a list of names of employees who have skill of chef and who has assigned a duty.

select e_name
from employee31,position,emp_post
where employee31.e_no=emp_post.e_no
and position.p_no=emp_post.p_no
and skill='chef'
and shift='yes';

D) Display emp_no and dates for all employees who are working on Tuesday and at least one other day.







E) Display shiftwise employee details

Select e_name,e_skill ,e_payrate
from employee31, position, emp_post
where employee31.e_no=emp_post.e_no
and position.p_no=emp_post.p_no
order by shift;

13

Roll No:-
Name:-
Slip No:-08
*************************************************************************************
create table bill(b_id number(5)primary key,b_day varchar(20),b_table_no varchar(20),b_total varchar(20));

insert into bill values(301,'sunday',55,20);
insert into bill values(302,'monday',57,80);
insert into bill values(303,'thursday',75,45);
insert into bill values(304,'wednsday',85,54);
insert into bill values(305,'friday',100,200);

create table menu(d_id number(5)primary key,d_desc varchar(20),d_price varchar(20));

insert into menu values(1,'spicy',100);
insert into menu values(2,'sweet',200);
insert into menu values(3,'cold',300);
insert into menu values(4,'hot',400);
insert into menu values(5,'fastfood',500);
insert into menu values(6,'pizza',600);

create table bil_menu(b_id number(5)references bill(b_id),d_id number(5) references menu(d_id),quantity
number(10),b_date date);

insert into bil_menu values(301,1,5,'08jan2013');
insert into bil_menu values(302,2,9,'01dec2013');
insert into bil_menu values(303,3,8,'08feb2013');
insert into bil_menu values(304,4,7,'08may2013');
insert into bil_menu values(305,5,12,'08jun2013');

14


A) Display receipt which includes bill_no with Dish description, price, quantity and total amount of each
menu.
select sum(d_price)
from bill,menu,bil_menu
where bill.b_id=bil_menu.b_id
and menu.d_id=bil_menu.d_id;

B) Find total amount collected by hotel on date 08/01/2013
select sum(d_price)
from bill,menu,bil_menu
where bill.b_id=bil_menu.b_id
and menu.d_id=bil_menu.d_id
and b_date='08jan2013';

C) Count number of menus of billno 301.
select count(d_desc)
from bill,menu,bil_menu
where bill.b_id=bil_menu.b_id
and menu.d_id=bil_menu.d_id
and b_id=301;

D) Display menu details having price between 100 and 500.
select count(d_desc)
from bill,menu,bil_menu
where bill.b_id=bil_menu.b_id
and menu.d_id=bil_menu.d_id
between b_price=100 and 500;

E) Display total number of bills collected from each table on 01/12/2013
select count(b_id),b_tableno
from bill,menu,bil_menu
group by b_tableno
Having b_date=01-dec-2013;

15

Roll No:-
Name:-
Slip No:-09
*************************************************************************************
create table Musician (mno number(5) primary key, mname varchar2(20), addr varchar2(20), phno
number(10));

insert into Musician values(1,'prashant','shirur',9890157615);
insert into Musician values(2,'pratap','satara',9403942654);
insert into Musician values(3,'A.R.Rehman','pune',9028326598);
insert into Musician values(4,'Pritam','surat',9860548123);

create table Album (a_no number(5) primary key,title varchar2(20), copy_right_date date, format
varchar2(20),mno number(5) references Musician(mno));

insert into Album values(11,'Thriller','10-feb-1982','pop',1);
insert into Album values(12,'Back in Black','15-june-1980',' Hard Rock',2);
insert into Album values(13,'Dangerous','20-april-2000','Audio',1);
insert into Album values(14,'Jay Ho','10-dec-2011','pop',3);
insert into Album values(15,'Birfi','11-feb-2012','soft',4);

16


A) Display all albums composed by A R Rehman.

select title from Album,Musician
where Musician.mno= Album.mno
and mname ='A.R.Rehman';

B) Display musician details who have composed Audio album

select mname,addr,phno,title from Album,Musician
where Musician.mno= Album.mno
and format ='Audio';

C) Find all musicians who have composed maximum albums.

select mname,count(title) from Album,Musician
where Musician.mno= Album.mno
group by mname;

D) Display musician wise album details.

select mname,title,copy_right_date ,format from Album,Musician
where Musician.mno= Album.mno
order by mname asc

E) Display Musian details from 'Pune'

select mname,title,copy_right_date ,format from Album,Musician
where Musician.mno= Album.mno
and addr='pune'


17

Roll No:-
Name:-
Slip No:-15
*************************************************************************************

create table employee5(e_no number(5)primary key,e_name varchar(10),e_dept_name varchar(15),e_salary
number(15));
insert into employee5 values(1,'Ramesh','computer',70000);
insert into employee5 values(2,'Suresh','management',60000);
insert into employee5 values(3,'Ram','research',50000);
insert into employee5 values(4,'Shyam','finance',30000)
insert into employee5 values(5,'Monu','history',20000);
insert into employee5 values(6,'Tinu','computer',10000);

create table project6(p6_no number(5)primary key,p6_name varchar(15),p6_budget number(15));
insert into project6 values(11,'voice recog',50000);
insert into project6 values(12,'P.D',20000);
insert into project6 values(13,'voice recog',60000);
insert into project6 values(14,'acconting',40000);
insert into project6 values(15,'world war',10000);
insert into project6 values(16,'robot',5000);

create table emp_proj6(e_no number(5)references employee5(e_no),p6_no number(5) references
project6(p6_no));
insert into emp_proj6 values(1,11);
insert into emp_proj6 values(2,12);
insert into emp_proj6 values(3,13);
insert into emp_proj6 values(4,14);
insert into emp_proj6 values(5,15);
insert into emp_proj6 values(2,13);

18

A) List the name of employee and departent having salary > 50000.
select e_name,e_dept_name
from employee5,project6,emp_proj6
where employee5.e_no = emp_proj6.e_no
and project6.p6_no = emp_proj6.p6_no
and e_salary>50000;

B) List names of all employees who works with Ramesh on same project.
Select e_name,p6_name
From employee5,project6,emp_proj6
Where employee5.e_no = emp_proj6.e_no
AND project6.p6_no = emp_proj6.p6_no
AND p6_name IN(Select p6_name
From employee5,project6,emp_proj6
Where employee5.e_no = emp_proj6.e_no
AND project6.p6_no = emp_proj6.p6_no
AND e_name='Ramesh');

C) Find the names of employees who are working on project having budget greater than 30000.

select e_name
from employee5,project6,emp_proj6
where employee5.e_no = emp_proj6.e_no
and project6.p6_no = emp_proj6.p6_no
and p6_budget>30000;

D) List name of department that have at least two projects under them.

Select e_dept_name,COUNT(p6_name)
From employee5,project6,emp_proj6
Where employee5.e_no = emp_proj6.e_no
AND project6.p6_no = emp_proj6.p6_no
Group by e_dept_name
Having COUNT(p6_name)>=2;
19


E) Update budget of a project done by employees of Computer Department by 15
update project6
set p6_budget=p6_budget * 0.15
Where p6_budget IN(Select e_dept_name
From employee5,project6,emp_proj6
Where employee5.e_no = emp_proj6.e_no
AND project6.p6_no = emp_proj6.p6_no
and e_dept_name='computer');




20

Roll No:-
Name:-
Slip No:-16
*************************************************************************************
Create Table Branch(B_No number(7)primary key ,B_Name varchar(20),B_City varchar(20),B_Assets
varchar(20));

Insert into Branch values(1,'Kharadi','Pune',900000);
Insert into Branch values(2,'Aundh','Pune',1200000);
Insert into Branch values(3,'Nagar','A_Nager',5000000);
Insert into Branch values(4,'Andheri','Mumbai',3000000);
Insert into Branch values(5,'Shirur','Shirur',2000000);

Create Table Account(Acc_No number(7)primary key ,A_Balance varchar(20),B_No number(7) references
Branch(B_No));

Insert into Account values(11,100000,1);
Insert into Account values(22,250000,2);
Insert into Account values(33,30000,4);
Insert into Account values(44,80000,5);
Insert into Account values(55,40000,5);
Insert into Account values(66,750000,1);
Insert into Account values(77,300000,2);
Insert into Account values(88,40000,3);
Insert into Account values(99,15000,3);

21


A) Find the maximum account balance of each branch.
select MAX(A_Balance),B_Name
from Branch,Account
where
Branch.B_No=Account.B_No
Group by B_Name;

B) Find branches where average account balance is more than 30000.
select AVG(A_Balance),B_Name
from Branch,Account
where
Branch.B_No=Account.B_No
Group by B_Name
having AVG(A_Balance)>30000;

C) Find names of all branches that have assets value greater than that of each branch in pune.

select distinct B_Name,b_assets
from Branch,Account
where
Branch.B_No=Account.B_No
and B_Assets>All
(select B_Assets
from Branch,Account
where B_City='pune');

D) Decrease 3% balance on account whose balance is greater than 100000.

update Account
SET A_Balance=A_Balance-0.03
where
A_Balance>100000;

22


E) Display details of branch whose city starts from 'A'.

select *
from Branch,Account
where
Branch.B_No=Account.B_No
and
B_name like 'A%';


23

Roll No:-
Name:-
Slip No:-17
*************************************************************************************
create table donar(d_no number(20)primary key,d_name varchar(20),d_city varchar(20));

insert into donar values(1,'sonu','shirur');
insert into donar values(2,'teju','shikrapur');
insert into donar values(3,'siya','nagar');
insert into donar values(4,'tanu','pune');
insert into donar values(5,'monu','bid');


create table blood11(b_no number(10) primary key,b_group varchar(20),quantity number(10),d_of_collection
varchar(20),d_no number(20)references donar(d_no));

insert into blood11 values(106,'A+ve',5,'25th dec.2013',2);
insert into blood11 values(107,'B+ve',5,'22th dec.2012',4);
insert into blood11 values(108,'A',5,'4th mar.2011',1);
insert into blood11 values(109,'B',5,'5th aug.2010',1);
insert into blood11 values(110,'o',5,'25th jan.2013',2);


24


A) Display total blood quantity collected on 25th December 2013.

select sum(quantity)
from donar,blood11
where donar.d_no=blood11.d_no
and d_of_collection='25th dec.2013';

B) Display total blood donated by each donor

select sum(quantity)
from donar,blood11
where donar.d_no=blood11.d_no;

C) Display Donor details having blood group 'A+ve'.

select d_name,d_city
from donar,blood11
where donar.d_no=blood11.d_no
and b_group='A+ve';

D) Display the donor who has donated blood more than two times.

select distinct d_name
from donar,blood11
where donar.d_no=blood11.d_no
and quantity>2;

E) Display the donor information with blood group whose city name contains sh in it.

select d_name,d_city,b_group
from donar,blood11
where donar.d_no=blood11.d_no
and d_city LIKE '%sh%';

25

Roll No:-
Name:-
Slip No:-18
*************************************************************************************
Create table Route (Rout_No Number(10)Primary Key,Source Varchar(20),
Destination Varchar(20), No_Of_Stations Varchar(20));

Insert into Route Values(1,'Chinchwad to Katraj','20KM',5);
Insert into Route Values(2, Swargate to Hadapsar,'20KM',5);
Insert into Route Values(3,'Nigadi to Kothrud','25KM',15);


Create table Bus(Bus_No Number(10)Primary Key,Capacity Varchar(20),Depot_No
Varchar(20),Rout_No Number(10) References Route (Rout_No));

Insert into Bus Values(11,20,105,3);
Insert into Bus Values(22,20,105,2);
Insert into Bus Values(33,50,106,2);
Insert into Bus Values(44,30,107,1);
Insert into Bus Values(55,60,105,3);
Insert into Bus Values(66,40,106,2);
Insert into Bus Values(77,40,777,2);

26

1)Find out the route details on which buses whose capacity is 20 runs.

Select Source,Capacity
From Route,Bus
Where Route.Rout_No=Bus.Rout_No
AND Capacity=20;

2)Display number of stations from 'Chinchwad' to ' Katraj'.
Select No_Of_Stations,Source
From Route,Bus
Where Route.Rout_No=Bus.Rout_No
AND Source='Chinchwad to Katraj';

3)Display the route on which more than 3 buses runs.
Select Source,COUNT(Bus_No)
From Route,Bus
Where Route.Rout_No=Bus.Rout_No
Group by Source
Having COUNT(Bus_No)>3

4)Display number of buses of route Swargate to Hadapsar.
Select Source,COUNT(Bus_No)
From Route,Bus
Where Route.Rout_No=Bus.Rout_No
AND Source='Swargat to Hadapsar'
Group by Source;

5)Find the bust having maximum capacity from Nigadi to 'Kothrud'..
Select Source,Max(Capacity)
From Route,Bus
Where Route.Rout_No=Bus.Rout_No
AND Source='Nigadi to Kothrud'
Group by Source;

27

Roll No:-
Name:-
Slip No:-19
*************************************************************************************
create table person(driver_id number(5)primary key,driver_name varchar(10),driver_add varchar(10));

insert into person values(1,'ram','shirur');
insert into person values(2,'shyam','pune');
insert into person values(3,'balu','vagholi');
insert into person values(4,'gopal','satara');
insert into person values(5,'raghav','mumbai');


create table car(license_no number(10)primary key,model varchar(10),year number(5));
insert into car values(111,'alto',1999);
insert into car values(222,'verna',2000);
insert into car values(333,'audi',2002);
insert into car values(444,'nano',1998);
insert into car values(555,'sx4',2005);


create table person_car(driver_id number (5)references person(driver_id),license_no
number (10)references car(license_no));

insert into person_car values(1,111);
insert into person_car values(2,222);
insert into person_car values(3,333);
insert into person_car values(4,111);
insert into person_car values(4,111);

28


A) Display details of all persons who are driving Alto car.
select distinct(driver_name),driver_add
from person,car,person_car
where person.driver_id=person_car.driver_id
and car.license_no=person_car.license_no
and model='alto';
B) Count the number of cars driven by each driver.
select count(model)
from person,car,person_car
where person.driver_id=person_car.driver_id
and car.license_no=person_car.license_no
group by driver_name;

C) Display car details manufactured before year 2000.
select distinct(model),year
from person,car,person_car
where person.driver_id=person_car.driver_id
and car.license_no=person_car.license_no
and year<2000;

D) In which day Mr. Ram drives maximum number of cars.
select year,count(driver_name)
from person,car,person_car
where person.driver_id=person_car.driver_id
and car.license_no=person_car.license_no
group by year;

E) Display total number of persons who drives car in each year.
select distinct(year)
from person,car,person_car
where person.driver_id=person_car.driver_id
and car.license_no=person_car.license_no
and driver_name='ram';

29

Roll No:-
Name:-
Slip No:-25
*************************************************************************************
Create table Party(Party_Code Number (10) Primary key,Party_Name Varchar(20));

Insert into Party Values(1,'MANASE');
Insert into Party Values(2,'SHIV SENA');
Insert into Party Values(3,'BJP');
Insert into Party Values(4,'Congress');

Create table Politicians(P_No Number (10) Primary key,P_Name Varchar(20),
Telephone_No Number(20),Party_Code Number (10)References Party(Party_Code));

Insert into Politicians Values(11,'PopatRao',0221251,4);
Insert into Politicians Values(22,'Raj',021545,1);
Insert into Politicians Values(33,'ShivajiRao',0212516,2);
Insert into Politicians Values(44,'Narendra',0212554,3);
Insert into Politicians Values(55,'Mahesh',012515,4);
Insert into Politicians Values(66,'Prashant',0122125,4);



30

1)Display party names in ascending order.

Select Distinct Party_Name
From Party,Politicians
where Party.Party_Code=Politicians.Party_Code
Order by Party_Name ASC;

2)Find the party who is having less number of members than Congress party.
Select Party_Name,COUNT(P_Name)
From Party,Politicians
Where Party.Party_Code=Politicians.Party_Code
Group by Party_Name
Having COUNT(P_Name)<(Select COUNT(P_Name)
From Party,Politicians Where
Party.Party_Code=Politicians.Party_Code
and Party_Name='Congress');

3) Display party wise politician name with details.
Select Party_Name,P_Name,Telephone_No
From Party,Politicians
Where Party.Party_Code=Politicians.Party_Code
Order by Party_Name;

4)Display the party name with the details of politicians whose name include Rao.
Select Party_Name,P_Name
From Party,Politicians
Where Party.Party_Code=Politicians.Party_Code
AND P_Name LIKE '%Rao%';

5)Which party has maximum politicians
Select COUNT(P_Name),Party_Name
From Party,Politicians
Where Party.Party_Code=Politicians.Party_Code
AND P_Name=(Select MAX(P_Name)
From Politicians)Group by Party_Name;

31

Roll No:-
Name:-
Slip No:-26
*************************************************************************************

create table game(g_no number(20)primary key,g_name varchar2(20),g_no_of_players
varchar2(20),g_coach_name varchar2(20));

insert into game values(111,'cricket',11,'sachin');
insert into game values(222,'bassketball',8,'sam');
insert into game values(333,'football',10,'vijay');
insert into game values(444,'kho_kho',11,'prashant');
insert into game values(555,'tenees',2,'saniya');


create table player(p_id number(10)primary key,p_name varchar2(20),p_add varchar2(20),p_club_name
varchar2(20));
insert into player values(1,'verrat','Delhi','sports_club');
insert into player values(2,'sachin','Delhi','sports_club');
insert into player values(3,'vijay','pune','win_club');
insert into player values(4,'piyush','shirur','mac_clu
insert into player values(5,'kiran','mumbai','mah_club');

create table game_player(g_no number(10)references game(g_no),p_id number(10)references player(p_id));

insert into game_player values(111,1);
insert into game_player values(222,2);
insert into game_player values(333,3);
insert into game_player values(444,4);
insert into game_player values(555,5);


32

A) Display players from Delhi.
select p_name
from game,player,game_player
where game.g_no=game_player.g_no
and player.p_id=game_player.p_id
and p_add='Delhi';

B) List all games which require more than 4 players.
select g_name
from game,player,game_player
where game.g_no=game_player.g_no
and player.p_id=game_player.p_id
and g_no_of_players>=4;

C) Find the total number of cricket players of 'sports club.

select count(p_name)
from game,player,game_player
where game.g_no=game_player.g_no
and player.p_id=game_player.p_id
and g_name='cricket'
and p_club_name='sports_club';

D) Display games having more number of players than that of football.

select g_name
from game,player,game_player
where game.g_no=game_player.g_no
and player.p_id=game_player.p_id
group by g_name
having g_no_of_players>='football';


33

E) Display coach wise player details.

select p_name,p_add,p_club_name
from game,player,game_player
where game.g_no=game_player.g_no
and player.p_id=game_player.p_id
order by g_coach_name;

34

Roll No:-
Name:-
Slip No:-28
*************************************************************************************

create table wholesaler2(w_no number(10)primary key,w_name varchar(15),w_add varchar(15),w_city
varchar(15));

insert into wholesaler2 values(1,'khabiya','fr','pune');
insert into wholesaler2 values(2,'priya','dr','nagar');
insert into wholesaler2 values(3,'sona','se','pune');
insert into wholesaler2 values(4,'sejal','gt','shirur');
insert into wholesaler2 values(5,'swati','er','satara');


create table product2(p_no number(10)primary key,p_name varchar(15),p_rate varchar(15));

insert into product2 values(11,'mouse',5000);
insert into product2 values(12,'monitor',6000);
insert into product2 values(13,'laptop',30000);
insert into product2 values(14,'keyboard',8000);
insert into product2 values(15,'pc',5000);


create table wholsaler2_product2(w_no number(10)references wholesaler2(w_no),p_no number(10)references
product2(p_no));

insert into wholsaler2_product2 values(1,11);
insert into wholsaler2_product2 values(2,12);
insert into wholsaler2_product2 values(3,13);
insert into wholsaler2_product2 values(4,14);
insert into wholsaler2_product2 values(5,15);

35


A) Display wholesaler from 'Pune' city and supplying 'Monitor'.

select w_name
from wholesaler2,product2,wholsaler2_product2
where wholesaler2.w_no= wholsaler2_product2.w_no
and product2.p_no=wholsaler2_product2.p_no
and w_city='pune'
and p_name='mouse';

B) Display total number of wholesaler of each product.

select count(w_name)
from wholesaler2,product2,wholsaler2_product2
where wholesaler2.w_no= wholsaler2_product2.w_no
and product2.p_no=wholsaler2_product2.p_no
group by p_name;

C) Display all wholesalers who are supplying Keyboard with maximum price.


Select w_name,p_name,MAX(p_rate)
From wholesaler2,product2,wholsaler2_product2
Where wholesaler2.w_no= wholsaler2_product2.w_no
AND product2.p_no=wholsaler2_product2.p_no
AND p_name= 'keyboard'
Group by p_name,w_name;


D) Display total quantity of each product sold by Mr. Khabia.

select count(p_name)
from wholesaler2,product2,wholsaler2_product2
where wholesaler2.w_no= wholsaler2_product2.w_no
and product2.p_no=wholsaler2_product2.p_no
and w_name='khabiya';
36


E) Decrement rate of all products by 5% supplied by wholesaler from 'Pune ' city.
Update Product2
Set P_rate=p_rate-0.05
Where P_rate IN(Select p_rate
From wholesaler2,product2,wholsaler2_product2
where wholesaler2.w_no= wholsaler2_product2.w_no
AND product2.p_no=wholsaler2_product2.p_no
AND w_city='Pune');

37

You might also like