MYSQL Sum Query with IF Condition

The Solution to MYSQL Sum Query with IF Condition is


Try with a CASE in this way :

SUM(CASE 
    WHEN PaymentType = "credit card" 
    THEN TotalAmount 
    ELSE 0 
END) AS CreditCardTotal,

Should give what you are looking for ...

~ Answered on 2012-01-04 18:39:04


Most Viewed Questions: