pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedrunning aggregates
2+ messages / 2 participants
[nested] [flat]
* running aggregates
@ 2003-09-01 20:46 Glenn <gdavy@tpg.com.au>
2003-09-04 19:56 ` Re: running aggregates Tomasz Myrta <jasiek@klaster.net>
0 siblings, 1 reply; 2+ messages in thread
From: gdavy@tpg.com.au @ 2003-09-01 20:46 UTC (permalink / raw)
To: pgsql-sql
f1 sum_f1 avg_f1 pseudo_recno
10 10 10 1
20 30 15 2
30 60 20 3
40 100 25 4
50 150 30 5
60 210 35 6
I know I can do this by iterating with a plpgsql routine, but there must
be a means simply using SQL
Thanks in advance
Glenn
ps sorry if this isn't the appropriate use for this forum
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: running aggregates
2003-09-01 20:46 running aggregates Glenn <gdavy@tpg.com.au>
@ 2003-09-04 19:56 ` Tomasz Myrta <jasiek@klaster.net>
0 siblings, 0 replies; 2+ messages in thread
From: Tomasz Myrta @ 2003-09-04 19:56 UTC (permalink / raw)
To: Glenn <gdavy@tpg.com.au>; +Cc: pgsql-sql
> f1 sum_f1 avg_f1 pseudo_recno
> 10 10 10 1
> 20 30 15 2
> 30 60 20 3
> 40 100 25 4
> 50 150 30 5
> 60 210 35 6
>
> I know I can do this by iterating with a plpgsql routine, but there must
> be a means simply using SQL
select f1
t1.f1,
sum(t2.f1) as sum_f1,
avg(t2.f1) as avg_f1,
count(*) as pseudo_recno
from
ttt t1
join ttt t2 on (t2.f1<=t1.t1)
group by t1.f1
order by t1.f1;
Regards,
Tomasz Myrta
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-09-04 19:56 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-01 20:46 running aggregates Glenn <gdavy@tpg.com.au>
2003-09-04 19:56 ` Tomasz Myrta <jasiek@klaster.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox