Chybí vám THEN
ve vašem prvním CASE
Prohlášení. (Omlouvám se, že jsem musel přidat aliasy tabulek )
SELECT sc.session_id
, sc.product_id
, sc.product_qty
, sc.product_option
, p.product_title
, p.product_price
, p.product_sale_price_status
, p.product_sale_price
, po.option_text
, po.option_upcharge
, CASE
WHEN (p.product_sale_price_status = 'Y')
THEN <-- add this
CASE
WHEN (po.option_upcharge IS NOT NULL)
THEN (sc.product_qty * (p.product_sale_price + po.option_upcharge))
ELSE (sc.product_qty * p.product_sale_price)
END
ELSE
CASE
WHEN (po.option_upchage IS NOT NULL)
THEN (sc.product_qty * (p.product_price + po.option_upcharge))
ELSE (sc.product_qty * p.product_price)
END
END AS product_total
FROM tblshopping_cart sc
INNER JOIN tblproducts p
ON sc.product_id = p.product_id
LEFT JOIN tblproduct_options po
ON sc.product_option = po.option_product_id
ORDER BY sc.product_qty ASC