Re: if-clause to an exiting statement
| От | Adrian Klaver |
|---|---|
| Тема | Re: if-clause to an exiting statement |
| Дата | |
| Msg-id | 4CFE7F99.5020004@gmail.com обсуждение исходный текст |
| Ответ на | if-clause to an exiting statement (Kobi Biton <kobi@comns.co.il>) |
| Список | 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 по дате отправления: