SQL / per cent change question

Поиск
Список
Период
Сортировка
От Johnson, Shaunn
Тема SQL / per cent change question
Дата
Msg-id 73309C2FDD95D11192E60008C7B1D5BB04C73D0F@snt452.corp.bcbsm.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Justin Clift
Дата:
Сообщение: UK Goverment accounces a (very postive) policy on Open Source Software
Следующее
От: "Hillensbeck, Preston"
Дата:
Сообщение: Re: [SQL] No command history in psql