BEGIN
Declare score int;
Select IFNULL(MAX(Reliablity),100) From AgentComputerData Join Computers Using (ComputerID),managementscore Where Computers.ClientID=CID into @score;
return @score;
END