i want to execute this query but it return null row when the table empty. it's working when SUM(products.sale_price)/COUNT(orders.id) AS avg_price_rang
is not in the query
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
Aucun commentaire:
Enregistrer un commentaire