how to select rows for a sum function

From: e-letter <inpost(at)gmail(dot)com>
To: pgsql-novice-owner(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org
Subject: how to select rows for a sum function
Date: 2011-05-22 07:57:08
Message-ID: BANLkTinqrF5C9hB6cbkPhmK6kb7tq+dHcw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Readers,

For a table:

value name
10 text1
20 text2
30 text3
40 text4

The function SELECT ... WHERE cannot be used with an aggregate
function SUM. Is it possible to obtain a result of the rows where the
SUM<=number? Ideally, to obtain rows where the sum of values is
between an upper and lower value, e.g. if the target range is >=50 and
<=60, the result would be:

text1
text2
text3

or

text2
text4

Each result should go into a separate table

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Birchall, Austen 2011-05-23 10:56:05 pg_stop_backup fails to complete
Previous Message Mike Thomsen 2011-05-20 17:05:09 Log user creation and deletion