Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>SELECT b.`name Item`, a.qty `Sold Quantity`, a.price `@ price`, (a.qty * a.price) Total FROM transaction_detail a INNER JOIN Item b ON a.idItem = b.idItem </code></pre> <ul> <li><a href="http://www.sqlfiddle.com/#!2/f7090/2" rel="nofollow">SQLFiddle Demo</a></li> </ul> <p>The query above is based on the records and result given on the example. <em>Follow-up question(s): is there any possibility that a certain Item can be sold with different price? If so, how do you calculate it?</em></p> <p><strong>UPDATE 1</strong></p> <pre><code>SELECT b.`name Item`, SUM(a.qty) `Sold Quantity`, a.price `@ price`, (SUM(a.qty) * a.price) Total, c.Date FROM transaction_detail a INNER JOIN Item b ON a.idItem = b.idItem INNER JOIN `transaction` c ON a.idtransaction = c.idTransaction GROUP BY b.idItem, b.`name Item`, a.price, c.Date </code></pre> <ul> <li><a href="http://www.sqlfiddle.com/#!2/ab120/4" rel="nofollow">SQLFiddle Demo</a></li> </ul> <p><strong>UPDATE 2</strong></p> <pre><code>SELECT b.`name Item`, SUM(a.qty) `Sold Quantity`, a.price `@ price`, (SUM(a.qty) * a.price) Total, d.`Name Customer` FROM transaction_detail a INNER JOIN Item b ON a.idItem = b.idItem INNER JOIN `transaction` c ON a.idtransaction = c.idTransaction INNER JOIN Customer d ON d.idCustomer = c.idCustomer GROUP BY b.idItem, b.`name Item`, a.price, MONTH(c.Date), YEAR(c.Date), d.`Name Customer` </code></pre> <ul> <li><a href="http://www.sqlfiddle.com/#!2/5d648/2" rel="nofollow">SQLFiddle Demo</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload