Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

Next:From: A. KretschmerDate: 2009-12-22 14:12:31
Subject: Re: short-cutting if sum()>constant
Previous:From: Filip RembiaƂkowskiDate: 2009-12-22 13:48:55
Subject: Re: short-cutting if sum()>constant

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group