0% found this document useful (0 votes)
5 views

Dbms Exp7

The document describes an experiment to implement nested subqueries in SQL using various tables. It provides the aim, tools used, procedure to perform various nested subqueries on the tables, and post lab questions about incremental update and cascade deletes/updates.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Dbms Exp7

The document describes an experiment to implement nested subqueries in SQL using various tables. It provides the aim, tools used, procedure to perform various nested subqueries on the tables, and post lab questions about incremental update and cascade deletes/updates.

Uploaded by

Nishant Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

SE COMP – B Nishant Patil Roll number :9629

Experiment no. : 7 Date of Implementation :

Aim : To implement Nested Sub-queries in SQL

Tool Used : PostgreSQL/ Mysql


Related Course outcome : At the end of the course, Students will be able to Use
SQL : Standard language of relational database
Rubrics for assessment of Experiment:
Indicator Poor Average Good
Timeline (2) submitted on Submitted in same Submitted in
time or early (2) week (1) next week (0)
Applies all Not able to enforce Tables created
DDL/DML/TC few constraints or without
L commands not able to write constraints or
DDL/DML/TCL
with all proper TCL Failed to
Commands(2)
specified commands (1) implement
constraint transaction
successfully (2) (0.5)
Able to apply Able to apply Able to solved
optimized appropriate few queries or
Applies Appropriate SQL /
SQL/PLSQL SQL/PLSQL query queries with
PLSQL (4) query (3) partially correct
and getting correct
output (2) output (1)
Knowledge Unable to
Unable to answer 1 Able to answer
In depth knowledge of the answer 2
question (1) 2 questions (2)
topic(2) questions(0)

Assessment Marks :
Timeliness (2)

DDL/DML/TCL (2)

Applies Appropriate SQL /


PLSQL (4)

Knowledge (2)

Total (10)
Total : (Out of 10)

Teacher's Sign :

EXPERIMENT 7 Nested subqueries in SQL


Aim To implement nested sub-queries in SQL
Tools PostgreSQL/Mysql
Procedure Use the tables created in the previous experiments and Perform the
following queries using nested sub-queries.
Client_master (client_no, name, address, city, pincode, state,
bal_due)
Product_master (product_no, description, profit_percentage,
unit_measure, qty_on_hand, reorder_level, sell_price, cost_price)
Sales_order( order_no, order_date, client_no, dely_Addr,
salesman_no, dely_type, billed_yn, dely_date, order_status)
Sales_order_details(order_no, product_no, qty_ordered,
qty_disp, product_rate)

1. Find the product no. and description of non-moving products i.e.


products not being sold.
2. Find the customer name, address for the client who has placed
order no ‘O191’
3. Find the clients names who have placed orders before the month of
May’96
4. Find the names of clients who have placed orders worth Rs. 10000
or more
5. Retrieve all the orders placed by a client named ‘Rahul Desai’ from
the sales_order table.
6. Retrieve name, address, city of all the clients who have placed an
order through salesman no ‘s001’.

Post Lab Questions: 1. What is incremental Update?


2. Explain is use of on delete cascade and on update cascade with
suitable example?
Output:

Client_master (client_no, name, address, city, pincode, state, bal_due)


Product_master (product_no, description, profit_percentage, unit_measure,
qty_on_hand, reorder_level, sell_price, cost_price)

Sales_order( order_no, order_date, client_no, dely_Addr, salesman_no, dely_type,


billed_yn, dely_date, order_status)

Sales_order_details(order_no, product_no, qty_ordered, qty_disp,


product_rate)
1. Find the product no. and description of non-moving products i.e. products
not being sold.
select product_no, desription from product_master where product_no not
in(select product_no from sales_order_del);

2. Find the customer name, address for the client who has placed order no
‘O191’
select client_name, client_address from client_master, sales_order where
client_master.client_no=sales_order.client_no and
sales_order.order_no='O1';

3. Find the clients names who have placed orders before the month of May’96
SELECT client_no, client_name FROM client_master WHERE client_no
IN(SELECT client_no FROM sales_order WHERE TO_CHAR(Dely_date,
'MON,YY') < 'MAY,96');
4. Find the names of clients who have placed orders worth Rs. 10000 or more
SELECT client_name FROM client_master WHERE client_no IN(SELECT
client_no FROM sales_order WHERE order_no IN(SELECT order_no FROM
sales_order_del WHERE(Qty_ordered * product_rate) >= 10000));

5. Retrieve all the orders placed by a client named ‘Rahul Desai’ from the
sales_order table.
select * from sales_order where client_no=(select client_no from
client_master where client_name='Rahul Desai');
6. Retrieve name, address, city of all the clients who have placed an order
through salesman no ‘s001’.

select * from sales_order_del where product_no =(select product_no from sales_order_del


where product_no='p3');

You might also like