pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #17961: Incorrect aggregation MIN, AVG, MAX
3+ messages / 3 participants
[nested] [flat]
* BUG #17961: Incorrect aggregation MIN, AVG, MAX
@ 2023-06-04 22:04 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: PG Bug reporting form @ 2023-06-04 22:04 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: dp.maxime@gmail.com
The following bug has been logged on the website:
Bug reference: 17961
Logged by: Maxim Zakharov
Email address: dp.maxime@gmail.com
PostgreSQL version: 14.8
Operating system: Ubuntu 22.04.2
Description:
Hello,
I came across a situation when MIN(), AVG() and MAX() aggregates where
computed incorrectly, as you can see from the output below the valuer of
MIN() is higher than AVG() and MAX()!
Expected values should be the same as for MIN()
The table n has all values been updated several times with different values
and currently all rows contain the value of 11.55
$ psql db
psql (15.3 (Ubuntu 15.3-1.pgdg22.04+1), server 14.8 (Ubuntu
14.8-1.pgdg22.04+1))
Type "help" for help.
asx=# reindex table n;
REINDEX
asx=# select at, MIN(diluted_earnings_1)::numeric as diluted_earnings_1min,
ROUND(AVG(diluted_earnings)::numeric, 2) as diluted_earnings_1avg,
MAX(diluted_earnings)::numeric as diluted_earnings_1max
from n
where sym like '___ '
group by at
order by at desc limit 1;
at | diluted_earnings_1min | diluted_earnings_1avg |
diluted_earnings_1max
------------+-----------------------+-----------------------+-----------------------
2023-06-02 | 11.55 | -0.17 |
-0.17
(1 row)
db=#
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17961: Incorrect aggregation MIN, AVG, MAX
@ 2023-06-05 07:40 Julien Rouhaud <rjuju123@gmail.com>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 3+ messages in thread
From: Julien Rouhaud @ 2023-06-05 07:40 UTC (permalink / raw)
To: dp.maxime@gmail.com; pgsql-bugs@lists.postgresql.org
Hi,
On Sun, Jun 04, 2023 at 10:04:04PM +0000, PG Bug reporting form wrote:
>
> I came across a situation when MIN(), AVG() and MAX() aggregates where
> computed incorrectly, as you can see from the output below the valuer of
> MIN() is higher than AVG() and MAX()!
> Expected values should be the same as for MIN()
> The table n has all values been updated several times with different values
> and currently all rows contain the value of 11.55
>
> asx=# select at, MIN(diluted_earnings_1)::numeric as diluted_earnings_1min,
> ROUND(AVG(diluted_earnings)::numeric, 2) as diluted_earnings_1avg,
> MAX(diluted_earnings)::numeric as diluted_earnings_1max
Unless I'm missing something you're using diluted_earnings_1 for min, but
diluted_earnings for avg and max so it looks like it's working as expected?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #17961: Incorrect aggregation MIN, AVG, MAX
@ 2023-06-05 07:46 Maxim Zakharov <dp.maxime@gmail.com>
parent: Julien Rouhaud <rjuju123@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Maxim Zakharov @ 2023-06-05 07:46 UTC (permalink / raw)
To: Julien Rouhaud <rjuju123@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org
Hello,
You're right, the SQL query was incorrect. Shame on me! :]
Thank you and sorry for bothering with such a mistake.
On Mon, 5 Jun 2023 at 17:40, Julien Rouhaud <rjuju123@gmail.com> wrote:
> Hi,
>
> On Sun, Jun 04, 2023 at 10:04:04PM +0000, PG Bug reporting form wrote:
> >
> > I came across a situation when MIN(), AVG() and MAX() aggregates where
> > computed incorrectly, as you can see from the output below the valuer of
> > MIN() is higher than AVG() and MAX()!
> > Expected values should be the same as for MIN()
> > The table n has all values been updated several times with different
> values
> > and currently all rows contain the value of 11.55
> >
> > asx=# select at, MIN(diluted_earnings_1)::numeric as
> diluted_earnings_1min,
> > ROUND(AVG(diluted_earnings)::numeric, 2) as diluted_earnings_1avg,
> > MAX(diluted_earnings)::numeric as diluted_earnings_1max
>
> Unless I'm missing something you're using diluted_earnings_1 for min, but
> diluted_earnings for avg and max so it looks like it's working as expected?
>
--
http://au.linkedin.com/in/dpmaxime/
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-06-05 07:46 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-06-04 22:04 BUG #17961: Incorrect aggregation MIN, AVG, MAX PG Bug reporting form <noreply@postgresql.org>
2023-06-05 07:40 ` Julien Rouhaud <rjuju123@gmail.com>
2023-06-05 07:46 ` Maxim Zakharov <dp.maxime@gmail.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