Обсуждение: Build an statement

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

Build an statement

От
Alexander Burbello
Дата:
Hi people,

I am begginer on Postgres, and I would like to build a report this way:

1 - Central
    101 - Base Rio
        1001 - Sing X
        1002 - Sing Y
        1003 - Sing Z
    102 - Base Sao Paulo
        1004 - Sing A
        1004 - Sing A
        1004 - Sing A


In my table, I have the following data:

 coo_cod_cooperative     coo_cooperative_up    coo_type         coo_name
 ----------------------      ---------------------------
-----------          --------------------
 1001                        100
      3                            Singular X
 1002                        100
        3                            Singular Y
 1003                        100
        3                            Singular Z
 100                          1
            2                           Base Sao Paulo
 101                           1
        2                              Base Rio de Janeiro
 1004                        101
        3                            Singular A
 1005                        101
        3                            Singular B
 1006                        101
        3                            Singular C
 1                               (null)
            1                            Central


COO_TYPE means: 1 master;  2 - regional;  3 - offices

I would like to do this statement independent the code, based on type.
Is it possible to do on Postgres?

Thanks in advance.

Alexander