SELECT SUM((qty * (SELECT gross_wt
FROM lpr_productmaster
WHERE productid = lpr_order_detail.productid))) AS prodwt
FROM lpr_order_detail
WHERE order_id = 413
GROUP BY order_id;
答案 0 :(得分:2)
尝试一下:
SELECT SUM(qty * gross_wt) AS prodwt
FROM lpr_order_detail
INNER JOIN lpr_productmaster
ON lpr_order_detail.productid = lpr_productmaster.productid
WHERE order_id = 413
GROUP BY order_id;
想法是重写查询,以免使用子查询。