pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedSQL Script
4+ messages / 3 participants
[nested] [flat]
* SQL Script
@ 2002-01-30 01:12 lonh SENG <slonh@camgsm.com.kh>
2002-01-30 02:08 ` Re: [ADMIN] SQL Script David Stanaway <david@netventures.com.au>
2002-01-30 02:14 ` Re: SQL Script Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 2 replies; 4+ messages in thread
From: lonh SENG @ 2002-01-30 01:12 UTC (permalink / raw)
To: pgsql-admin
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.
Regards,
lonh
Attachments:
result.txt (text/plain, 585B) download
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
source.txt (text/plain, 378B) download
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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [ADMIN] SQL Script
2002-01-30 01:12 SQL Script lonh SENG <slonh@camgsm.com.kh>
@ 2002-01-30 02:08 ` David Stanaway <david@netventures.com.au>
1 sibling, 0 replies; 4+ messages in thread
From: David Stanaway @ 2002-01-30 02:08 UTC (permalink / raw)
To: pgsql-sql@postgresql.org; +Cc: lonh SENG <slonh@camgsm.com.kh>
On Wednesday, January 30, 2002, at 12:12 PM, 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
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?
==============================
David Stanaway
Personal: david@stanaway.net
Work: david@netventures.com.au
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL Script
2002-01-30 01:12 SQL Script lonh SENG <slonh@camgsm.com.kh>
@ 2002-01-30 02:14 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-01-30 03:37 ` Re: SQL Script lonh SENG <slonh@camgsm.com.kh>
1 sibling, 1 reply; 4+ messages in thread
From: Stephan Szabo @ 2002-01-30 02:14 UTC (permalink / raw)
To: lonh SENG <slonh@camgsm.com.kh>; +Cc: pgsql-admin
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;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: SQL Script
2002-01-30 01:12 SQL Script lonh SENG <slonh@camgsm.com.kh>
2002-01-30 02:14 ` Re: SQL Script Stephan Szabo <sszabo@megazone23.bigpanda.com>
@ 2002-01-30 03:37 ` lonh SENG <slonh@camgsm.com.kh>
0 siblings, 0 replies; 4+ messages in thread
From: lonh SENG @ 2002-01-30 03:37 UTC (permalink / raw)
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>; +Cc: pgsql-admin
Thank all of you very much. It works now.
----- Original Message -----
From: "Stephan Szabo" <sszabo@megazone23.bigpanda.com>
To: "lonh SENG" <slonh@camgsm.com.kh>
Cc: <pgsql-admin@postgresql.org>
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
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2002-01-30 03:37 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-01-30 01:12 SQL Script lonh SENG <slonh@camgsm.com.kh>
2002-01-30 02:08 ` David Stanaway <david@netventures.com.au>
2002-01-30 02:14 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-01-30 03:37 ` lonh SENG <slonh@camgsm.com.kh>
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