From slonh@camgsm.com.kh Wed Jan 30 01:37:18 2002 Received: from mailmx.camgsm.com.kh ([203.144.65.11]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0U1bHl13563 for ; Tue, 29 Jan 2002 20:37:18 -0500 (EST) (envelope-from slonh@camgsm.com.kh) Received: from idlonh ([23.0.160.5]) by mailmx.camgsm.com.kh (8.10.2/8.10.2/SuSE Linux 8.10.0-0.3) with SMTP id g0U1CvV13501 for ; Wed, 30 Jan 2002 08:12:57 +0700 X-Authentication-Warning: mailmx.camgsm.com.kh: Host [23.0.160.5] claimed to be idlonh Message-ID: <00ba01c1a92b$31c58280$05a00017@idlonh> From: "lonh SENG" To: Subject: SQL Script Date: Wed, 30 Jan 2002 08:12:32 +0700 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_00B6_01C1A965.DE151840" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200201/251 X-Sequence-Number: 3132 This is a multi-part message in MIME format. ------=_NextPart_000_00B6_01C1A965.DE151840 Content-Type: multipart/alternative; boundary="----=_NextPart_001_00B7_01C1A965.DE151840" ------=_NextPart_001_00B7_01C1A965.DE151840 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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" att= ached 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. Regards, lonh ------=_NextPart_001_00B7_01C1A965.DE151840 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all,
 
    I have one table contai= ning data=20 as "source.txt" attached file. I want to create a script to clean the = data=20 and get the result as "result.txt" attached file.
    inbtime and inbtime1 is datetime data=20 type.
    Anyone has an idea?
    Any help will be=20 appreciated.
    thanks in advance
 
    Sorry. It seems to be o= ut of the=20 topic.
=  
Regards,
 
lonh
------=_NextPart_001_00B7_01C1A965.DE151840-- ------=_NextPart_000_00B6_01C1A965.DE151840 Content-Type: text/plain; name="result.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="result.txt" card inbtime inbtime1 ---------------- --------------------------- --------------------------- 0250002 2002-01-25 19:16:41.000 2002-01-25 19:17:18.000 0250002 2002-01-25 19:17:18.000 2002-01-25 20:12:07.000 0250002 2002-01-25 20:12:07.000 2002-01-26 05:34:09.000 0250002 2002-01-26 05:34:09.000 2002-01-27 18:38:52.000 0250002 2002-01-27 18:38:52.000 2002-01-27 18:38:52.000 0250003 2002-01-25 06:28:31.000 2002-01-25 17:13:26.000 0250003 2002-01-25 17:13:26.000 2002-01-26 06:39:00.000 ------=_NextPart_000_00B6_01C1A965.DE151840 Content-Type: text/plain; name="source.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="source.txt" card inbtime ---------------- --------------------------- 0250002 2002-01-25 19:16:41.000 0250002 2002-01-25 19:17:18.000 0250002 2002-01-25 20:12:07.000 0250002 2002-01-26 05:34:09.000 0250002 2002-01-27 18:38:52.000 0250003 2002-01-25 06:28:31.000 0250003 2002-01-25 17:13:26.000 ------=_NextPart_000_00B6_01C1A965.DE151840-- From david@netventures.com.au Wed Jan 30 02:08:16 2002 Received: from dealer.netventures.com.au (dnet137107-1.gw.connect.com.au [210.8.15.221] (may be forged)) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0U28Gl28526 for ; Tue, 29 Jan 2002 21:08:16 -0500 (EST) (envelope-from david@netventures.com.au) Received: from ciderbox.in.netventures.com.au (net137107-2.gw.connect.com.au [210.9.198.119]) by dealer.netventures.com.au (Postfix) with ESMTP id DBC761A5DC5; Wed, 30 Jan 2002 13:08:16 +1100 (EST) Date: Wed, 30 Jan 2002 13:08:23 +1100 Subject: Re: [ADMIN] SQL Script Content-Type: multipart/alternative; boundary=Apple-Mail-1--310434794 Mime-Version: 1.0 (Apple Message framework v480) Cc: "lonh SENG" To: pgsql-sql@postgresql.org From: David Stanaway In-Reply-To: <00ba01c1a92b$31c58280$05a00017@idlonh> Message-Id: <3D4F50BE-1526-11D6-BBC8-0003930FDAB2@netventures.com.au> X-Mailer: Apple Mail (2.480) X-Archive-Number: 200201/328 X-Sequence-Number: 6412 --Apple-Mail-1--310434794 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed On Wednesday, January 30, 2002, at 12:12 PM, lonh SENG wrote: > Hi all, > =A0 > =A0=A0=A0 I have one table containing data as "source.txt" attached file.= I=20 > want to create a script to clean=A0the data and get the result as=20 > "result.txt" attached file. > =A0=A0=A0 inbtime and inbtime1 is datetime data type. > =A0=A0=A0 Anyone has an idea? > =A0=A0=A0 Any help will be appreciated. > =A0=A0=A0 thanks in advance It looks like you are going to need to look into using a cursor, and=20 perl DBI or equiv. Alternatively, you could create a function in=20 PL/PGSQL. Where do you get the date for the end of the interval for the last=20 inbtime ordered by time? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D David Stanaway Personal: david@stanaway.net Work: david@netventures.com.au --Apple-Mail-1--310434794 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 On Wednesday, January 30, 2002, at 12:12 PM, lonh SENG wrote: ArialHi all, =A0 Arial=A0=A0=A0 I have one table containing data as "source.txt" attached file. I want to create a script to clean=A0the data and get the result as "result.txt" attached file. =A0=A0=A0 inbtime and inbtime1 is datetime data type. Arial=A0=A0=A0 Anyone has an idea? Arial=A0=A0=A0 Any help will be appreciated. Arial=A0=A0=A0 thanks in advance It looks like you are going to need to look into using a cursor, and perl DBI or equiv. Alternatively, you could create a function in PL/PGSQL. Where do you get the date for the end of the interval for the last inbtime ordered by time? Helvetica=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D David Stanaway Personal: david@stanaway.net=20 Work: david@netventures.com.au --Apple-Mail-1--310434794-- From sszabo@megazone23.bigpanda.com Wed Jan 30 02:14:13 2002 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; From slonh@camgsm.com.kh Wed Jan 30 04:00:58 2002 Received: from mailmx.camgsm.com.kh (mailmx.camgsm.com.kh [203.144.65.11]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g0U40ul50798 for ; Tue, 29 Jan 2002 23:00:58 -0500 (EST) (envelope-from slonh@camgsm.com.kh) Received: from idlonh ([23.0.160.5]) by mailmx.camgsm.com.kh (8.10.2/8.10.2/SuSE Linux 8.10.0-0.3) with SMTP id g0U3c6P09953; Wed, 30 Jan 2002 10:38:06 +0700 X-Authentication-Warning: mailmx.camgsm.com.kh: Host [23.0.160.5] claimed to be idlonh Message-ID: <002001c1a93f$79369aa0$05a00017@idlonh> From: "lonh SENG" To: "Stephan Szabo" Cc: References: <20020129180955.B97423-100000@megazone23.bigpanda.com> Subject: Re: SQL Script Date: Wed, 30 Jan 2002 10:37:41 +0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200201/254 X-Sequence-Number: 3135 Thank all of you very much. It works now. ----- Original Message ----- From: "Stephan Szabo" To: "lonh SENG" Cc: Sent: Wednesday, January 30, 2002 9:14 AM Subject: Re: [ADMIN] SQL Script > > 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; > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > >