pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedproblem in sql - sum()
5+ messages / 3 participants
[nested] [flat]
* problem in sql - sum()
@ 2016-03-22 14:42 ivan@adicional.com.br
0 siblings, 2 replies; 5+ messages in thread
From: ivan@adicional.com.br @ 2016-03-22 14:42 UTC (permalink / raw)
To: pgsql-bugs
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.
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
return 103.629.305,96.
It's very diferenty.
Only change is date.
The version in use is :
PostgreSQL 9.0.8 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2), 64-bit
Please, helpe me.
Thanks,
Ivan Rodrigues
Brazil - São Paulo
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: problem in sql - sum()
@ 2016-03-22 20:15 David G. Johnston <david.g.johnston@gmail.com>
parent: ivan@adicional.com.br
1 sibling, 0 replies; 5+ messages in thread
From: David G. Johnston @ 2016-03-22 20:15 UTC (permalink / raw)
To: ivan@adicional.com.br; +Cc: pgsql-bugs
On Tue, Mar 22, 2016 at 7:42 AM, <ivan@adicional.com.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.
>
>
Which day 18?
> 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
>
> return 103.629.305,96.
>
> It's very diferenty.
> Only change is date.
>
> The version in use is :
> PostgreSQL 9.0.8 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC)
> 4.6.3 20120306 (Red Hat 4.6.3-2), 64-bit
>
You are going to find little help here given you are running an ancient
and, even when within support, woefully unpatched release of the software.
David J.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: problem in sql - sum()
@ 2016-03-22 20:25 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: ivan@adicional.com.br
1 sibling, 1 reply; 5+ messages in thread
From: Alvaro Herrera @ 2016-03-22 20:25 UTC (permalink / raw)
To: ivan@adicional.com.br; +Cc: pgsql-bugs
ivan@adicional.com.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".
> 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.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: problem in sql - sum()
@ 2016-03-22 21:00 David G. Johnston <david.g.johnston@gmail.com>
parent: Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 5+ messages in thread
From: David G. Johnston @ 2016-03-22 21:00 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: pgsql-bugs
On Tue, Mar 22, 2016 at 1:25 PM, Alvaro Herrera <alvherre@2ndquadrant.com>
wrote:
> ivan@adicional.com.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.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: problem in sql - sum()
@ 2016-03-22 21:07 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Alvaro Herrera @ 2016-03-22 21:07 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs
David G. Johnston wrote:
> 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.
I misspoke. My intention here was to point out that this is most likely
user error, not a software bug, despite how obsolete the version. Yes,
he needs to upgrade, but I cannot honestly believe that upgrading would
"solve" this particular problem.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2016-03-22 21:07 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-03-22 14:42 problem in sql - sum() ivan@adicional.com.br
2016-03-22 20:15 ` David G. Johnston <david.g.johnston@gmail.com>
2016-03-22 20:25 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-03-22 21:00 ` David G. Johnston <david.g.johnston@gmail.com>
2016-03-22 21:07 ` Alvaro Herrera <alvherre@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox