Reputation: 31
Am trying to find the equivalent statement to below in Netezza
greatest(table1.column1, table2.column2, table3.column3)
also
least(table1.column1, table2.column2, table3.column3)
all the columns are dates
Any help is appreciated.
Upvotes: 3
Views: 12168
Reputation: 31
In newer versions of Netezza, this will also work:
max(table1.column1, table2.column2, table3.column3)
min(table1.column1, table2.column2, table3.column3)
Upvotes: 3
Reputation: 998
The Netezza SQL Extensions toolkit includes a greatest
and a least
function that take a variable number of arguments.
Upvotes: 1
Reputation: 6819
You can use a CASE WHEN
expression to duplicate the greatest
function logic:
CASE WHEN table1.column1 > table2.column2
THEN CASE WHEN table1.column1 > table3.column3
THEN table1.column1
ELSE table3.column3
END
ELSE CASE WHEN table2.column2 > table3.column3
THEN table2.column2
ELSE table3.column3
END
END
The same can be done for the least
function.
Upvotes: 1