Re: short-cutting if sum()>constant

From: Adam Tauno Williams <awilliam(at)opengroupware(dot)us>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: short-cutting if sum()>constant
Date: 2009-12-22 14:02:37
Message-ID: 1261490557.6467.0.camel@linux-m3mt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 2009-12-22 at 13:35 +0100, Ivan Sergio Borgonovo wrote:
> 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?

SELECT SUM(object_version)
FROM date_x
WHERE owner_id = 10100
HAVING SUM(object_version) > 1000

?

--
OpenGroupware developer: awilliam(at)whitemice(dot)org
<http://whitemiceconsulting.blogspot.com/>
OpenGroupare & Cyrus IMAPd documenation @
<http://docs.opengroupware.org/Members/whitemice/wmogag/file_view>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2009-12-22 14:12:31 Re: short-cutting if sum()>constant
Previous Message Filip Rembiałkowski 2009-12-22 13:48:55 Re: short-cutting if sum()>constant