Re: Stuck Up In My Own Category Tree - Mailing list pgsql-sql

From Don Parris
Subject Re: Stuck Up In My Own Category Tree
Date
Msg-id CAJ-7yokatsLBvdMFrZA99BrpH6z_7CcFx=oO-tMHwaQYSmxPNg@mail.gmail.com
Whole thread Raw
In response to Re: Stuck Up In My Own Category Tree  ("Edward W. Rouse" <erouse@comsquared.com>)
List pgsql-sql
On Thu, Aug 11, 2011 at 12:48, Edward W. Rouse <erouse@comsquared.com> wrote:

How about SELECT cat_name, sum(amount) AS "amount" FROM category, trans_details WHERE category_cat_id in (select cat_id from category where lineage ~ ‘^1’)

 

Where the in clause is basically, the cat_id where lineage starts with, and then the lineage you want. 1, 1-2, whatever the lineage is. Not sure about efficiency or whether you can put another subselect in there to build the lineage string to match, but the basic idea should work.

 



Thanks all, I will try out the suggestions.  Samuel, thanks for the link!  Haven't had a chance to check it out yet, but it sure looks promising.  I'll post again when I've had a chance to look over/ try out some of these things.  :-)

Don
--
D.C. Parris, FMP, LEED AP O+M, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
GPG Key ID: F5E179BE

pgsql-sql by date:

Previous
From: "Edward W. Rouse"
Date:
Subject: Re: Stuck Up In My Own Category Tree
Next
From: tlund79
Date:
Subject: Using variables in select