If we want to multiply 2 columns from same row and then sum all the results in mysql
Here is example table
Result Will like blew
Here is example table
ProductID | Price | QTY |
---|---|---|
1 | 100 | 2 |
1 | 100 | 2 |
2 | 200 | 3 |
1 | 100 | 1 |
SELECT SUM(price*qty) price, SUM(qty) qty, proID FROM `table1` GROUP BY proID
Result Will like blew
ProductID | Price | QTY |
---|---|---|
1 | 500 | 5 |
2 | 600 | 3 |
No comments:
Post a Comment