You are on page 1of 2

1. Give library wise book details.

select lname, count(bid) as 'No_of_Books' from books b, ilib i where b.lid =


i.lid group by lname;

2. Give bookwise total copies which are available.


select bname, sum(bnid) from books b, nofocopies n where b.bid = n.bid group
by bname ;
or
select bname, sum(quantity) from books b, purchase p where b.bid = p.bid
group by bname ;

3. Which library has total copies more than 100?

select i.lname , sum(quantity) as 'Total_Copies' from books b, purchase p ,


ilib i where b.bid = p.bid and b.lid = i.lid group by lname having sum(quantity)
> 100 ;

OR

select i.lname , sum(quantity) as 'Total_Copies' from books b, purchase p ,


ilib i where b.bid = p.bid and b.lid = i.lid group by lname ;

create table Q3 (select i.lname , sum(quantity) as 'Total_Copies' from books


b, purchase p , ilib i where b.bid = p.bid and b.lid = i.lid group by lname );

select * from Q3 where Total_Copies > 100 ;

4. Give institute wise department details.

select lname ,count(deptname) as 'No_of_Dept' from ilib i,department d where


i.lid = d.lid group by lname ;

5. Give citywise seller details.


select city , count(slname) as 'No_of_Seller' from seller group by city ;

6. Give author wise book details that have authored more than 2 books.
select aname, count(bid) as 'No_of_Books' from writes w, author a where a.aid
= w.aid group by a.aid having count(bid)>2;

7. Give book details library wise whose price is less than 1000
select lname, count(bid) as 'No_of_Books' from books b, ilib i where b.lid =
i.lid and b.price > 1000 group by lname;

8. Give department wise staff details.


select deptname , count(stname) as 'No_of_emp' from department d,staff s
where d.deptid = s.deptid group by deptname ;

9. How many books are issued library wise


select lname , count(issueid) as 'No_of_issue' from ilib il,issue i where
il.lid = i.lid group by lname ;

10. Give purchase details publisher wise.

select pname ,count(quantity) as 'Total_Copies' , count(totalcost) as


'Total_Cost' from publisher pu , purchase p where pu.pid = p.pid groub by pname;
11. Display books in a descending order of their cost.
select bname from books order by price desc ;

You might also like