Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how shall i find the total value of all books

Status
Not open for further replies.

tom22london

Programmer
Mar 11, 2003
11
0
0
US
how shall i find the total value of all books the borrowers have currently on loan, where the total value is at least £20 for each borrower.

Following are tables,

Borrower (bor_id, bor_name, bor_maxbooks)

Book_title (bt_id, bt_name,pub_id, value)

Book_copy (bc_id, bt_id*, date acquired)

Loan (bor_id, bc_id, date_out, date_due, date_back)

Publisher (pub_id, pub_name, pub_address)

Author (author_id, author_name)

Authorship (author_id, bt_id)

----------------------------------------------------------
 
select sum(x) from
(select sum(value) x
from Book_title natural join Book_copy
natural join Borrower
group by bor_id
having sum(value) > 20) dt

Tell your instructor (or are you reading a book?) that value should not be used as a column name as it is a reserved word in SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top