Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D9AA89FB450 for ; Mon, 12 Feb 2007 11:41:15 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 50939-08 for ; Mon, 12 Feb 2007 11:41:11 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.238]) by postgresql.org (Postfix) with ESMTP id 5134A9FB383 for ; Mon, 12 Feb 2007 11:41:12 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so1755354wxd for ; Mon, 12 Feb 2007 07:41:11 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=RrXuOlD7KSncGuNIUaH11OxYmDRU9Rkr9B+R7M+yJYbQSEE9pskQgz9bCbSnHImtZD/bH3tmuo3XF1CofyxcX8zXjBkHi6WCIlwPXG2RFGSsyINgJZnQl3nWLX5r4+j1t+8BlugynwRIi2Mxfcxt+Pc/xNhWHmT0Tv0ycie4e3I= Received: by 10.90.56.14 with SMTP id e14mr4271304aga.1171294871017; Mon, 12 Feb 2007 07:41:11 -0800 (PST) Received: by 10.66.217.13 with HTTP; Mon, 12 Feb 2007 07:41:10 -0800 (PST) Message-ID: <55c095e90702120741w3908f730vbd23b6d9b4fa7cc3@mail.gmail.com> Date: Mon, 12 Feb 2007 12:41:10 -0300 From: "Ezequias Rodrigues da Rocha" To: pgsql-sql@postgresql.org Subject: Sum sets of records MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_76524_1691270.1171294870780" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.344 tagged_above=0 required=5 tests=AWL, BAYES_50, HTML_40_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/138 X-Sequence-Number: 27472 ------=_Part_76524_1691270.1171294870780 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi list, I would like a little help from you to get the sum value of various subsets of my table. My table is like this id | type | value 1 C 10.00 2 C 15.00 3 W 5.00 4 W 3.00 Where C is credit and w is witdraw. How do I sum all records with C and subtract with all records with type W ? Is it possible ? Ezequias ------=_Part_76524_1691270.1171294870780 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi list,

I would like a little help from you to get the sum value of various subsets of my table.

My table is like this

id | type | value
1   C       10.00
2   C       15.00
3  W        5.00
4  W        3.00

Where C is credit and w is witdraw.

How do I sum all records with C and subtract with all records with type W ?

Is it possible ?
Ezequias

------=_Part_76524_1691270.1171294870780--