problem with Sql least function
Ade2May 11 2009 — edited May 11 2009Hi everyone, I have a request to choose the least of dates in view definition. However, when one of the least argument is null the view picked the null value. examle,
select least(' ', '03/09/2009') test from some_view
Output
Test
Null . I want '03/09/2009' to be outputted when the other argument is null.
Please advice if their is any other function that could be used. When both arguments are not null , then the current output is outputted, however, when one is null, the the output is wrong because the null value is selected.
create or replace view some_view (Enddate)
As
Select least(table1.actual_end_date, table2.actual_end_date)
FROM
(SELECT actual_end_date
FROM some_table
where description = 'TEST') table1,
(SELECT actual_end_date AS end_date
FROM some_table
WHERE description = 'RESULT') table2