Top banner

Thursday, April 29, 2010

SQL OR DBMS SQL QUERIES 3

Table Structure

Book
(BookID, Title, Author, Publishers, Price, DistID)
Distributors
(DistID, Name, City)

i) Display the details of books whose price is more than the average price of all books.

Select * from book where price > ( select avg(price) from book)

ii) Display the details of books written by ‘Groff’ and published by ‘TMGH’

select * from book where Author=’Groff’ and publisher=’TMGH’

iii) Create a view to show Title, Author, Publisher and Distributor’s Name & name this view as ShowDetails.

create view ShowDetails (Title, Author, Publisher, Distributor)
as select title, author, publisher, name
from book , distributor
where book.distid = distributor.distid.

No comments:

Post a Comment