Re: query

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Ankur Arora <"Ankur Arora"(at)clear(dot)net(dot)nz>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: query
Date: 2004-01-19 05:20:13
Message-ID: 20040119052013.GA19053@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sun, Jan 18, 2004 at 00:02:42 +1300,
Ankur Arora <"Ankur Arora"@clear.net.nz> wrote:
> hello there
> i have a problem
> i want to know the query for finding out aggregate
>
> eg. i have a column named sum in table xyz
>
> sum
> ----
> 2
> 4
> 7
> 5
>
>
> i want a sql query that will give me another column alongwith this column as
> aggregate
>
> sum aggregate
> -----
> 2 2
> 4 6
> 7 13
> 5 18
>
>
> if u could help me i will be obliged as i really need it on urgent basis

Its possible to do something like this with subqueries as long as there
is some way (e.g. additional columns) to order the table.

Then you could do something like:

select "sum", (select sum("sum") from xyz b where b.id <= a.id) from xyz a
order by id;
This assumes there is a column named id which can be used to order the data.

In response to

  • query at 2004-01-17 11:02:42 from Ankur Arora

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2004-01-19 07:50:44 Re: Discarding UNIQUE temporarily?
Previous Message Tom Lane 2004-01-19 04:32:25 Re: installing postgre