Sum sets of records

From: "Ezequias Rodrigues da Rocha" <ezequias(dot)rocha(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Sum sets of records
Date: 2007-02-12 15:41:10
Message-ID: 55c095e90702120741w3908f730vbd23b6d9b4fa7cc3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2007-02-12 15:46:24 Re: Sum sets of records
Previous Message Richard Huxton 2007-02-12 08:21:52 Re: COPY FROM query.