oracle - SQL: Repeating data in JOIN -


i'm doing homework class , can't figure out how answer question:

"determine books generate less 55% profit , how many copies of these books have been sold. summarize findings management, , include copy of query used retrieve data database tables."

i tried taking shot @ can't seem come out way want to. has data doesn't seem go together. below code:

select isbn, b.title, b.cost, b.retail, o.quantity "# of times ordered",    round(((retail-cost)/retail)*100,1)||'%' "percent profit",     o.quantity "# of times ordered" books o join orderitems o using(isbn); 

it works in sense data need comes this:

enter image description here

i have theory because table "order items" has multiple orders same isbn , different quantities it's selecting of them. there way combine them? if not me rid of redundant data caused join?

thank you!

i've had similar things in sql server / mysql. need group columns in see repeated data not care about, , need sum field values important you, this...

select isbn, b.title, b.cost, b.retail, o.quantity "# of times ordered",    round(((retail-cost)/retail)*100,1)||'%' "percent profit",     sum(o.quantity) "# of times ordered" books o join orderitems o using(isbn) group isbn, b.title, b.cost, b.retail; 

if need more information, go here , search sum: https://docs.oracle.com/javadb/10.6.1.0/ref/rrefsqlj32654.html


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -