Re: short-cutting if sum()>constant

From: Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>
To: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: short-cutting if sum()>constant
Date: 2009-12-22 13:48:55
Message-ID: 92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2009/12/22 Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>

> Hi,
>

Hi :-)

>
> I'd like to know if
>
> select sum(qty) from t where status=37;
>
> is > constant.
>
> qty is always >0.
>
> Is there a way to skip examining further rows and return a result
> ASAP?
>

With plain SQL, no.

With a user defined function in PL/PgSQL, yes.

>
>
> --
> Ivan Sergio Borgonovo
> http://www.webthatworks.it
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

--
Filip Rembiałkowski
JID,mailto:filip(dot)rembialkowski(at)gmail(dot)com
http://filip.rembialkowski.net/

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Adam Tauno Williams 2009-12-22 14:02:37 Re: short-cutting if sum()>constant
Previous Message Ivan Sergio Borgonovo 2009-12-22 12:35:27 short-cutting if sum()>constant