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

Help by query

From: killspam killspam <01killspam(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Help by query
Date: 2011-02-01 10:14:03
Message-ID: AANLkTinop7n7HNqzENFXAmtXPDzY-U3BDOcEfFNb85SN@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novice
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?

Thanks in advance

regards
Mario

Responses

pgsql-novice by date

Next:From: Thom BrownDate: 2011-02-01 10:54:55
Subject: Re: New table
Previous:From: Karen CastilloDate: 2011-02-01 09:47:14
Subject: New table

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