Re: Running Totals and other stuff.... - Mailing list pgsql-general

From Richard Huxton
Subject Re: Running Totals and other stuff....
Date
Msg-id 40BC95EB.8040704@archonet.com
Whole thread Raw
In response to Running Totals and other stuff....  ("Levan, Jerry" <Jerry.Levan@EKU.EDU>)
List pgsql-general
Jerry LeVan wrote:
> Yes, my mail server has a dynamic IP it is running
> on my Mac...
>
> I am retired and the University let me keep my mailbox,
> I tried using the  Universities Exchange Server to send
> the message you responded to below, much to my chagrin,
> the server wraps *all* outgoing mail in html.

My sympathies, sir.

> My check table does not have a  key, ( it does not
> have a lot of entries ~3200 in four years).

Whether 3200, 32 or 0 rows you should have a key...

> I generate the data in the table by exporting transactions
> from Quicken and parse the QIF file to a csv file and then
> import via COPY to the database.
>
> As I noted just using the date field does not quite work
> because there are multiple transactions on the same date.

And without a key there's no way to solve the issue, since there's no
way to distinguish one row from another.

> Is there  a way to add an increasing sequence of unique
> integers as a temporary column?

To cut a long story short - you need a primary key. If your table has no
suitable candidates, you will have to add one. (Can you not use
cheque-number?)

If you add your own, I would recommend adding a column of type SERIAL.
This is basically an integer with an attached sequence generator, so if
no value is supplied it defaults to the next number supplied by the
sequence.

You can continue to use COPY to import new data, just don't mention the
new column in the list to insert and it will be given the default.

You can then order by date, <key> and that will let you calculate your
running total.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Alan Graham
Date:
Subject: Re: Running Totals and other stuff....
Next
From: Alan Graham
Date:
Subject: Re: Running Totals and other stuff....