pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Filip Rembiałkowski <plk.zuber@gmail.com>
To: Ivan Sergio Borgonovo <mail@webthatworks.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: short-cutting if sum()>constant
Date: Tue, 22 Dec 2009 14:48:55 +0100
Message-ID: <92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com> (raw)
In-Reply-To: <20091222133527.3007bd96@dawn.webthatworks.it>
References: <20091222133527.3007bd96@dawn.webthatworks.it>

2009/12/22 Ivan Sergio Borgonovo <mail@webthatworks.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@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>



-- 
Filip Rembiałkowski
JID,mailto:filip.rembialkowski@gmail.com
http://filip.rembialkowski.net/

view thread (23+ messages)  latest in thread

Message-ID: <92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com>
Permalink:  ../92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com/
Also on:    postgresql.org/message-id/92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: plk.zuber@gmail.com, mail@webthatworks.it
  Subject: Re: short-cutting if sum()>constant
  In-Reply-To: <92869e660912220548j43a4528fu28b1389477e9fb1c@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox