Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0U2EDl29506 for ; Tue, 29 Jan 2002 21:14:13 -0500 (EST) (envelope-from sszabo@megazone23.bigpanda.com) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id E561BD5F6; Tue, 29 Jan 2002 18:14:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id DB13E5BF9; Tue, 29 Jan 2002 18:14:15 -0800 (PST) Date: Tue, 29 Jan 2002 18:14:15 -0800 (PST) From: Stephan Szabo To: lonh SENG Cc: Subject: Re: SQL Script In-Reply-To: <00ba01c1a92b$31c58280$05a00017@idlonh> Message-ID: <20020129180955.B97423-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200201/253 X-Sequence-Number: 3134 On Wed, 30 Jan 2002, lonh SENG wrote: > Hi all, > > I have one table containing data as "source.txt" attached file. I > want to create a script to clean the data and get the result as > "result.txt" attached file. > inbtime and inbtime1 is datetime data type. > Anyone has an idea? > Any help will be appreciated. > thanks in advance > > Sorry. It seems to be out of the topic. Probably belongs on pgsql-sql, but... :) This is not at all optimized, but maybe something of the form: select t1.card, t1.inbtime, coalesce((select min(inbtime) from t t2 where t2.inbtime>t1.inbtime and t2.card=t1.card), t1.inbtime) from t t1;