It seems that you are looking for something like this:

DECLARE @DataSource TABLE
(
    [RowID] INT
   ,[given] INT
);

INSERT INTO @DataSource ([RowID], [given])
VALUES (1, 10)
      ,(2, 15)
      ,(3, 12)
      ,(4, 14)
      ,(5, 20);

SELECT [given]
      ,MAX([given]) OVER (ORDER BY [RowID])
FROM @DataSource;

enter image description here

You can check the OVER clause as you may need to use PARTITION BY or ROWS BETWEEN in your real case.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top