Main rule is never to use float, because of unwanted effetcs:
Here the version with decimal. It always is correct.
DECLARE @SumA float, @SumB float
DECLARE @MyFloat1 float, @MyFloat2 float, @MyFloat3 float
DECLARE @MyTable table
(
ID int primary key identity,
NumA DECIMAL(17,0),
NumB DECIMAL(17,0)
)
SET @MyFloat1 = 10000000000020000
SET @MyFloat2 = -10000000000010000
SET @MyFloat3 = 1
INSERT INTO @MyTable
SELECT @MyFloat1, CAST(@MyFloat3 AS FLOAT)
UNION
SELECT @MyFloat2, @MyFloat1
UNION ALL
SELECT @MyFloat3, @MyFloat2
SELECT SUM(NumA), SUM(NumB) FROM
(select top 100 * from @MyTable
order by 1
) AS A
SELECT SUM(NumA), SUM(NumB) FROM
(select top 100 * from @MyTable
order by 2
) AS B