Skip site navigation (1) Skip section navigation (2)

Re: Modifying selected records

From: "Oliveiros C," <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Ruzsinszky Attila" <ruzsinszky(dot)attila(at)gmail(dot)com>
Cc: "postgresql novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Modifying selected records
Date: 2009-09-03 14:11:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Hello again, Ruzsi.

In what concerns to merging records, 
I think That can be done by tweaking ur query a little (N.B: Your query, not the one I gave you).

Try adding it a Group by clause to it.

Change your query like this

SELECT  all_kod, nev, megall, MIN(erkezik_ido) as erkezik_ido, MAX( indul_ido) as indul_ido
 FROM menetrend, stat  where statkod=all_kod and
train_selector in (SELECT train_selector
 FROM service where vonatszam='910' and datum_ig>now() and
datum_tol<now() order by datum_ig desc, datum_tol desc) 
GROUP BY all_kod,nev,megall
order by

Try that out and see if it merges the duplicated records.

Is indul_ido the arrival time? Or departure time? My hungarian is very bad, I don't understand a single word :p


----- Original Message ----- 
From: "Ruzsinszky Attila" <ruzsinszky(dot)attila(at)gmail(dot)com>
To: "Oliveiros C," <oliveiros(dot)cristina(at)marktest(dot)pt>
Cc: "postgresql novice" <pgsql-novice(at)postgresql(dot)org>
Sent: Thursday, September 03, 2009 12:44 PM
Subject: Re: [NOVICE] Modifying selected records


> 22;"5501289";"Győr";1;"07:39:00";"07:39:00";"910_22"
> 23;"5501289";"Győr";1;"07:41:00";"07:41:00";"910_23"

I'd like this:
<next count>; "5501289";"Győr"; "07:39:00"; "07:41:00"; "910_unknown"

> 28;"5544800";"Csorna";1;"08:00:00";"08:00:00";"910_28"
> 29;"5544800";"Csorna";1;"08:12:00";"08:12:00";"910_29"

For Csorna:
<next count>;"5544800";"Csorna";1;"08:00:00";"08:12:00";"910_unknown2"

_unknown means: it is a programmed selector, so not valid.
As you can see I want to merge the two time date in one record.

The problem comes from some specification misunderstood.
This timetable comes from three (almos) independent XML files.

> Indeed, I am not sure if I am understanding what you need.
Ihope you understand now.

> By duplicated record you mean records that have the first three columns the
> same ? E.G. ;"5544800";"Csorna";1; ?
Csorna and Győr is the problematic.

> And in these cases what do you need the train selector to be exactly?
I don't know exactly. I'm sure I have to change it because in the merged
record the sector is not valid.

> The left part of it (910) means what exactly?
vonatszam. In English: train number.


In response to


pgsql-novice by date

Next:From: Ruzsinszky AttilaDate: 2009-09-03 16:41:41
Subject: Re: Modifying selected records
Previous:From: Joshua TolleyDate: 2009-09-03 13:11:36
Subject: Re: Backup aggregate function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group