<分区>
我想执行这个查询,但是当表为空时它返回空行。它在 SUM(products.sale_price)/COUNT(orders.id) AS avg_price_rang 时工作
不在查询中
SELECT
products.brand_id,
(SELECT
category_brands.name
FROM
category_brands
WHERE
category_brands.id=products.brand_id
) AS brand,
products.material_id,
(SELECT
category_materials.material
FROM
category_materials
WHERE
category_materials.id=products.material_id
) AS material,
orders.color_code,
SUM(products.sale_price)/COUNT(orders.id) AS avg_price_rang
FROM
orders
INNER JOIN
products
ON
orders.prodcut_id = products.id