mysql 查询语句按天分组统计

时间:2021-12-14 02:25:40

-mysql

select sum(fixed_value) as fixedtotal ,FROM_UNIXTIME(createtime, '%Y-%m-%d') as day from ims_ewei_shop_order_goods group by day

-微擎下

  $where='where uniacid=:uniacid and openid=:openid and createtime >= :starttime and createtime <=:endtime';
  $params=array(
   ':uniacid'=>1,
   ':openid'=>'oKG_Qs0N-P8hH8gtN9jUhpq-1vuY',
   ':starttime'=>$starttime,
   ':endtime'=>$endtime
    );
  $sql="select sum(fixed_value*total)as fixedtotal, sum(tao_percent*price*0.01*total) as fenyong, FROM_UNIXTIME(createtime, '%Y-%m-%d') as day FROM ims_ewei_shop_order_goods ".$where." GROUP BY day";