Re: wrong field in example
От | Yaroslav Saburov |
---|---|
Тема | Re: wrong field in example |
Дата | |
Msg-id | 8EF645CB-0AE2-4113-80CB-97720A74939E@gmail.com обсуждение исходный текст |
Ответ на | Re: wrong field in example (Tom Lane <tgl@sss.pgh.pa.us>) |
Список | 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 по дате отправления: