Function for finding the max date value from 3 columns wit a date datatype

Database
N/A

Function for finding the max date value from 3 columns wit a date datatype

Hi,

Is there a function (something like RANK) that will return the max value of 3 different columns.

Eg. All columns are DATE datatype, the Select should return the value for column c below
Column Value
------ -----
a 1000101
b 1010101
c 1020101

Thnx,
Marius
2 REPLIES

Re: Function for finding the max date value from 3 columns wit a date datatype

I believe that your options are:

1) Code a UDF. There are a set of Oracle UDF's on Teradata's web site. One of the UDF's is a "GREATEST" function, which I think does what you want to do.

2) Code a CASE statement to test the conditions and pick out the greatest value from the 3 columns.

N/A

Re: Function for finding the max date value from 3 columns wit a date datatype

Thanks Barry, I wanted to avoid the CASE statement as the number of different columns will be greater than 3 but the UDF should work.

Rgds,
Marius