SQL Agreate Functions

From: Alex P <alex(at)meerkatsoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SQL Agreate Functions
Date: 2004-11-02 07:51:27
Message-ID: 41873C7F.80001@meerkatsoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have a problem I dont really know how to solve except for writing a
function.

I have a table with prices;

SecCode| Price | PriceDate
-------+------------+-----------
A0001 | 13.10 | 2004-10-30
A0001 | 13.03 | 2004-10-29
A0001 | 13.12 | 2004-10-28
A0001 | 12.45 | 2004-10-27
A0001 | 12.65 | 2004-10-26
A0001 | 12.45 | 2004-10-25

A0002 | 10.10 | 2004-10-30
A0002 | 10.45 | 2004-10-27
A0002 | 10.65 | 2004-10-26
A0002 | 10.45 | 2004-10-25
etc.

What I would like to calculate is:

a) the difference of the past 2 days for every security of
available prices

b) a flag indicating, that the price of today-1 is yesterday's
price (true in case A0001, false for A0002)

c) the variance of the past 30 days

Is it possible to do that within one query?

Thanks for any advise
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alex P 2004-11-02 08:05:56 Subselect Question
Previous Message Sim Zacks 2004-11-02 07:11:10 Re: Rows created by a stored proc prompt Access' dreaded "write conflict"