with t as ( select uid,max(date_format(in_time,"%Y-%***x_date,min(date_format(in_time,"%Y-%m-%d")) min_date from tb_user_log group by uid ) select "忠实用户" user_grade,round(sum(if(datediff("2021-11-04",max_date)<7&a...