PLEASE ANSWER THIS SPECIFIC QUESTION... 8. For each book order, give the ID and
ID: 3711358 • Letter: P
Question
PLEASE ANSWER THIS SPECIFIC QUESTION...
8. For each book order, give the ID and the total number of books requested in that order (e.g., for an order that requested 4 of one book, 3 of a second book, and 2 of a third book, the total number of books requested for that order would be 9). Sort the orders from the one with the largest total number of books to the one with the smallest total number of books
Remarks: 1. As is always the case, it is your responsibility to make sure that the files you have uploaded are readable and in the correct locations. I recommend that you download your file after submitting it to be sure that is has been uploaded correctly. And as is the case for all assignments, all work must be completed individually no collaboration between students is permitted. 2. For scratch work, a copy of the database instance created by Books.sql is given below Eric J. Schwabe - 04/11/18 LIBRARY ID NAME CITY Newburgh Hauppauge STATE ZIP 12550 11788 15213 96744 92612 87507 94121 33101 97045 12209 15228 33901 80514 48103 07201 07410 34646 1 Newburgh Free Library 2 Hauppuage Library 3 Three Rivers Library NY NY PittsburghPA Hawaii Public Library (Kaneohe Branch) Kaneohe Irvine CA 5 John Wayne Library 6 Santa Fe Public Library 7 The Peoples Library 8 Central Library of Miami 9 OC Branch, Library of Oregon Santa Fe San Francisco CA EL Oregon City OR NY Bethel Park PA 12 Lee County Library, Beachside Branch Fort Myers FL ?? MI NJ NJ FL Miami Albany 10 Albany NY Library (Main Branch) 11 South Hills Library 13 Free Public Library of Boulder 14 Ann Arbor Library 15 Public Library of Newark 16 Eair Lawn Library 17Main Library of Seminole Boulder Ann Arbor Newark Fair Lawn Seminole BOOK PRICE ISBN 0374104115 Acceptance 0374104093 Annihilation Jeff Vandermeer 0374104107 Authority 0441011160 Coyote 0441013570 Coyote Frontier Allen Steele 0441012515 Coyote Rising Allen Steele 0316262315 New York 2140 Kim Stanley Robinson 12.99 0316098116 2312 0374537658 Borne Jeff Vandermeer 7.99 9.99 10.99 4.99 5.99 6.99 Jeff Vandermeer Allen Steele Kim Stanley Robion 8.99 Jeff Vandermeer 11.99Explanation / Answer
Hi,
Thanks for posting question here.
here is your answer
--------------------------
select l.id,sum(g.quantity) total from library l,(select l1.id,i.orderid,i.quantity from library l1,bookorder b,lineitem i where l1.id=b.libraryid and b.orderid=i.id group by i.orderid) g where g.id=l.id group by(l.id) order by(total) desc
------------------------------
sum is used for counting the sumation
desc is used for ordering the result in descending order
thanks
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.