Re: coalesce seems to give strange results - Mailing list pgsql-general

From Tim Landscheidt
Subject Re: coalesce seems to give strange results
Date
Msg-id m38w5dgi29.fsf@passepartout.tim-landscheidt.de
Whole thread Raw
In response to coalesce seems to give strange results  (Richard Yen <richyen@iparadigms.com>)
List pgsql-general
Richard Yen <richyen@iparadigms.com> wrote:

> Ah, I see what you mean.  If there's no rows to return, then there's no coalesce-ing to do...

That's right, /but/ if you use a sub-select, you can achieve
something similar:

| tim=# SELECT COALESCE((SELECT ROUND(EXTRACT(epoch FROM now() - query_start))
| tim(#                    FROM pg_stat_activity
| tim(#                    WHERE current_query = '<IDLE> in transaction'),
| tim(#                 0);
|  coalesce
| ----------
|         0
| (1 Zeile)

| tim=#

> sorry for the spam.
> [...]

That wasn't spam :-).

Tim

pgsql-general by date:

Previous
From: Vincenzo Romano
Date:
Subject: Inheritance efficiency
Next
From: Ravi Katkar
Date:
Subject: Unable to create a Postgre Datasource from windows With Database installed in RHEL 5.3