Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26766475B99 for ; Mon, 28 Oct 2002 03:21:24 -0500 (EST) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by postgresql.org (Postfix) with SMTP id F1DD44758F1 for ; Mon, 28 Oct 2002 03:21:22 -0500 (EST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon Oct 28 09:20:32 2002 +0100 Received: œby rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA23745; Mon, 28 Oct 2002 09:20:32 +0100 (MET) Message-ID: <3DBCF34F.9F6ACBA8@rodos.fzk.de> Date: Mon, 28 Oct 2002 09:20:31 +0100 From: Christoph Haller X-Mailer: Mozilla 4.06 [en] (X11; I; HP-UX B.10.20 9000/780) MIME-Version: 1.0 To: kabai@audiobox.hu Cc: pgsql-sql@postgresql.org Subject: Re: Accumulated sums in SQL query Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/368 X-Sequence-Number: 10085 > Which is the simplest way to create an SQL query to get accumulated sums of > records like this (from the table containing the numbers): > > number sums > --------------- > 1 1 > 2 3 > 3 6 > 4 10 > SELECT number, SUM(your_sum_column) FROM your_table GROUP BY number ; Regards, Christoph