vendredi 13 février 2015

Sql Query for number of available and total books


I need a query which will return list of book from book table


but it will show total number of books and books available too ..



And for number of books it will count number of books with simular ISBN n amount count which will count number of books with simular ISBN with status available


Table structure



Bookid booktitle author ISBN edition publisher price supplier volume language status

status contains available,issued


I want result as



BookTitle Author Publisher Location Total available


Please also explain the query because I need to implement it on many tables


Queries i tried this far



select *,count(1) as Quantity from Book group by Book.BookTitle


It successfully gives me book list with total quantity


and



select *,count(1) as Quantity from Book where status='Available' group by Book.BookTitle


It Successfully gives me list of books with how many are available.


but i need combination of both total and available ..


Aucun commentaire:

Enregistrer un commentaire