sql:
insert into table ads_uv_count select '2020-03-12' dt, daycount.ct, wkcount.ct, mtcount.ct, if(date_add(next_day('2020-03-12','MO'),-1)='2020-03-12','Y','N'), if(last_day('2020-03-12')='2020-03-12','Y','N') from ( select '2020-03-12' dt, count(*) ct from dwt_uv_topic where login_date_last='2020-03-12' ) daycount join ( select '2020-03-12' dt, count(*) ct from dwt_uv_topic where login_date_last>=date_add(next_day('2020-03-12','MO'),-7) and login_date_last<=date_add(next_day('2020-03-12','MO'),-1) ) wkcount on daycount.dt=wkcount.dt join ( select '2020-03-12' dt, count(*) ct from dwt_uv_topic where date_format(login_date_last,'yy-MM')=date_format('2020-03-12','yy-MM') ) mtcount on mtcount.dt=daycount.dt;