pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedCOALESCE could use some better examples
2+ messages / 2 participants
[nested] [flat]
* COALESCE could use some better examples
@ 2022-10-13 14:28 PG Doc comments form <noreply@postgresql.org>
2022-10-13 19:34 ` Re: COALESCE could use some better examples Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 2+ messages in thread
From: PG Doc comments form @ 2022-10-13 14:28 UTC (permalink / raw)
To: pgsql-docs@lists.postgresql.org; +Cc: matthias01123@gmail.com
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/15/functions-conditional.html
Description:
Regarding:
https://www.postgresql.org/docs/current/functions-conditional.html
I ran into a situation where COALESCE was used like this
```
SELECT * FROM table WHERE COALESCE(col_1, col_2, col_3) >= 5
```
and didn't understand how it worked, and the examples don't really help
because they only use COALESCE like
```
SELECT COALESCE(..)
```
I asked and answered a question on stackoverflow with a pretty good example
of this, you could consider adding to your page.
Thank you :))
Stackoverflow question link:
https://stackoverflow.com/questions/74057319/coalesce-in-postgresql-conditional-displaying-seemingly...
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: COALESCE could use some better examples
2022-10-13 14:28 COALESCE could use some better examples PG Doc comments form <noreply@postgresql.org>
@ 2022-10-13 19:34 ` Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 2+ messages in thread
From: Bruce Momjian @ 2022-10-13 19:34 UTC (permalink / raw)
To: matthias01123@gmail.com; pgsql-docs@lists.postgresql.org
On Thu, Oct 13, 2022 at 02:28:23PM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/15/functions-conditional.html
> Description:
>
> Regarding:
> https://www.postgresql.org/docs/current/functions-conditional.html
>
> I ran into a situation where COALESCE was used like this
>
> ```
> SELECT * FROM table WHERE COALESCE(col_1, col_2, col_3) >= 5
> ```
>
> and didn't understand how it worked, and the examples don't really help
> because they only use COALESCE like
>
> ```
> SELECT COALESCE(..)
> ```
>
> I asked and answered a question on stackoverflow with a pretty good example
> of this, you could consider adding to your page.
>
> Thank you :))
>
> Stackoverflow question link:
> https://stackoverflow.com/questions/74057319/coalesce-in-postgresql-conditional-displaying-seemingly...
I read the Stackoverflow thread and it seems you thought a column name
in the function in a WHERE clause should span all the rows looking for
the first non-NULL row, and only if they are all NULL, go to th next
parameter. All WHERE functions are row-based so I don't see how to
actually improve our doc text without making it more confusing. Sorry.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
Indecision is a decision. Inaction is an action. Mark Batterson
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2022-10-13 19:34 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 14:28 COALESCE could use some better examples PG Doc comments form <noreply@postgresql.org>
2022-10-13 19:34 ` Bruce Momjian <bruce@momjian.us>
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