X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F014852876 for ; Wed, 1 Jun 2005 12:55:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12977-03 for ; Wed, 1 Jun 2005 15:55:45 +0000 (GMT) Received: from outmx003.isp.belgacom.be (outmx003.isp.belgacom.be [195.238.2.100]) by svr1.postgresql.org (Postfix) with ESMTP id 7DEE252855 for ; Wed, 1 Jun 2005 12:55:42 -0300 (ADT) Received: from outmx003.isp.belgacom.be (localhost [127.0.0.1]) by outmx003.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id j51FtdPB001795 for ; Wed, 1 Jun 2005 17:55:39 +0200 (envelope-from ) Received: from [127.0.0.1] (203-23.241.81.adsl.skynet.be [81.241.23.203]) by outmx003.isp.belgacom.be (8.12.11/8.12.11/Skynet-OUT-2.22) with ESMTP id j51FtSkn001687 for ; Wed, 1 Jun 2005 17:55:38 +0200 (envelope-from ) Message-ID: <429DDBB1.7000204@skynet.be> Date: Wed, 01 Jun 2005 18:00:49 +0200 From: Alain Reymond User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: fr, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: How do write a query... Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/69 X-Sequence-Number: 21670 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