## Re: Help by query

From: "Oliveiros d'Azevedo Cristina" "killspam killspam" <01killspam(at)gmail(dot)com>, Re: Help by query 2011-02-01 11:57:27 075F3B5A3FFE41E291D866DB56AA6288@marktestcr.marktest.pt (view raw, whole thread or download thread mbox) 2011-02-01 10:14:03 from killspam killspam <01killspam(at)gmail(dot)com>  2011-02-01 11:57:27 from "Oliveiros d'Azevedo Cristina"   2011-02-01 15:35:33 from killspam killspam <01killspam(at)gmail(dot)com> pgsql-novice
Howdy,
Can you explain a little better the background of the problem you're trying to solve as it is not clear for me?
Where did the line with id=6 come from?
And what's the role of the "example number" variable you've provided ? Is it the threshold? What happens if a group surpasses it ?

Best,
Oliveiros
----- Original Message -----
From: killspam killspam
To: pgsql-novice(at)postgresql(dot)org
Sent: Tuesday, February 01, 2011 10:14 AM
Subject: [NOVICE] Help by query

Hello list.

I have the following problem:

Example table Origin

id   | length  |  source  |  target

1        25          33           45
2       100         45           60
3        12          22           11
4        78          60           55
5        20          24           60

Example Results: new table

id   | length  |  source  |  target | group | total length

1        25          33           45        1          145
2       100         45           70        1          145
3        12          22           11        3           12
4        78          60           55        2           98
5        20          24           60        2           98
6        20          30           70        1          145

Example Number variable      >= 150

and I want to create groups of elements on two conditions.

source or target must match, since this indicates that touch

to group items with the first condition and that the sum of its length does not exceed a given number

not be repeated elements in groups (The items can not be processed and reprocessed)

Can someone help?

regards
Mario

### pgsql-novice by date

 Next: From: Michael Swierczek Date: 2011-02-01 14:29:54 Subject: Re: Primary keys in a single column table and text vs varchar Previous: From: Thom Brown Date: 2011-02-01 10:54:55 Subject: Re: New table