Re: Plan to support predicate push-down into subqueries with aggregates? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Plan to support predicate push-down into subqueries with aggregates?
Date
Msg-id CAKFQuwYPEV4uY7MdP_VLk4Z9OvLmc9-wxZ9OOKzyfYNDvJ4XKw@mail.gmail.com
Whole thread Raw
In response to Re: Plan to support predicate push-down into subqueries with aggregates?  (rob stone <floriparob@gmail.com>)
Responses Re: Plan to support predicate push-down into subqueries with aggregates?  (Adam Brusselback <adambrusselback@gmail.com>)
List pgsql-general
On Wednesday, March 9, 2016, rob stone <floriparob@gmail.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.

pgsql-general by date:

Previous
From: rob stone
Date:
Subject: Re: Plan to support predicate push-down into subqueries with aggregates?
Next
From: "David G. Johnston"
Date:
Subject: Re: Request - repeat value of \pset title during \watch interations