create procedure statistical_table()
begin
declare cur cursor for select BNum from bill;
#declare CONTINUE HANDLER FOR NOT FOUND SET @tmp=FALSE;
open cur;
FETCH next from cur into @a;
WHILE @@FETCH_STATUS=0 DO
select @a;
set @dd=@a;
select SUM(Oprice) into @cou from indent group by day_date having day_date=@dd;
UPDATE bill set Turnover=@cou where BNum=@dd;
fetch next from cur into @a;
END WHILE;
close cur;
DEALLOCATE cur;
end