pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alain Reymond <arwebmail@skynet.be>
To: pgsql-sql@postgresql.org
Subject: How do write a query...
Date: Wed, 01 Jun 2005 18:00:49 +0200
Message-ID: <429DDBB1.7000204@skynet.be> (raw)

Hello,

I have the following problem :

I have a table like
Id    Num      Date                   AValue
1      10         01/01/2005       50
2      10         31/05/2005       60
3      25         02/02/2005       55
4      25         15/03/2005       43
5      25         28/05/2005       62
etc..

Id is unique, Num is an identification number with duplicates possible,
date is a ... date and Avalue... a value!

If we have
Id    Num      Date                   AValue
Id1  Num1    Date1                  AValue1
Id2  Num1    Date2                  AValue2

The table is ordered on Num+Date.
What I would like to calculate is (AValue2-AValue1) for a given Num
(here num1).

In this case, I would have to calculate
60-50 for Num 10
and
43-55, 62-43 for Num 25.

Do you have any idea if it can be done simply with a request...

I thank you

Regards.

Alain Reymond





view thread (5+ messages)  latest in thread

Message-ID: <429DDBB1.7000204@skynet.be>
Permalink:  ../429DDBB1.7000204@skynet.be/
Also on:    postgresql.org/message-id/429DDBB1.7000204@skynet.be

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: arwebmail@skynet.be
  Subject: Re: How do write a query...
  In-Reply-To: <429DDBB1.7000204@skynet.be>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox