Ejemplo: mysql select inside sum
SELECT x.prod_name
, SUM(x.total)
FROM ( SELECT bp.prod_name
, ( SELECT SUM( wh.quantity ) * bp.weight
FROM bus_warehouse_entries wh
WHERE bp.prod_code = wh.org_product_code ) AS total
FROM bus_products bp ) x
GROUP BY x.prod_name
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)