thinkphp按日期(天)统计数据

上善若水、 最后发布于2019-09-25 16:32:38 阅读数 305 收藏
展开
··

$data = $orderModel->alias('m')->field('FROM_UNIXTIME(m.enddate,"%Y-%m-%d") as enddate,count(m.id) as sn_sum,sum(m.real_price) as rmb_sum,sum(m.use_up) as use_up_sum,o.sn as machine_sn')
->join('__MACHINE__ o ON m.machine_id=o.id', 'LEFT')
->where($where)
->group('m.machine_id,FROM_UNIXTIME(m.enddate,"%Y-%m-%d")')
->order('m.enddate DESC')
->limit($start . ',' . $limit)
->select();
$subQuery = $orderModel->alias('m')->field('FROM_UNIXTIME(m.enddate,"%Y-%m-%d") as enddate,count(m.id) as sn_sum,sum(m.real_price) as rmb_sum,sum(m.use_up) as use_up_sum,o.sn as machine_sn')
->join('__MACHINE__ o ON m.machine_id=o.id', 'LEFT')
->where($where)
->group('m.machine_id,FROM_UNIXTIME(m.enddate,"%Y-%m-%d")')
->order('m.enddate DESC')
->buildSql();
$count = $orderModel->table($subQuery . ' a')->count();
————————————————
版权声明:本文为CSDN博主「上善若水、」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_45623066/article/details/101372035

posted @ 2020-02-02 15:32  阿波罗任先生  阅读(1328)  评论(0编辑  收藏  举报