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

Exercise 2 Dbms

This document contains examples of SQL queries on various tables including product_master, sales_order_details, client_master, sales_order, IT_book, IT_stud, and IT_issu_retu. It also shows examples of creating views on these tables to more easily query specific subsets of data. The queries and views include selections, aggregations, joins, conditions and groupings.

Uploaded by

aj1991
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Exercise 2 Dbms

This document contains examples of SQL queries on various tables including product_master, sales_order_details, client_master, sales_order, IT_book, IT_stud, and IT_issu_retu. It also shows examples of creating views on these tables to more easily query specific subsets of data. The queries and views include selections, aggregations, joins, conditions and groupings.

Uploaded by

aj1991
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

EXERCISE 5 (SUB QUERIES)

A) a) select product_no,description from product_master notin(select product_no from sales_order_details); where product_no

b) select name,address1,address2,city,state,pincode from client_master where client_no in(select client_no from sales_order where order_no=1900); c) select client_no,name from client_master where client_no in(select client_no from sales_order where to_char(order_date,mon-yy)<may,96); d) select client_no,name from client_master where client_no in(select client_no from sales_order where order_no in(select order_no from sales_order_details where product_no in(select product_no from product_master where description=1.55 Drive))); e) select name from client_master where client_no in(select client_no from sales_order where order_no in(select order_no from sales_order_details where(qty_ordered*product_rate)>=1000));

EXERCISE 5
Queries on Library Table
a)select avg (IT_book_price),IT_book_title,IT_book_author,from where IT_book_price>avg(IT_book_price); IT_book

b) select max(IT_book_price),IT_stud_name from IT_book,IT_stud,IT_issu_retu where IT_book.IT_book_code=IT_issu_retu.IT_book_code and IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code and IT_book_price=max(IT_book_price); c) select max(IT_book_price),IT_stud_name from IT_stud,IT_book,IT_issu_retu where IT_book.IT_book_code=IT_issu_retu.IT_book_code and IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code group by IT_stud_branch having IT_stud_branch=EC; d) select max(IT_book_price),IT_stud_name from IT_stud,IT_book,IT_issu_retu where IT_book.IT_book_code=IT_issu_retu.IT_book_code and IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code group by IT_stud_branch; e) select IT_book_author,IT_book_name,min(IT_book_price) from IT_book group by IT_book_author; f) select max(IT_book_price),IT_stud_name from IT_stud,IT_book,IT_issu_retu where IT_book.IT_book_code=IT_issu_retu.IT_book_code and IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code group by IT_book_publish having IT_stud_branch =IT;

EXERCISE 6 Construction of Sentences


a)select description || worth Rs ||product_master|| was sold from product_master,sales_order_details where product_master.product_no=sales_order_details.product_no; b)select description|| worth Rs ||product_rate||was ordered in the month of ||to_char(order_date,month) from product_master,sales_order_details where sales_order_details.product_no=product_master.product_no; c) select client_name|| has placed order ||order_no||order_date from client_master,sales_order where sales_order.client_no=client_master.client_no;

EXERCISE 7
Queries on VIEWS a)create view a_student as select IT_stud_name,IT_stud_card_no.IT_issu_doi.IT_issu_fine from IT_stud,IT_issu_retu where IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code; b) create view a_details as(select * from IT_stud,IT_issu_retu where IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code and IT_stud_branch=IT); c) select IT_issu_fine from a_details; g) create view CS_details as (select * from IT_stud,IT_issu_retu where IT_stud.IT_stud_code=IT_issu_retu.IT_stud_code and IT_stud_branch=CS); create view EC_details as( select * from IT_stud,IT_issu_retu where IT_stud.IT_stud_code =IT_issu_retu.IT_stud_code and IT_stud_branch=EC); h) create view CS_EC as select * from IT_stud ,IT_issu_retu where IT_stud.IT_stud_code=IT_issu.IT_stud_code and IT_stud_branch=EC or CS and IT_stud_name=gaurav;

You might also like