MYSQL Sum Query with IF Condition
How about this?
SUM(IF(PaymentType = "credit card", totalamount, 0)) AS CreditCardTotal
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 ...