Re: isnull() function in pgAdmin3

Поиск
Список
Период
Сортировка
Искать
От
Kevin Grittner
Тема
Re: isnull() function in pgAdmin3
Дата
Msg-id
CACjxUsOkFgiGKRjmhWonE3yfiPpsrn9dsmHW+9KaZSh9RWB_ow@mail.gmail.com
Ответ на
Список
Дерево обсуждения
isnull() function in pgAdmin3 dudedoe01 <marsalanaq@gmail.com>
Re: isnull() function in pgAdmin3 Adrian Klaver <adrian.klaver@aklaver.com>
Re: isnull() function in pgAdmin3 Kevin Grittner <kgrittn@gmail.com>
Re: isnull() function in pgAdmin3 dudedoe01 <marsalanaq@gmail.com>
Re: isnull() function in pgAdmin3 Adrian Klaver <adrian.klaver@aklaver.com>
Re: isnull() function in pgAdmin3 dudedoe01 <marsalanaq@gmail.com>
Re: isnull() function in pgAdmin3 Alexander Farber <alexander.farber@gmail.com>
Re: isnull() function in pgAdmin3 Kevin Grittner <kgrittn@gmail.com>
Re: isnull() function in pgAdmin3 Igor Neyman <ineyman@perceptron.com>
Re: isnull() function in pgAdmin3 Thomas Kellerer <spam_eater@gmx.net>
On Tue, Sep 27, 2016 at 12:04 PM, dudedoe01  wrote:

> I am trying to emulate the isnull() function used in MySQL into postreSQL.

In the future, please describe the results you are trying to achieve
or at least describe the semantics of the function from elsewhere that
you are trying to emulate.  I had no idea what the ISNLL() function of
MySQL does; on a quick web search, it looks like you can replace:
  isnull(expression)

with:

  (expression) IS NULL


> In MySQL:
>
> (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`,

In PostgreSQL perhaps:

(case
            when
                (("s"."Funding_Date" = '')
                    and (("s"."Actual_Close_Date") is null
                    or ("s"."Actual_Close_Date" = '')))
            then
                'RPG_INV'
            when
                ((("s"."Funding_Date") is null
                    or ("s"."Funding_Date" <> ''))
                    and (("s"."Actual_Close_Date" = '')
                    or ("s"."Actual_Close_Date") is null))
            then
                'Builder_Inventory'
            else 'Owner_Inventory'
        end) AS "Lot_Status",

-- 
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

В списке pgsql-general по дате отправления
От: Adrian Klaver
Дата:
От: Israel Brewster
Дата:
Сообщение: Re: Determining server load
FAQ