Re: Plan to support predicate push-down into subqueries with aggregates?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: rob stone <floriparob(at)gmail(dot)com>
Cc: Adam Brusselback <adambrusselback(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Plan to support predicate push-down into subqueries with aggregates?
Date: 2016-03-10 03:07:45
Message-ID: CAKFQuwYPEV4uY7MdP_VLk4Z9OvLmc9-wxZ9OOKzyfYNDvJ4XKw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wednesday, March 9, 2016, rob stone <floriparob(at)gmail(dot)com> wrote:

> On Wed, 2016-03-09 at 12:25 -0500, Adam Brusselback wrote:
>
> Note that:- (a) I included header_description in the definition.
> (b) Removed some lines as if you want the total you may as well
> include it in your select from the view, and for the life of me I
> couldn't understand the purpose of:-
>
> header.amount = coalesce(detail_1.amount, 0) +
> coalesce(detail_2.amount, 0) as balanced
>
> Is "balanced" supposed to be a boolean?
>
> If you need header.amount include it in the view.
>
>
It's basically accounting. Does the total amount on the header
(header.amount) equal the sum of the two components (1.amount + 2.amount),
returns true or false based upon the equality. So not only do you need to
compute 1.amount but you also need to immediately use it as part of an
expression. And return both usages from the view.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-03-10 06:40:30 Re: [GENERAL] Request - repeat value of \pset title during \watch interations
Previous Message rob stone 2016-03-10 02:48:55 Re: Plan to support predicate push-down into subqueries with aggregates?