Re: caculating while select - maybe sum ?

From: Ben-Nes Michael <miki(at)canaan(dot)co(dot)il>
To: Frank Bax <fbax(at)sympatico(dot)ca>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: caculating while select - maybe sum ?
Date: 2002-02-05 16:41:16
Message-ID: 200202051641.g15GfGJ01714@mikispc.canaan.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Nope, I mean:

a column from table:
1
2
7
4

select row1, sum (row1 until current row) from table;

Result:
1 | 1
2 | 3
7 | 10
4 | 14

the second column is like sum() of all the rows until/include this row.

Sorry for being ambigious

On Tuesday 05 February 2002 18:21, Frank Bax wrote:
> I'm not quite sure what you're asking for; but it shoulds like you want:
> age(timestamp,timestamp) => interval
> For example:
> select age('2002-12-25',now());
> age
> --------------------------
> 10 mons 19 days 12:30:28
> (1 row)
>
> Frank
>
> At 04:17 PM 2/5/02 +0200, Ben-Nes Michael wrote:
> >Hi All
> >
> >im trying to calculate hour usage so a typical row is: 1. enter time, 2.
> >exit time 3. sum() until this row
> >
> >Couldn't use sum() as it ask me to 'group by' which I don't want.
> >
> >Is there a way to add the previous row value to the current, per row ?
> >
> >example:
> >select row1, row2, (row1 + row2 until now) from table;
> >
> >--------------------------
> >Canaan Surfing Ltd.
> >Internet Service Providers
> >Ben-Nes Michael - Manager
> >Tel: 972-4-6991122
> >http://sites.canaan.co.il
> >--------------------------

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-05 16:48:03 Re: Re :Solaris Performance
Previous Message Frank Bax 2002-02-05 16:21:25 Re: caculating while select - maybe sum ?