On Mon, Oct 3, 2016 at 6:39 AM, dudedoe01 <[email protected]> wrote:
> What is the most feasible way to emulate the below MySQL function into
> postgreSQL. Since the isnull() function is no longer supported in 9.6
> version. I have tried every trick in the hat to get the desired results.
> Still 'RPG INV' doesn't show only the other two then options show up.
>
> (case
> when
> ((`s`.`Funding_Date` = '')
> and (isnull(`s`.`Actual_Close_Date`)
> or (`s`.`Actual_Close_Date` = '')))
> then
> 'RPG_INV'
> when
> ((isnull(`s`.`Funding_Date`)
> or (`s`.`Funding_Date` <> ''))
> and ((`s`.`Actual_Close_Date` = '')
> or isnull(`s`.`Actual_Close_Date`)))
> then
> 'Builder_Inventory'
> else 'Owner_Inventory'
> end) AS `Lot_Status`
>
>
​If you include something like the following people are going to be more
willing to provide help and better able to provide good help.
WITH dt (funding_date, actual_date) AS (
VALUES (null, null), ('X', 'X'),
(null, ''), (null, 'X'),
('', null), ('X', null)
)
SELECT funding_date, actual_date,
CASE WHEN funding_date IS NULL
AND actual_date IS NULL
THEN 'Both Null'
ELSE 'write more WHEN statements...'
END
FROM dt
​;
That's a self-contained example and it does wonders for problem solving.
David J.
​