>I think I should know this but..........
>
>I have a DB2 table with fields Num1, Num2, Num3 (among others)
>
>I need to get the largest of the three numeric fields.
>
>Clearly SELECT MAX(Num1, Num2, Num3) FROM mytable won't work, but it seems as if there ought to be some simple equivalent. I just haven't been able to find it.
>
>Can somebody point me in the right direction?
>
>Thanks.........Rich
I can't remember CASE syntax well, but it must be something like:
SELECT "MaxNum" = CASE
WHEN Num1 >= Num2 AND Num1 >= Num3 THEN Num1
WHEN Num2 >= Num1 AND Num2 >= Num3 THEN Num2
WHEN Num3 >= Num1 AND Num3 >= Num2 THEN Num3
ELSE Num1
END
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.