Group by bug? - Mailing list pgsql-general

From wd
Subject Group by bug?
Date
Msg-id CABexzmhtmwdYFyhDAXWsqHf60ZQrJvshrdzX0t1G6g7KcB3G2w@mail.gmail.com
Whole thread Raw
Responses Re: Group by bug?
Re: Group by bug?
List pgsql-general
hi,

wd_test=# \d t1
                         Table "public.t1"
 Column |  Type   |                    Modifiers                   
--------+---------+-------------------------------------------------
 id     | integer | not null default nextval('t1_id_seq'::regclass)
 tag    | text    |

wd_test=# select * from t1;
 id | tag
----+-----
  1 | a
  2 | a
  3 | b
  4 | c
  5 | b
(5 rows)

---- this sql will not group by the case result.
wd_test=# select case t1.tag when 'a' then '1' else '0' end as tag, count(*) from t1 group by tag;
 tag | count
-----+-------
 0   |     1
 0   |     2
 1   |     2
(3 rows)

---- this sql will group by the case result.
wd_test=# select case t1.tag when 'a' then '1' else '0' end as ttag, count(*) from t1 group by ttag;
 ttag | count
------+-------
 0    |     3
 1    |     2
(2 rows)

pgsql-general by date:

Previous
From: François Beausoleil
Date:
Subject: Re: update from a csv file?
Next
From: wd
Date:
Subject: Re: Group by bug?