1
BEGIN
2
Declare score int;
3
Declare result int;
4
Declare Total int;
5
SELECT 1 As Result,
6
1 as Total, IFNULL(ROUND(100-((SUM(IF(h_DriveStatsDaily.Free<DriveSpaceLevel,1*(DriveSpaceWeight *.01),0)) +
7
SUM(IF(h_DriveStatsDaily.Frag>DriveFragLevel,1*(DriveFragWeight*.01),0)))/
8
((Count(*) * (1*(DriveSpaceWeight *.01)))+(Count(*) * (1*(DriveFragWeight*.01))))) *100),100) as DriveScore
9
FROM managementScore,h_DriveStatsDaily Join Drives Using (DriveID) Join Computers Using (ComputerID) Where h_DrivestatsDaily.EventDate=DATE(DATE_ADD(CURDATE(),interval -1 day)) and Computers.ClientID=CID into @result,@total,@score;
10
return @score;
11
END