title: SQL: Repeating data in JOIN
body: <p>I'm doing homework for my class and I can't figure out how to properly answer this question:</p>
  
  <p>"Determine which books generate less than a 55% profit and how many copies of these books have been sold. Summarize your findings for management, and include a copy of the query used to retrieve data from the database tables."</p>
  
  <p>I tried taking a shot at it but I can't seem to get it to come out the way I want it to. It always has data that doesn't seem to go together. Below is my code:</p>
  
  <pre><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"
  FROM books o JOIN orderitems o USING(isbn);
  </code></pre>
  
  <p>It works in the sense that I get the data I need but it comes up like this:</p>
  
  <p><img src="https://i.stack.imgur.com/CiKOc.jpg" alt="enter image description here"></p>
  
  <p>I have a theory that because the table "Order Items" has multiple orders with the same isbn and different quantities it's selecting all of them. Is there a way to combine them? If not could anyone help me get rid of the redundant data caused by the JOIN?</p>
  
  <p>Thank you!</p>