summary_keep_rate
4618 단어 데이터베이스
BEGIN
/*DECLARE minDate varchar(20) ;
DECLARE maxDate varchar(20) ;*/
DECLARE stkDate varchar(20) ;
DECLARE done int default -1;
/* */
DECLARE rgServer VARCHAR(24);
/* */
DECLARE mCursor CURSOR FOR (select DISTINCT server from yt_log_role_create where server IS NOT NULL ORDER BY server ASC);
/* ,mysql done=1 */
DECLARE CONTINUE HANDLER FOR NOT found SET done=1;
# 30
SET @FLAG = (SELECT date FROM yt_keep_rate WHERE k=30 LIMIT 1,1 ) ;
IF minDate = '' OR minDate IS NULL THEN
IF maxDate = '' OR maxDate IS NULL THEN
SELECT MAX(time) INTO maxDate FROM yt_log_role_create where server IS NOT NULL;
SELECT MIN(time) INTO minDate FROM yt_log_role_create where server IS NOT NULL;
TRUNCATE TABLE yt.yt_keep_rate;
ELSE
IF @FLAG IS NOT NULL OR @FLAG != '' THEN
SELECT ADDDATE(MAX(date),1) INTO minDate FROM yt_keep_rate WHERE k=30;
ELSE
SELECT MIN(time) INTO minDate FROM yt_log_role_create where server IS NOT NULL;
END IF;
END IF;
ELSE
IF maxDate = '' OR maxDate IS NULL THEN
SELECT MAX(time) INTO maxDate FROM yt_log_role_create where server IS NOT NULL;
END IF;
END IF;
/*SET stkDate = (SELECT DATE_FORMAT(A,'%Y-%m-%d') FROM (SELECT MIN(time) AS A from yt_log_role_login_in) AS T);*/
SET stkDate = (SELECT DATE_FORMAT(minDate,'%Y-%m-%d'));
SET @diff = DATEDIFF(stkDate,maxDate);
WHILE @diff<0 DO
SET @likeTime = CONCAT(stkDate,'%');
/* */
OPEN mCursor;
/* */
mLoop: LOOP
FETCH mCursor INTO rgServer;
IF done = 1 THEN
IF @dayInterval=31 THEN
SET done = 0;
LEAVE mLoop;
END IF;
END IF;
/* */
SET @rgLikeServer = CONCAT(rgServer,'%');
SET @registerSum = (SELECT count(distinct role_id) FROM yt_log_role_create WHERE time LIKE @likeTime AND server LIKE @rgLikeServer);
# dayInterval
SET @dayInterval = 1;
WHILE @dayInterval<31 DO
SET @IntervalFlag = (select @dayInterval in (1,2,3,4,5,6,7,14,30));
/* IntervalFlag 1 dayInterval a.time <= @adLikeTime like*/
IF @IntervalFlag>0 THEN
SET @afterDate = (SELECT ADDDATE(stkDate,@dayInterval));
SET @adLikeTime = CONCAT(@afterDate,'%');
# 0 SELECT stkDate,rgServer,@dayInterval,'',@registerSum,0 ;
INSERT INTO yt.yt_keep_rate values (stkDate,rgServer,@dayInterval,'',@registerSum,0);
REPLACE INTO yt.yt_keep_rate
(SELECT stkDate,rgServer,@dayInterval,a.server,@registerSum,COUNT(distinct a.role_id) FROM yt_log_role_login_in as a INNER JOIN yt_log_role_create as r
ON a.role_id=r.role_id
WHERE r.time like @likeTime AND a.time like @adLikeTime AND r.server LIKE @rgLikeServer GROUP BY a.server);
SELECT stkDate,rgServer,@dayInterval,a.server,@registerSum,COUNT(distinct a.role_id) FROM yt_log_role_login_in as a INNER JOIN yt_log_role_create as r
ON a.role_id=r.role_id
WHERE r.time like @likeTime AND a.time like @adLikeTime AND r.server LIKE @rgLikeServer GROUP BY a.server;
/*select stkDate,@dayInterval,@afterDate,@IntervalFlag,rgServer,@registerSum,@likeTime,@adLikeTime,@rgLikeServer; */
END IF;
/*IF @registerSum >0 THEN
select stkDate,@dayInterval,@afterDate,@IntervalFlag,rgServer,@registerSum ;
END IF;*/
SET @dayInterval = @dayInterval+1;
END WHILE;
END LOOP mLoop;
SET @diff = DATEDIFF(stkDate,maxDate);
SET stkDate = (SELECT ADDDATE(stkDate,1));
/* */
CLOSE mCursor;
/*SELECT stkDate, minDate,maxDate,@diff;*/
END WHILE;
END
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
SQLite의 query로 망설임이것은 내가 처음 안드로이드 응용 프로그램 개발에서 망설이고, 그 후 해결 된 방법을 비망록으로 철자하고 있습니다. java에서 SQLite를 이용한 애플리케이션을 작성하는 동안 EditText에 입력된 item이 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.