📜  mysql select inside sum - SQL 代码示例

📅  最后修改于: 2022-03-11 15:04:59.629000             🧑  作者: Mango

代码示例1
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