Обсуждение: Hierarchical structure

Поиск
Список
Период
Сортировка

Hierarchical structure

От
"Alexander B."
Дата:
Hi, I need to create a view using hierarchical structure.
Let me explain how is designed the table and what's the expected result.

TABLE:
coo_nro integer
coo_nro_father integer
level integer


DATA:
100 – null – 1
106 – null – 1
134 – 100 – 2
725 – 100 – 2
635 – 106 – 2
423 – 134 – 3
814 – 725 – 3


EXPECTED RESULT:
100 - 1
134 – 2
423 – 3
725 – 2
814 – 3
106 – 1
635 – 2
. . . so on

Basically, my result should be this way, not necessary spaces, but
sorted by hierarchic.

Is this possible on Postgres?
Could you help me?



_______________________________________________________
Yahoo! Mail - Sempre a melhor opção para você!
Experimente já e veja as novidades.
http://br.yahoo.com/mailbeta/tudonovo/



Re: Hierarchical structure

От
imad
Дата:
There is a contrib module named tablefunc. It has a function
connect_by that can do some things like this. Check if it is
sufficient for you.

--Imad
www.EnterpriseDB.com

On 2/10/07, Alexander B. <burbello3000@yahoo.com.br> wrote:
> Hi, I need to create a view using hierarchical structure.
> Let me explain how is designed the table and what's the expected result.
>
> TABLE:
> coo_nro integer
> coo_nro_father integer
> level integer
>
>
> DATA:
> 100 – null – 1
> 106 – null – 1
> 134 – 100 – 2
> 725 – 100 – 2
> 635 – 106 – 2
> 423 – 134 – 3
> 814 – 725 – 3
>
>
> EXPECTED RESULT:
> 100 - 1
> 134 – 2
> 423 – 3
> 725 – 2
> 814 – 3
> 106 – 1
> 635 – 2
> . . . so on
>
> Basically, my result should be this way, not necessary spaces, but
> sorted by hierarchic.
>
> Is this possible on Postgres?
> Could you help me?
>
>
>
> _______________________________________________________
> Yahoo! Mail - Sempre a melhor opção para você!
> Experimente já e veja as novidades.
> http://br.yahoo.com/mailbeta/tudonovo/
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>