Re: Modifying selected records - Mailing list pgsql-novice

From Oliveiros C,
Subject Re: Modifying selected records
Date
Msg-id 35A804E917DB43B5814F9C3A8E8FA027@marktestcr.marktest.pt
Whole thread Raw
In response to Modifying selected records  (Ruzsinszky Attila <ruzsinszky.attila@gmail.com>)
Responses Re: Modifying selected records  (Ruzsinszky Attila <ruzsinszky.attila@gmail.com>)
List 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
indul_ido
 
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
 
Best
Oliveiros
 
 
 
----- Original Message -----
From: "Ruzsinszky Attila" <ruzsinszky.attila@gmail.com>
To: "Oliveiros C," <oliveiros.cristina@marktest.pt>
Cc: "postgresql novice" <pgsql-novice@postgresql.org>
Sent: Thursday, September 03, 2009 12:44 PM
Subject: Re: [NOVICE] Modifying selected records

Hi,

> 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.

TIA,
Ruzsi

pgsql-novice by date:

Previous
From: Joshua Tolley
Date:
Subject: Re: Backup aggregate function
Next
From: Ruzsinszky Attila
Date:
Subject: Re: Modifying selected records