$query = "SELECT sum(o.feeship) feeship_total,
(SELECT SUM(p.products_price) FROM products p
left join orders_products op on op.products_id = p.products_id
WHERE op.orders_id = o.orders_id) AS cost
FROM orders o ";
$query .= " GROUP BY year(o.date_purchased), month(o.date_purchased)";
if ($sel_month<>0)
$query .= ", dayofmonth(o.date_purchased)";
$query .= " ORDER BY o.date_purchased";
上記の SQL では、select sum products_price
最初の注文のすべての製品のみ。(注文のすべての製品の) の合計方法はsum products_price
、注文に従ってgroup by
ください。選択するために同じSQLを書く方法と同じように見えますfeeship_total
かsum(cost)
?