select t2.*from(select dt,u,min(datatime) from tbl where dt='2018-08-01' group by dt,u)t1 join ( select * from tbl where dt='2018-08-01' ) t2 on t1.dt=t2.dt and t1.u=t2.u