草庐IT

PaymentType

全部标签

带有IF条件的MYSQL求和查询

我正在为SUM上具有多个IF条件的报表构建查询。我在SUM上遇到多个IF条件的问题。这里是查询:SELECTSUM(`totalamount`)ASTotal,SUM(`PayPalFee`)ASFees,DATE(`TransactionDate`)AS`Day`,SUM(IF(PaymentType="paypal",1,0))ASPaypal,SUM(IF(PaymentType="check",1,0))ASChecks,SUM(IF(PaymentType="creditcard",1,0))ASCreditCard,COUNT(*)ASEntriesFROMmy_table

带有IF条件的MYSQL求和查询

我正在为SUM上具有多个IF条件的报表构建查询。我在SUM上遇到多个IF条件的问题。这里是查询:SELECTSUM(`totalamount`)ASTotal,SUM(`PayPalFee`)ASFees,DATE(`TransactionDate`)AS`Day`,SUM(IF(PaymentType="paypal",1,0))ASPaypal,SUM(IF(PaymentType="check",1,0))ASChecks,SUM(IF(PaymentType="creditcard",1,0))ASCreditCard,COUNT(*)ASEntriesFROMmy_table