So you're looking for max(abs(diff(a,b))). Well, yeah. I've gotta lotta cool ideas. The best: Pleas post concise and complete samples. This means table DDL and sample data INSERT statments as a runnable T-SQL script.
DECLARE @DataSet1 TABLE ( A INT );
DECLARE @DataSet2 TABLE ( B INT );
INSERT INTO @DataSet1
VALUES ( 120 );
INSERT INTO @DataSet2
VALUES ( 250 ),
( 60 );
WITH [Difference]
AS ( SELECT DS1.A - DS2.B AS [Value]
FROM @DataSet1 DS1
CROSS JOIN @DataSet2 DS2
)
SELECT [Value]
FROM [Difference]
WHERE ABS([Value]) = ( SELECT MAX(ABS([Value]))
FROM [Difference]
);
No comments:
Post a Comment