SELECT a.id AS supplier, sum( processed_weight ) AS total_qty
FROM supplier_inward a
INNER JOIN warehouseb ON a.id = b.supplier
WHERE a.master_product_id = '38'
GROUP BY b.supplier
output present
supplier total_qty
12046 475.00
12482 99.00
output needed
total_qty
574.00
here i need the sum(total_qty) in this query? how to achieve this
MySQL SUM() FunctionThe SUM() function calculates the sum of a set of values. Note: NULL values are ignored.
AVG() SyntaxThe SUM() function returns the total sum of a numeric column.
MySQL SUM() function retrieves the sum value of an expression which is made up of more than one columns. The above MySQL statement returns the sum of multiplication of 'receive_qty' and 'purch_price' from purchase table for each group of category ('cate_id') .
SUM() function with group by MySQL SUM() function retrieves the sum value of an expression which has undergone a grouping operation by GROUP BY clause.
how about this:
SELECT SUM(iQuery.total_qty) as iTotal
FROM
(SELECT a.id AS supplier, sum( processed_weight ) AS total_qty
FROM supplier_inward a
INNER JOIN warehouseb ON a.id = b.supplier
WHERE a.master_product_id = '38'
GROUP BY b.supplier) as iQuery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With