Re: Specifying text to substitute for NULLs in selects

Поиск
Список
Период
Сортировка
От Mike Toews
Тема Re: Specifying text to substitute for NULLs in selects
Дата
Msg-id 4914BB85.60400@sfu.ca
обсуждение исходный текст
Ответ на Re: Specifying text to substitute for NULLs in selects  (Mike Toews <mwtoews@sfu.ca>)
Список pgsql-general
Mike Toews wrote:
> Keep in mind that you can't mix data types, like 'NaN'::text and
> 32.3::float in the result.

oh yeah, regarding mixing data types (in regards to the first post)...

A good exception is that you can use 'NaN' for floating point data
types, so:

    SELECT COALESCE(myval, 'NaN') as myval FROM foo;

where "myval" is a field with a floating-point data type. This maneuver
is sometimes preferred in some aggregates like sum() where you don't
want to take sums on incomplete sets since NULL is counted as 0 whereas
a single NaN value forces the resulting sum to be NaN.

There are other special floats like 'Infinity' and '-Infinity', which
can also be coalesced in for NULL float values:
http://www.postgresql.org/docs/current/interactive/datatype-numeric.html

-Mike

В списке pgsql-general по дате отправления:

Предыдущее
От: Jason Long
Дата:
Сообщение: archive command Permission Denied?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: archive command Permission Denied?