pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: pgsql-sql@postgresql.org
Cc: franco@akyasociados.com.ar
Subject: Re: What's wrong with this group by clause?
Date: Thu, 13 Mar 2003 15:12:47 +0100
Message-ID: <3E7091DF.AECA1635@rodos.fzk.de> (raw)

> Hi everyone.=20
>
> Below you can find a simplified example of a real case.=20
> I don't understand why I'm getting the "john" record twice.=20
> I know there's no point in using constants in the group by, but makes
sense=
>  in=20
> the real much bigger query.=20
> What I see is that when I issue an EXPLAIN with this query, it tells
me tha=
> t=20
> the SORT KEY is "0".=20
> When I remove one of the constant fields and try again the EXPLAIN, it
says=
> =20
> that the SORT KEY is "0, name" (and the group by works, it shows only
one=
> =20
> record for each person in the table).
>
> Thanks anyone.
>
> /*EXAMPLE*/
> CREATE TABLE people
> (
>    name TEXT
> );
> INSERT INTO people VALUES ('john');
> INSERT INTO people VALUES ('john');
> INSERT INTO people VALUES ('pete');
> INSERT INTO people VALUES ('pete');
> INSERT INTO people VALUES ('ernest');
> INSERT INTO people VALUES ('john');
> =20=20=20
> SELECT
>    0 AS field1,
>    0 AS field2,=20
>    name
> FROM
>    people
> GROUP BY
>    field1,
>    field2,
>    name;
>
I did your example and did not get the "john" record twice.
Instead I got what you expected.
 field1 | field2 |  name
--------+--------+--------
      0 |      0 | ernest
      0 |      0 | john
      0 |      0 | pete
(3 rows)
What version are you using?

Regards, Christoph





view thread (8+ messages)  latest in thread

Message-ID: <3E7091DF.AECA1635@rodos.fzk.de>
Permalink:  ../3E7091DF.AECA1635@rodos.fzk.de/
Also on:    postgresql.org/message-id/3E7091DF.AECA1635@rodos.fzk.de

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, franco@akyasociados.com.ar
  Subject: Re: What's wrong with this group by clause?
  In-Reply-To: <3E7091DF.AECA1635@rodos.fzk.de>

* 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