pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedcoalesce
9+ messages / 5 participants
[nested] [flat]
* coalesce
@ 2011-09-21 12:34 Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
0 siblings, 1 reply; 9+ messages in thread
From: Henry Drexler @ 2011-09-21 12:34 UTC (permalink / raw)
To: pgsql-docs
http://www.postgresql.org/docs/9.1/static/functions-conditional.html
states: "The COALESCE function returns the first of its arguments that is
not null. Null is returned only if all arguments are null."
I was having a terrible time understanding this, and looking at the two
examples were just as confusing I could not get it to work right.
not sure if others have had the same difficulty, but here are my suggested
adjustments:
Then on someones website this made perfect sense to me:
" If the results of the first argument are null, it will return the
second."
so I made this example that makes sense:
COALESCE(column,substitute value)
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
@ 2011-09-21 14:33 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Kevin Grittner @ 2011-09-21 14:33 UTC (permalink / raw)
To: Henry Drexler <alonup8tb@gmail.com>; pgsql-docs
Henry Drexler <alonup8tb@gmail.com> wrote:
> "If the results of the first argument are null, it will return the
> second."
Unless the second is also null, in which case it will return the
third. Unless the third is also null...
The trick is to come up with language which recognizes that there
can be any number of arguments. Personally, I think the existing
language does a good job of that, and is pretty clear.
> so I made this example that makes sense:
>
> COALESCE(column,substitute value)
Perhaps a two-argument example would be helpful, as long as it
doesn't mislead people into thinking the construct is limited to two
arguments.
-Kevin
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
@ 2011-09-21 15:50 ` Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
0 siblings, 1 reply; 9+ messages in thread
From: Henry Drexler @ 2011-09-21 15:50 UTC (permalink / raw)
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: pgsql-docs
thanks,
so I take it I am not getting those more complex examples (that are
apparently beyond my use case), I will take a look at them again.
Thank you for the feedback.
On Wed, Sep 21, 2011 at 10:33 AM, Kevin Grittner <
Kevin.Grittner@wicourts.gov> wrote:
> Henry Drexler <alonup8tb@gmail.com> wrote:
>
> > "If the results of the first argument are null, it will return the
> > second."
>
> Unless the second is also null, in which case it will return the
> third. Unless the third is also null...
>
> The trick is to come up with language which recognizes that there
> can be any number of arguments. Personally, I think the existing
> language does a good job of that, and is pretty clear.
>
> > so I made this example that makes sense:
> >
> > COALESCE(column,substitute value)
>
> Perhaps a two-argument example would be helpful, as long as it
> doesn't mislead people into thinking the construct is limited to two
> arguments.
>
> -Kevin
>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
@ 2011-09-21 16:37 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-10-05 01:04 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
2011-10-05 01:47 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 9+ messages in thread
From: Alvaro Herrera @ 2011-09-21 16:37 UTC (permalink / raw)
To: Henry Drexler <alonup8tb@gmail.com>; +Cc: Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
Excerpts from Henry Drexler's message of mié sep 21 12:50:18 -0300 2011:
> thanks,
>
> so I take it I am not getting those more complex examples (that are
> apparently beyond my use case), I will take a look at them again.
Maybe the fix is just to add a simpler example, without altering the
wording (which seems pretty clear to me as well, but then I already know
what COALESCE does).
--
Álvaro Herrera <alvherre@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
@ 2011-10-05 01:04 ` Bruce Momjian <bruce@momjian.us>
1 sibling, 0 replies; 9+ messages in thread
From: Bruce Momjian @ 2011-10-05 01:04 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: Henry Drexler <alonup8tb@gmail.com>; Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
Alvaro Herrera wrote:
>
> Excerpts from Henry Drexler's message of mié sep 21 12:50:18 -0300 2011:
> > thanks,
> >
> > so I take it I am not getting those more complex examples (that are
> > apparently beyond my use case), I will take a look at them again.
>
> Maybe the fix is just to add a simpler example, without altering the
> wording (which seems pretty clear to me as well, but then I already know
> what COALESCE does).
The current example is:
SELECT COALESCE(description, short_description, '(none)') ...
What would a simpler one look like?
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
@ 2011-10-05 01:47 ` Bruce Momjian <bruce@momjian.us>
2011-10-05 02:09 ` Re: coalesce Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 9+ messages in thread
From: Bruce Momjian @ 2011-10-05 01:47 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@commandprompt.com>; +Cc: Henry Drexler <alonup8tb@gmail.com>; Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
Alvaro Herrera wrote:
>
> Excerpts from Henry Drexler's message of mié sep 21 12:50:18 -0300 2011:
> > thanks,
> >
> > so I take it I am not getting those more complex examples (that are
> > apparently beyond my use case), I will take a look at them again.
>
> Maybe the fix is just to add a simpler example, without altering the
> wording (which seems pretty clear to me as well, but then I already know
> what COALESCE does).
Here is a doc patch that at least explains the example. Applied.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
/rtmp/coalesce (text/x-diff, 532B) download
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
new file mode 100644
index 0b6a109..2f307c2
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
*************** SELECT ... WHERE CASE WHEN x <> 0
*** 10015,10020 ****
--- 10015,10022 ----
<programlisting>
SELECT COALESCE(description, short_description, '(none)') ...
</programlisting>
+ This returns <varname>description</> if it is not null, or
+ <varname>short_description</> if it is not null, or <literal>(none)</>.
</para>
<para>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
2011-10-05 01:47 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
@ 2011-10-05 02:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-05 02:39 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 9+ messages in thread
From: Tom Lane @ 2011-10-05 02:09 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; Henry Drexler <alonup8tb@gmail.com>; Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
Bruce Momjian <bruce@momjian.us> writes:
> Here is a doc patch that at least explains the example. Applied.
I think s/or/otherwise/ (both places) would make that read better.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
2011-10-05 01:47 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
2011-10-05 02:09 ` Re: coalesce Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-10-05 02:39 ` Bruce Momjian <bruce@momjian.us>
2011-10-05 18:33 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
0 siblings, 1 reply; 9+ messages in thread
From: Bruce Momjian @ 2011-10-05 02:39 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@commandprompt.com>; Henry Drexler <alonup8tb@gmail.com>; Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> > Here is a doc patch that at least explains the example. Applied.
>
> I think s/or/otherwise/ (both places) would make that read better.
Done with the attached patch.
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
Attachments:
/rtmp/coalesce2 (text/x-diff, 817B) download
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
new file mode 100644
index 2f307c2..bedd8ba
*** a/doc/src/sgml/func.sgml
--- b/doc/src/sgml/func.sgml
*************** SELECT ... WHERE CASE WHEN x <> 0
*** 10015,10022 ****
<programlisting>
SELECT COALESCE(description, short_description, '(none)') ...
</programlisting>
! This returns <varname>description</> if it is not null, or
! <varname>short_description</> if it is not null, or <literal>(none)</>.
</para>
<para>
--- 10015,10022 ----
<programlisting>
SELECT COALESCE(description, short_description, '(none)') ...
</programlisting>
! This returns <varname>description</> if it is not null, otherwise
! <varname>short_description</> if it is not null, otherwise <literal>(none)</>.
</para>
<para>
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: coalesce
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Re: coalesce Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Re: coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Re: coalesce Alvaro Herrera <alvherre@commandprompt.com>
2011-10-05 01:47 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
2011-10-05 02:09 ` Re: coalesce Tom Lane <tgl@sss.pgh.pa.us>
2011-10-05 02:39 ` Re: coalesce Bruce Momjian <bruce@momjian.us>
@ 2011-10-05 18:33 ` Henry Drexler <alonup8tb@gmail.com>
0 siblings, 0 replies; 9+ messages in thread
From: Henry Drexler @ 2011-10-05 18:33 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Alvaro Herrera <alvherre@commandprompt.com>; Kevin Grittner <kevin.grittner@wicourts.gov>; pgsql-docs
That is certainly clearer - thank you.
On Tue, Oct 4, 2011 at 10:39 PM, Bruce Momjian <bruce@momjian.us> wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce@momjian.us> writes:
> > > Here is a doc patch that at least explains the example. Applied.
> >
> > I think s/or/otherwise/ (both places) would make that read better.
>
> Done with the attached patch.
>
> --
> Bruce Momjian <bruce@momjian.us> http://momjian.us
> EnterpriseDB http://enterprisedb.com
>
> + It's impossible for everything to be true. +
>
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~2011-10-05 18:33 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 12:34 coalesce Henry Drexler <alonup8tb@gmail.com>
2011-09-21 14:33 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-09-21 15:50 ` Henry Drexler <alonup8tb@gmail.com>
2011-09-21 16:37 ` Alvaro Herrera <alvherre@commandprompt.com>
2011-10-05 01:04 ` Bruce Momjian <bruce@momjian.us>
2011-10-05 01:47 ` Bruce Momjian <bruce@momjian.us>
2011-10-05 02:09 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-10-05 02:39 ` Bruce Momjian <bruce@momjian.us>
2011-10-05 18:33 ` Henry Drexler <alonup8tb@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox