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