Re: Aggregating over nodes in hierarchical trees - Mailing list pgsql-general

From hari.fuchs@gmail.com
Subject Re: Aggregating over nodes in hierarchical trees
Date
Msg-id 87iokuzht4.fsf@hf.protecting.net
Whole thread Raw
In response to Aggregating over nodes in hierarchical trees  ("McGehee, Robert" <Robert.McGehee@geodecapital.com>)
List pgsql-general
"McGehee, Robert" <Robert.McGehee@geodecapital.com> writes:

> SELECT n.node, sum(students) as students
> FROM tree_tbl t, node_tbl n
> WHERE t.course ~ '.*' || n.node || '.*'
> GROUP BY n.node;

I'd write this as

SELECT n.node, sum(students) AS students
FROM tree_tbl t
JOIN node_tbl n ON t.course ~ ('*.' || n.node || '.*')::lquery
GROUP BY n.node;

pgsql-general by date:

Previous
From: damien clochard
Date:
Subject: Re: Introducing Open PostgreSQL Monitoring (OPM)
Next
From: Iain Mott
Date:
Subject: permission denied for schema topology