Re: if-clause to an exiting statement - Mailing list pgsql-general

From Adrian Klaver
Subject Re: if-clause to an exiting statement
Date
Msg-id 4CFE7F99.5020004@gmail.com
Whole thread Raw
In response to if-clause to an exiting statement  (Kobi Biton <kobi@comns.co.il>)
List 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> 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> now() - interval '10 minutes')




--
Adrian Klaver
adrian.klaver@gmail.com

pgsql-general by date:

Previous
From: "Massa, Harald Armin"
Date:
Subject: is anyone from the pokertracker.com within this mailing list?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Do we want SYNONYMS?