pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: koglep@gmail.com
Subject: BUG #15069: group by after regexp_replace
Date: Thu, 15 Feb 2018 15:14:49 +0000
Message-ID: <151870768979.1393.4103488163602755553@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      15069
Logged by:          Ilhwan Ko
Email address:      koglep@gmail.com
PostgreSQL version: 9.6.7
Operating system:   macOS 10.12
Description:        

create table test_t (a varchar(10), b varchar (20), c int);
 
insert into test_t (a,b,c) values ('a', 'a', 1);
insert into test_t (a,b,c) values (' a', 'a', 2); 
insert into test_t (a,b,c) values ('	a', 'a', 4);
insert into test_t (a,b,c) values ('	 a', 'a', 8);
insert into test_t (a,b,c) values ('b', 'b', 1);
insert into test_t (a,b,c) values (' b', 'b', 2); 
insert into test_t (a,b,c) values ('	b', 'b', 4);
insert into test_t (a,b,c) values ('	 b', 'b', 8);
 
 
select keyword, sum(t.c) as cc
from
(
	select upper(regexp_replace(a, '\\s+', '')) as keyword,  c
    from test_t
) t
group by keyword;

select upper(regexp_replace(a, '\\s+', '')) as keyword,  sum(c)
from test_t
group by upper(regexp_replace(a, '\\s+', ''));
    
    

select keyword, sum(t.c) as cc
from
(
	select upper(regexp_replace(b, '\\s+', '')) as keyword,  c
    from test_t
) t
group by keyword;

select upper(regexp_replace(b, '\\s+', '')) as keyword,  sum(c)
from test_t
group by upper(regexp_replace(b, '\\s+', ''));
    

I expected to get the same results regarding to above  four queries.
However, they were different.



view thread (3+ messages)  latest in thread

Message-ID: <151870768979.1393.4103488163602755553@wrigleys.postgresql.org>
Permalink:  ../151870768979.1393.4103488163602755553@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/151870768979.1393.4103488163602755553@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, koglep@gmail.com
  Subject: Re: BUG #15069: group by after regexp_replace
  In-Reply-To: <151870768979.1393.4103488163602755553@wrigleys.postgresql.org>
  References: <151870768979.1393.4103488163602755553@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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