I want some help sum with Quantity total cost and total unit price

i want this
name | Total Qty | Total Cost(sumQuantity) | total price(sumQuantity)

Item table

 Name   | item_id | Cost price | Unit price | 
shirt1 	|   4     |  3800.00   | 5320.00    
shirt2 	|   5     |  3800.00   | 5320.00
shirt3 	|   6     |  3800.00   | 5320.00
shirt5 	|   7     |  2900.00   | 4060.00
-----------------------------------------------

quantities table

item_id | Quantity

4   |   5      
5   |   4
6   |   3
7   |   1

please guys help me… Any help appreciated!

Something like the following?

SELECT Name, Quantity, (Quantity * CostPrice) AS Total_Cost, (Quantity * UnitPrice) AS Total_Price FROM Item LEFT JOIN Quantities ON Item.item_id = Quantities.item_id

where is sum? total amount?

What have you tried? We need to see what you’ve tried before we can help you do your homework. We’re not going to do it for you.

okay, this will help…

you need an INNER JOIN

you need GROUP BY

and you need SUM() functions

**Guys Help me >

 Less Sale at Cost price

what will be mysql Query any idea???**

sure, i have an idea…

you need an INNER JOIN

you need GROUP BY

and you need SUM() functions

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.