Calc

From: "Muhyiddin A(dot)M Hayat" <middink(at)indo(dot)net(dot)id>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Calc
Date: 2003-10-15 19:59:21
Message-ID: 002e01c39356$d5885ca0$1f00a8c0@middinkcomp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Dear all,

I have below table

+-----+--------------------+---------------------+
| id | db |cr |
+-----+--------------------+---------------------+
|1 | | 200 |
|2 | 100 | |
|3 | 100 | |
|4 | 150 | |
|5 | | 200 |

I Would like to calc that balance, and look like

+-----+--------------------+---------------------+-----------+
| id | db |cr | bal |
+-----+--------------------+---------------------+-----------+
|1 | | 200 |200 |
|2 | 100 | |100 |
|3 | 100 | |0 |
|4 | 150 | |-150 |
|5 | | 200 |50 |

What can I do to get result like that

Responses

  • Re: Calc at 2003-10-15 20:31:22 from Steve Crawford
  • Re: Calc at 2003-10-15 22:15:43 from Josh Berkus

Browse pgsql-sql by date

  From Date Subject
Next Message teknokrat 2003-10-15 20:25:17 Re: indexing timestamp fields
Previous Message Christopher Browne 2003-10-15 16:21:48 Re: indexing timestamp fields