Re: if-clause to an exiting statement

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Kobi Biton <kobi(at)comns(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: if-clause to an exiting statement
Date: 2010-12-07 18:40:25
Message-ID: 4CFE7F99.5020004@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/07/2010 08:04 AM, Kobi Biton wrote:
> Adrian hi,
>
> Thanks for the reply can you please show me how to incorporate the below
> into my below statement ?
>
> SELECT a.eventuei AS _eventuei,
> a.nodeid AS _nodeid,
> a.ipaddr AS _ipaddr,
> now() AS _ts
> FROM events a
> WHERE
> eventuei='uei.opennms.org/comns/backup-success-trap' AND
> (eventcreatetime&gt; now() - interval '10 minutes')
>
> Thanks!
> Kobi
>

>>
>

Not sure this is what you want but here, reminder count(*) can have
performance issues for large values of count():

SELECT a.eventuei AS _eventuei,
case count(*) when 0
then 1
else
count(*)
end
AS _ct,
a.nodeid AS _nodeid,
a.ipaddr AS _ipaddr,
now() AS _ts
FROM events a
WHERE
eventuei='uei.opennms.org/comns/backup-success-trap' AND
(eventcreatetime&gt; now() - interval '10 minutes')

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2010-12-07 18:45:02 Re: Do we want SYNONYMS?
Previous Message Jaiswal Dhaval Sudhirkumar 2010-12-07 18:39:40 Tool for data modeling and ER diagram