Hi I try to need to sum values and if there is more than 20 there shouldbe written 20 else should be number.
I don't know what i make wrong:
SELECT
ta6.product_product_id AS ID,
ta6.product_manufacture_code AS Code,
SUM(CASE WHEN ta3.stock_quantity >= 20 THEN 20 ELSE ta3.stock_quantity END) AS Quantity,
ta4.price_value AS Price,
ta5.Attribute_Value AS Sizer,
ta6.Procut_product_name AS Name,
ta7.Attribute_Value AS produce
FROM
product ta6
LEFT JOIN stock ta3 ON
ta3.stock_id = ta6.product_id
LEFT JOIN price ta4 ON
ta4.price_id = ta6.product_id
AND ta4.price_type = 2
LEFT JOIN Attributes ta5 ON
ta5.Attributes_product_Id = ta6.product_id
LEFT JOIN Attributes ta7 ON
ta7.Attributes_product_Id = ta6.product_id
WHERE
( ta3.stock_wharehouse_id = 1
AND ta5.Attrib_id = 54
AND ta7.Attrib_id = 25 )
GROUP BY
ta6.product_manufacture_code,
ta6.product_product_id
ta4.price_value,
ta5.Attribute_Value,
ta6.product_product_name ,
ta7.Attribute_Value;
Table stock_quantity looks like: Stock_table image
How to sum it ??
Aucun commentaire:
Enregistrer un commentaire