select t1 as businessDate,count(*) as userCount from
(select distinct case when hh <28800 then date_format(date_add(tt,interval -1 day),'%Y-%m-%d') else date_format(tt,'%Y-%m-%d') end t1,hh,openId,date_format(tt,'%Y-%m-%d %H:%i') tt from (
select timestampdiff(second,date_format(tt,'%Y-%m-%d 00:00:00'),tt) hh,openId,tt from (
select t1 as businessDate,count(*) as userCount from
(select distinct case when hh < 28800 then date_format(date_add(tt,interval -1 day),'%Y-%m-%d') else date_format(tt,'%Y-%m-%d') end t1,hh,username,date_format(tt,'%Y-%m-%d %H:%i') tt from (
select timestampdiff(second,date_format(tt,'%Y-%m-%d 00:00:00'),tt) hh,username,tt from (