From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> |
Cc: | ivan(at)adicional(dot)com(dot)br, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: problem in sql - sum() |
Date: | 2016-03-22 21:00:46 |
Message-ID: | CAKFQuwZGyoAjDSmXD7oc4qYo878wVU8pY_PCcBror0Mvc25HsQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Tue, Mar 22, 2016 at 1:25 PM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:
> ivan(at)adicional(dot)com(dot)br wrote:
> > Hi. I have a problem identified.
> > In select :
> >
> > select data_carteira, sum(valor_carteira) from carteira where
> > data_carteira between '2016-01-01' and '2016-02-18'
> > GROUP BY data_carteira order by data_carteira
> >
> > return a values from month. In the day 18, return the value
> 82.915.213,14.
>
> This query means "the sum of all values for all the days between Jan 1st
> and Feb 18th".
>
Huh?
This query returns 49 (ish) rows, one for each date, and should include a
value for January 18th. It should be possible to compare the value of the
January 18 row in this query with the single row returned by the following
query - and they should, in theory, match.
The OP claims that the corresponding rows don't match but I personally have
not excluded user error - specifically that my assumption (above) of what
is being compared matches that which is actually being compared.
I'm also not that inclined to debug 9.0.8 when the entire 9.0 release is
out of support and there are 13 point releases - any of which might have
been required to fix a bug that exhibits this behavior.
> > Now, if I use the select :
> > select data_carteira, sum(valor_carteira) from carteira where
> > data_carteira='2016-01-18'
> > GROUP BY data_carteira order by data_carteira
>
> "The sum of all values for Jan 18th".
>
> > return 103.629.305,96.
> >
> > It's very diferenty.
>
> I don't understand why you think this is a problem. The values in that
> table could be anything --- What this says is that there are rows for
> the 2016-01-18 date that add up exactly to 103.629.305,96; and the
> values for the other dates add to -20.714.093,82.
>
> > Only change is date.
>
> Right.
>
>
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2016-03-22 21:07:56 | Re: problem in sql - sum() |
Previous Message | Alvaro Herrera | 2016-03-22 20:25:27 | Re: problem in sql - sum() |