Re: Summing & Grouping in a Hierarchical Structure

From: Don Parris <parrisdc(at)gmail(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Summing & Grouping in a Hierarchical Structure
Date: 2013-02-23 17:53:01
Message-ID: CAJ-7yo=BOwc5px8oZoxSO-7GGCm+80U2Bav49juaf6w4hPnq_A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Bryan,

The detailed category listing is dead simple to create: SELECT cat_id,
cat_name, sum(amount) FROM category, line-item GROUP BY cat_name, cat_id;
But... as you say, the result is a LOT of numbers over the course of
160-ish categories of all levels. Which is why it is so important to be
able to summarize. I want to summarize by the highest-levels of the
category tree, precisely so as not to get a headache looking at the
details. But it is still important to be able to drill down when I want
more details.

On Sat, Feb 23, 2013 at 11:15 AM, Bryan L Nuse <nuse(at)uga(dot)edu> wrote:

> > That said, now that I have finally gotten the chance to try ltree, I
> think I like it a lot.
>
> Hello Don,
>
> Yes, after looking at ltree --which I had not done before-- I have to
> agree with Misa that it looks like the right solution for your problem.
> That is not to say that "brute force" SQL couldn't provide a workable
> arrangement; but ltree looks very flexible, especially as it allows you to
> assign cost values to non-terminal nodes. If it were me, though, I'd still
> make use of VIEWs to report results of the workhorse queries: staring at a
> list of items like "Transportation.Bicycle.Gear.Chain_ring" sounds like
> headache. That's a matter of taste, of course.
>
> Bryan
>

--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
http://dcparris.net/
<https://www.xing.com/profile/Don_Parris><http://www.linkedin.com/in/dcparris>
GPG Key ID: F5E179BE

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Don Parris 2013-02-23 18:00:29 Re: Summing & Grouping in a Hierarchical Structure
Previous Message Bryan L Nuse 2013-02-23 16:15:45 Re: Summing & Grouping in a Hierarchical Structure