DECLARE @a INT,@b INT,@c INT=0;
DECLARE @ABC TABLE(id INT identity(1,1),stock int,month INT);
BEGIN
INSERT INTO @ABC(Stock,month) SELECT Stock,Month FROM ABC;
WHILE @c<=(SELECT COUNT(1) FROM @ABC)
BEGIN
SELECT @a=Stock,@b=month FROM @ABC WHERE ID=@c;
if @a>@b
SELECT @a;
ELSE
SELECT @b;
SET @c=@c+1;
END;
END;