文章日志
日志类别:数据库
2019-06-20 14:37

CREATE FUNCTION GetNuc(dd DATETIME,dy int,of int)
RETURNS NUMERIC
BEGIN
declare r NUMERIC;

declare d1 DATETIME DEFAULT dd;
declare d2 DATETIME DEFAULT DATE_ADD(dd, INTERVAL 1 DAY);

declare d1a DATETIME DEFAULT DATE_ADD(dd, INTERVAL (dy - 1) DAY);
declare d2a DATETIME DEFAULT DATE_ADD(dd, INTERVAL (dy - of) DAY);

declare count1 numeric;
declare count numeric;

set count1 = (
select count(id) as c from log_r
where time>=d1
and time and act='CreateRole'
and id IN (select distinct(id) from log_ol where time>=d1a and time );

set count = (
select count(id) as c from log_Role 
where time>=d1
and time and act='CreateRole'
);

set r = count1 / count;

return r;

END


0    0
昵称: