Re: Group by bug?

From: wd <wd(at)wdicc(dot)com>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Group by bug?
Date: 2012-12-28 07:26:00
Message-ID: CABexzmg9oyVvTra0BZx7TzP7YDuOgmUVLtS8-z1b_+yYOB816A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sorry, forget to say,

PostgreSQL 9.2.2 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.6
20110731 (Red Hat 4.4.6-3), 64-bit

psql (9.2.2)

On Fri, Dec 28, 2012 at 3:24 PM, wd <wd(at)wdicc(dot)com> wrote:

> 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)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jov 2012-12-28 07:47:55 Re: Group by bug?
Previous Message wd 2012-12-28 07:24:23 Group by bug?