From: Yaroslav Saburov <y.saburov@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: PostgreSQL Documentation <pgsql-docs@lists.postgresql.org>
Subject: Re: wrong field in example
Date: Wed, 24 Jul 2024 19:31:55 +0300
Message-ID: <8EF645CB-0AE2-4113-80CB-97720A74939E@gmail.com> (raw)
In-Reply-To: <1242015.1721837850@sss.pgh.pa.us>
References: <1242015.1721837850@sss.pgh.pa.us>
first query
=> SELECT * FROM test1;
x | y
---+---
a | 3
c | 2
b | 5
a | 1
(4 rows)
second query
=> SELECT x FROM test1 GROUP BY x;
x
---
a
b
c
(3 rows)
In the second query, we could not have written SELECT * FROM test1 GROUP BY x, because there is no single value for the column y that could be associated with each group. The grouped-by columns can be referenced in the select list since they have a single value in each group.
> 24 лип. 2024 р. о 19:17 Tom Lane <tgl@sss.pgh.pa.us> пише:
>
> "David G. Johnston" <david.g.johnston@gmail.com> writes:
>> I don't know that the existing wording is the most clear, but it is correct.
>
> Perhaps it'd be better to write "... we could not have written
> SELECT x, y FROM test1 GROUP BY x, because ..." ? The first
> half of the example uses "SELECT *", and this bit was meant
> to be consistent with that; but if the reader is confused about
> how "y" got into the discussion then writing it out explicitly
> should help.
>
> regards, tom lane
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-docs@postgresql.org
Cc: y.saburov@gmail.com, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pgsql-docs@lists.postgresql.org
Subject: Re: wrong field in example
In-Reply-To: <8EF645CB-0AE2-4113-80CB-97720A74939E@gmail.com>
* 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