$user_sql = "select year(from_unixtime(ref_date)) as year,month(from_unixtime(ref_date)) as month,SUM(cancel_user) as cancel_user,SUM(new_user) as new_user,user_source as all_user,count(distinct mid) as count_mp ";
//订阅
$subscription_user = Db::query($user_sql." from mr_user_summary_data where mid " . $subscription_where . $user_where . " group by year(from_unixtime(ref_date)), month(from_unixtime(ref_date))");
//服务
以上代码自动按日期把每个月的数据统计起来(每个月的数据相加),并在显示年和月
$income = Db::query("select UNIX_TIMESTAMP(edate) as edate,account_id,ad_type,sum(amount) as amount from mr_flow_income WHERE ".$income_where." unix_timestamp(edate) between ".$satrttime." and ".$endtime." group by unix_timestamp(edate) ,account_id order by unix_timestamp(edate) ASC");