select progressive total - Mailing list pgsql-general

From brian
Subject select progressive total
Date
Msg-id 46003F95.3070708@zijn-digital.com
Whole thread Raw
Responses Re: select progressive total  ("Merlin Moncure" <mmoncure@gmail.com>)
List pgsql-general
 From the "I thought this would be trivially easy" dept:

I have a table holding member data for an organisation

CREAT table member (
    id    SERIAL PRIMARY KEY,
    applied    date,
...

and i'd like to plot the growth in memberships. I'd prefer to hand off
the data already totaled, if possible.

'2006-02-01', 452
'2006-02-17', 453
...

It semed to me that a self join was the way to go, but that route
produced some flaky results. Here's my latest attempt:

SELECT m1.applied AS date_applied, count(m2.id) AS num_applications
    FROM member m1, member m2 WHERE m1.applied <= m2.applied
    GROUP BY m1.applied ORDER BY date_applied ASC;

The thing is, some applications fell on the same day, so i'm not even
sure that this approach would work. Can anyone see where i'm going wrong
here? And how can i handle applications that occurred on the same day?
Can this even be done in a SELECT, or should i create a function?

b

pgsql-general by date:

Previous
From: "Andrej Ricnik-Bay"
Date:
Subject: Re: Postgresql to Delphi
Next
From: Richard Huxton
Date:
Subject: Re: Postgresql to Delphi