BEGIN select min(Atime) from t_month into @m; select max(Atime) from t_month into @n; truncate t_rlt;
while @m <= @n do insert ignore into t_rlt (name) select name from t_month where aTime between @m and date_add(@m, interval 6 month) having sum(data) >= 1000;
set @m = date_add(@m, interval 1 month); end while;
select name from t_rlt; END
----------------------------------------------
-