Experiment - 9 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Experiment - 9

Aim - To implement Views.

PROCESS -

1. Select Schema
Use joinss;

2. View Table ORDERS


SELECT * FROM orders;

3. View Table SALES


SELECT * FROM sales;

QUERY -
1. Create a view for those salespeople who belong to the city of
“VARANASI”.
create view salescity as
select * from sales
where city='varanasi';

SELECT * FROM joins.salescity;


2. Create a view for all salespersons. Return sid, name, and city
create view salesinfo as
select sid,name,city from sales;

SELECT * FROM joinss.salesinfo;

3. Create a view for salesman living in “Varanasi”. Return order


no,purch_amt
create view ordersInfo as
select ordno,purch_amt from orders
where sid in (select sid from sales where
city='varanasi');

select * from orderInfo;

4. Create a view to find the salesperson who handles a customer


who makes the highest order. Return order date, salesperson ID,
name.
create view maxInfo as
select salesman.sid,sname,odate,purch_amt
from salesman inner join orders
on salesman.sid=orders.sid
where purch_amt =(select max(purch_amt) from orders);
select * from maxInfo;

You might also like