Re: wrong field in example - Mailing list pgsql-docs

From Yaroslav Saburov
Subject Re: wrong field in example
Date
Msg-id 8EF645CB-0AE2-4113-80CB-97720A74939E@gmail.com
Whole thread Raw
In response to Re: wrong field in example  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-docs
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

pgsql-docs by date:

Previous
From: Tom Lane
Date:
Subject: Re: wrong field in example
Next
From: PG Doc comments form
Date:
Subject: Typo in 15.3.4