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

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

pgsql-novice by date

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

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