Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T3Spn-00089K-Vc for pgsql-sql@postgresql.org; Mon, 20 Aug 2012 14:20:04 +0000 Received: from iota.marktest.pt ([80.251.174.118] helo=hermes.marktest.pt) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T3Spl-0007Ju-7J for pgsql-sql@postgresql.org; Mon, 20 Aug 2012 14:20:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by hermes.marktest.pt (Postfix) with ESMTP id D99691A81CD; Mon, 20 Aug 2012 15:19:59 +0100 (WEST) X-Virus-Scanned: amavisd-new at marktest.pt Received: from hermes.marktest.pt ([127.0.0.1]) by localhost (hermes.marktest.pt [127.0.0.1]) (amavisd-new, port 11124) with ESMTP id wKTXs32moSCG; Mon, 20 Aug 2012 15:19:59 +0100 (WEST) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by hermes.marktest.pt (Postfix) with ESMTP id 945E21A81CA; Mon, 20 Aug 2012 15:19:59 +0100 (WEST) Message-ID: <90C447DC256446F3A7143ECD343F17C0@marktestcr.marktest.pt> From: "Oliveiros d'Azevedo Cristina" To: "Gary Stainburn" , References: <201208201317.46588.gary.stainburn@ringways.co.uk> Subject: Re: generated dates from record dates - suggestions Date: Mon, 20 Aug 2012 15:19:58 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Pg-Spam-Score: 0.3 (/) X-Archive-Number: 201208/21 X-Sequence-Number: 36792 With a CASE ... WHEN statement? Best, Oliver ----- Original Message ----- From: "Gary Stainburn" To: Sent: Monday, August 20, 2012 1:17 PM Subject: [SQL] generated dates from record dates - suggestions > Hi folks. > > I've got a table with three dates which are populated from an external > source. > I then want to have a view with two calculated dates in it, e.g. > > if date_1 is null and date_2 is null then date_a=NULL > if date_1 is not null and date 2 is null then date_a=date_1+'90 days' > if date_1 > date3 rhen date_b=date1 else date_b=date2 > etc. > > What's the best way to do this? > > I know it's a quite open question but I'm interested to hear different > responses > > > -- > Gary Stainburn > Group I.T. Manager > Ringways Garages > http://www.ringways.co.uk > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql