Please, read my comment first. You have to modify your SQL statement to be able to get result as expected.
Take a look at below example:
DECLARE @tmp TABLE (branch INT, number INT, val INT)
INSERT INTO @tmp (branch, number, val)
VALUES(1, 50, 200),
(5, 2, 150),
(1, 1, 200),
(3, 4, 300)
SELECT DISTINCT [branch], MAX([number]) OVER (PARTITION BY [branch] ORDER BY number DESC) AS [number], [val]
FROM @tmp
Result:
branch number val
1 50 200
3 4 300
5 2 150