sql while语句及procedure
作者:
vlsee | 来源:发表于
2018-10-17 17:47 被阅读137次CREATE PROCEDURE myProc()
BEGIN
DECLARE num INT DEFAULT 0;
DECLARE stime TIMESTAMP;
DECLARE etime TIMESTAMP;
DECLARE cnt INT DEFAULT 0;
WHILE num<90 DO
SET stime="2018-07-01 00:00:00" + INTERVAL num DAY;
SET etime="2018-07-01 23:59:59" + INTERVAL num DAY;
-- SELECT count(*) INTO cnt FROM usertpiactivity where time>=stime and time<=etime;
-- INSERT INTO temp SET period=num,utpicount=cnt;
-- SELECT count(*) INTO cnt FROM usertpisactivity where time>=stime and time<=etime;
-- UPDATE temp SET utpiscount=cnt where period=num;
UPDATE temp SET day=stime where period=num;
SET num=num+1;
END WHILE;
END
本文标题:sql while语句及procedure
本文链接:https://www.haomeiwen.com/subject/scirzftx.html
网友评论