select DISTINCT a.userid,a.order_date from t_order_status a where a.order_date >'2019-07-29' and a.order_date<'2019-07-30' and a.order_type !=0 ;
这时distinct 会对userid 和order_date都去重所以数据会不对,需求是只对userid去重,mysql中这时用group by来操作。
select a.userid,a.order_date from t_order_status a where a.order_date >'2019-07-29' and a.order_date<'2019-07-30' and a.order_type !=0 GROUP BY a.userid;
现在数据没有重复了。