Tuesday, March 27, 2018

Multiply 2 columns from same row and sum all the results MYSQL

If we want to multiply 2 columns from same row and then sum all the results in mysql

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

ProductIDPriceQTY
15005
26003

Total Pageviews