Академический Документы
Профессиональный Документы
Культура Документы
Practical 3
Customer (cust_id, Lname, Fname, Area, phone)
Movie (Mvno, Title, Type, Star, Price)
Invoice (Invno, Mvno, Custid, Issue date, Return date)
Generate SQL statements to perform the following computations on
the table data
1. Find the movies that cost more than 159 and also find the cost
as original cost * 15
2. Print the names and types of all the movie except horror
movies
3. Find out number of movies in each type
4. Display the title, Lname, Fname for customers having movie
number greater than or equal to three in the following format.
The movie taken by { Fname} { Lname} is { Title}
Practical 5
CATALOG (Book_id primary key, title, author_id foreign key
reference AUTHOR(author_id),publisher_id foreign key reference
PUBLISHER(publisher_id),category_id foreign key reference
CATEGORY(category_id),year, price)
AUTHOR (author_id primary key, name, city, country)
PUBLISHER (publisher_id primary key, name, city, country)
CATEGORY (category_id primary key, description)
MEMBER (member_id primary key, name, address, city, state, pin,
phone, email)
ORDER_SUMMARY (order_no primary key, member_id foreign key
reference MEMBER (member_id), order_date, amt, order_status)
ORDER_DETAILS (order_no foreign key reference
ORDER_SUMMARY (order_no), Book_id foreign key reference
CATALOG (book_id))
Exercises on Joins
1. List the titles ,author’s names, publisher’s name and year for
the books which are published in year 1993 or 1996 or 1998
2. List the titles and names of the authors of the books whose
publisher’s name begins with M
SQL statements for Sub-queries
1. List the title and price of all books whose price is greater than
average than average price of the books having description
‘business’ in the CATEGORY table
2. List the ID, Address, city, state and Pin of all members who
placed an order for the book ‘SQL Complete Reference’
Exercise on updating, altering table structure and deleting table
1. Delete all the books whose price is greater than the average
price
2. Increase the price by 10% for the books published by
‘Microsoft Press ’
3. Change the data type of the column Phone of MEMBER table to
number
Practical 7
Book (title, author, publisher, category, year, price)
Distributer (dist_id, distributor, city, discount, credit)
Orders (order_no.title, dist_id, quantity)
1. Get the details of all the books whose price is greater than the
average price of the books
2. Get the names of all distributors who are supplying the books
titled ’software testing ’ to the bookshop
3. Get the details of all distributors who give more discount than
the average discount
4. Get the details of all the books whose price is greater than the
maximum of the category average
5. Get the names of all distributors who are supplying the books
author is ‘McConnel’(use nested subquery)
6. Grant the select ,delete & update authority on BOOK table to
user ‘Alex’ with capability to grant those privileges to the other
users
7. Remove all privileges on BOOK table from user ‘Sam’
Practical 8
Workers (worker_id, fname, lname, email, hiredate, salary,
manager_id, commission_pct)
2.List the section ID and section name of all the section from the
SECTIONS table, regardless of whether or not they belong to any
section or not
5.List all the workers having salary more than 30000 and joined in
the month of January
6.Display the last names of the workers who earns less than the
average salary in their sections
7.Display the worker last name, section nam,e Area Id, and city of all
workers who earn a commission