赞
踩
按条件求和
- SUM(IF(fee_type=1,fee_for_balance,0))
- count(if(bill_sec<=12, bill_sec, null))
- MAX(IF(item_code like '%_mini', item_value, null))
数据示例
统计每月账单的金额和支付金额
select order_no,month, SUM(IF(fee_type=1,fee_for_balance,0)) bill_money,SUM(IF(fee_type=2,fee_for_balance,0)) receivable_money from test GROUP BY month
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。