Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 79B089FA281 for ; Fri, 9 Feb 2007 15:53:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 85359-05 for ; Fri, 9 Feb 2007 15:53:23 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id 46CA19FA249 for ; Fri, 9 Feb 2007 15:53:23 -0400 (AST) Received: by nf-out-0910.google.com with SMTP id x4so1318990nfb for ; Fri, 09 Feb 2007 11:53:21 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=ITe2aJi6GdFHxpWInrhyQOncAE7FJ8bCZZ+NA49zQbLx2a98t8K84rTVJlIhlxMXYtp0VjRN3o0VPTNxx5/2jrzmFqsMFQgvX/6OYFWTJAHxONBCqzV65zwRNqmeGw0/+0GrVLnWSvxT6kV1dBnWxO+nv0iuaNLPMi+0YWvc3xg= Received: by 10.82.107.15 with SMTP id f15mr6633043buc.1171050801431; Fri, 09 Feb 2007 11:53:21 -0800 (PST) Received: by 10.82.183.4 with HTTP; Fri, 9 Feb 2007 11:53:21 -0800 (PST) Message-ID: <1f30b80c0702091153u49f15ca1ycd0dbaa73f02d68a@mail.gmail.com> Date: Sat, 10 Feb 2007 00:53:21 +0500 From: imad To: "Alexander B." Subject: Re: Hierarchical structure Cc: "pgsql-admin@postgresql.org" In-Reply-To: <45CCCA4E.6080703@yahoo.com.br> MIME-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <45CCCA4E.6080703@yahoo.com.br> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/133 X-Sequence-Number: 24598 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. 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 =96 null =96 1 > 106 =96 null =96 1 > 134 =96 100 =96 2 > 725 =96 100 =96 2 > 635 =96 106 =96 2 > 423 =96 134 =96 3 > 814 =96 725 =96 3 > > > EXPECTED RESULT: > 100 - 1 > 134 =96 2 > 423 =96 3 > 725 =96 2 > 814 =96 3 > 106 =96 1 > 635 =96 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=E7=E3o para voc=EA! > Experimente j=E1 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 >