wordpress收费下载资源主题
wordpress付费下载资源插件

Mysql 统计今年每月的数据

最近模板兔给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 个评论

定制开发
本站承接WordPress等系统建站仿站、二次开发、主题插件定制等开发服务
在线咨询
  • 请先加Q,临时会话收不到
    QQ:1-247-246-247

  • QQ一群:104228692(满)
  • QQ二群:64786792
在线咨询
本站承接WordPress建站仿站、二次开发、主题插件定制等PHP开发服务!

了解详情