Re: coalesce seems to give strange results

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: coalesce seems to give strange results
Date: 2010-07-15 10:23:10
Message-ID: m38w5dgi29.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Yen <richyen(at)iparadigms(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ravi Katkar 2010-07-15 10:57:11 Unable to create a Postgre Datasource from windows With Database installed in RHEL 5.3
Previous Message Craig Ringer 2010-07-15 09:59:01 Re: Planner features, discussion