Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C34B963293F for ; Fri, 9 Apr 2010 06:13:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 57289-08 for ; Fri, 9 Apr 2010 09:12:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moon.antora.ru (moon.antora.ru [89.111.189.180]) by mail.postgresql.org (Postfix) with ESMTP id 1CAA2632886 for ; Fri, 9 Apr 2010 06:12:59 -0300 (ADT) Envelope-to: pgsql-sql@postgresql.org Received: from moon.inner.space ([10.1.1.5] helo=moon.antora.ru) by moon.antora.ru with esmtp (Exim 4.67) (envelope-from ) id 1O0AGn-0003AA-8g for pgsql-sql@postgresql.org; Fri, 09 Apr 2010 13:12:57 +0400 Received: from [192.168.1.6] [178.34.174.206] by moon.antora.ru (Axigen) with (DHE-RSA-AES256-SHA encrypted) ESMTPSA id 0F3048; Fri, 9 Apr 2010 13:12:56 +0400 Message-ID: <4BBEEF98.301@bankir.ru> Date: Fri, 09 Apr 2010 13:12:56 +0400 From: silly sad User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20100111 Thunderbird/3.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Cascading sum in tree with CTE? References: <4BBED49D.7080501@krap.dk> In-Reply-To: <4BBED49D.7080501@krap.dk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scan-Signature: 92ddf81d1c5ad125032b7be4b1611ede X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.342 tagged_above=-10 required=5 tests=AWL=-0.342 X-Spam-Level: X-Archive-Number: 201004/35 X-Sequence-Number: 33962 to select a whole subtree of a particular node of a tree. u have to modify the tree representation in one of the two ways (according to you fine-tuned needs) (1) store in the EACH node the PATH from root to this node (2) store (l,r) segment representing the INCLUSIONS of nodes into other nodes subtree (exactly as segments include each other) (2) i forgot the "official" name of this type of tree representation.