the highest of the two values? Something like:
Acct Total_Dollars Collected Total_Dollars_Due
11233 900.00 1000.00
Declare @.Value as money
set @.Value=GetHighest(Total_Dollars_Collected,TotalDol lars_Due)
Print @.Value
This function will return 1000.00 or the Total_dollars_Due??
Is there such a creature?On 21 Sep 2004 08:41:16 -0700, Philip Mette wrote:
>Is there a function that compares two columns in a row and will return
>the highest of the two values? Something like:
>Acct Total_Dollars Collected Total_Dollars_Due
>11233 900.00 1000.00
>Declare @.Value as money
>set @.Value=GetHighest(Total_Dollars_Collected,TotalDol lars_Due)
>Print @.Value
>
>This function will return 1000.00 or the Total_dollars_Due??
>Is there such a creature?
Hi Philip,
No. But you can create a user-defined function, if you wish. Or simply use
a CASE expression:
SET @.Value = CASE WHEN a > b THEN a ELSE b END
The user-defined function might be more friendly to the eyes. Using the
CASE expression wherever you need it might be a little bit less readable,
but it will probably perform better.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||>> Is there a function that compares two columns in a row and will
return the highest of the two values? <<
in Oracle, there is a general GREATEST(<list>) function, but in
Standard SQL and T-SQL you nedd to use a CASE expression.
No comments:
Post a Comment