最近模板兔给erphpdown增加了统计收入功能,需要统计今年每月的收入数据以及本月每天的收入数据。
今年每月的数据:
$month_total = $wpdb->get_row("select sum(case month(ice_time) when '1' then ice_money else 0 end) as Jan, sum(case month(ice_time) when '2' then ice_money else 0 end) as Feb, sum(case month(ice_time) when '3' then ice_money else 0 end) as Mar, sum(case month(ice_time) when '4' then ice_money else 0 end) as Apr, sum(case month(ice_time) when '5' then ice_money else 0 end) as May, sum(case month(ice_time) when '6' then ice_money else 0 end) as June, sum(case month(ice_time) when '7' then ice_money else 0 end) as July, sum(case month(ice_time) when '8' then ice_money else 0 end) as Aug, sum(case month(ice_time) when '9' then ice_money else 0 end) as Sept, sum(case month(ice_time) when '10' then ice_money else 0 end) as Oct, sum(case month(ice_time) when '11' then ice_money else 0 end) as Nov, sum(case month(ice_time) when '12' then ice_money else 0 end) as Dece from $wpdb->icemoney where year(ice_time)='".date("Y")."' and ice_success>0;");
本月每天的数据可基于此方法类推,用case day(ice_time)。
上面统计的是充值金额总和,那如果需要统计充值记录数呢,需要把ice_money替换成1,也就是每次加1。
0 个评论