SQL / per cent change question - Mailing list pgsql-general

From Johnson, Shaunn
Subject SQL / per cent change question
Date
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C73D0F@snt452.corp.bcbsm.com
Whole thread Raw
List pgsql-general

Howdy:

Currently running PostgreSQL 7.1.3 on RedHat Linux.

What I'm trying to do is create a table where I have
data loaded every week or so.  In that table I'll have
simple things like name, count, date, whatever.
 
What I'm looking for is for a method to do per cent
difference from each last count that was loaded into
the table. 

For instance, I load something like this:

insert into t_change (name, count, date
values ("widgets", "2304", timestamp(now()))

That give me my table and some info, right?  Now,
every time that someone updates that table, I've seen
a formula on how to get the per cent between
two columns already inserted in the table, but what
can I do when I have only ONE field and want to get the
difference between that and the load PRIOR to
what I have?  That is to say, how can I get the
difference / percent change between "count" and
the count that was loaded, say, a few minutes before
on a routine basis?

Suggestion?  Comments?  Thanks!

-X

pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: UK Goverment accounces a (very postive) policy on Open Source Software
Next
From: "Hillensbeck, Preston"
Date:
Subject: Re: [SQL] No command history in psql