Description
Calculate how many mugs StackExchange should give away(for graduation) to top reputed users on codereview.stackexchange.com so I'll also receive one. (output is divisible by 50).
Code
DECLARE @mugs INT,@rounded_mugs INT,@inc INT,@remainder INT;
SELECT @mugs = COUNT(1) FROM Users WHERE Reputation >=
(SELECT Reputation FROM Users WHERE DisplayName='JaDogg');
SET @remainder = @mugs%50;
IF (@remainder = 0) SET @inc = 0 ELSE SET @inc=50-@remainder;
SELECT @mugs+@inc AS 'AMOUNT OF MUGS TO GIVE AWAY';
username
parameter ;) \$\endgroup\$