dwain.c (9/12/2012)
Another way:
;WITH MyValues AS (
SELECT Id
,A=CASE WHEN A > 0 THEN A ELSE 2147483647 END
,B=CASE WHEN B > 0 THEN B ELSE 2147483647 END
,C=CASE WHEN C > 0 THEN C ELSE 2147483647 END
FROM #MinAmt)
SELECT Id
,MinAmt=CASE
WHEN A < B THEN CASE WHEN A < C THEN A ELSE C END
WHEN B < A THEN CASE WHEN B < C THEN B ELSE C END
ELSE CASE WHEN C < A THEN C ELSE A END END
FROM MyValues
BTW. You didn't specify what to return if all values are <= 0.
You also need to deal with the case where the values are null.
You code returns 2147483647 when they are all <1 or null, and I doubt that is what they would want.
Returning a null probably makes the most sense for that case.