Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWeua-00GWhw-JM for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jul 2024 16:32:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sWeuZ-006OJp-3O for pgsql-docs@arkaria.postgresql.org; Wed, 24 Jul 2024 16:32:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sWeuY-006OJh-N1 for pgsql-docs@lists.postgresql.org; Wed, 24 Jul 2024 16:32:18 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sWeuW-001ERD-34 for pgsql-docs@lists.postgresql.org; Wed, 24 Jul 2024 16:32:17 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a7ab5fc975dso4898866b.1 for ; Wed, 24 Jul 2024 09:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721838734; x=1722443534; darn=lists.postgresql.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=laJ+e7Vkl3gYdiVfGw8qmmJGdgWWSLpTI0sGh6ijMwY=; b=XefuLeEjrsymHCB9rTuR42UdU562YH6k/bKgJw++NMMJx3/vtv3A8kmMe48nXt4n5Z e8sfw4KqxEt4kLKNaB6Nu3WlXqgMFrm+HAhtlin43DDe6qAg7FB7xpTIsLC7OKbZ8M05 FjfV4bml0dhTgIi53z3BZbcxL/k+te5TRdfLnAfBZtXvFiA0lBf+JQc/9R5Bpk1CKaD5 AfY2f2ITgJgES7VBW63glwfnMvpurKiukdW0frN9L47Qr3qJwB09AnPOPy457+6aBdsU veUljZokByTQyddyP+s1cpIpKD0WXvIY38iaEzceH3awJMtMM2yHIk0YluLrnc9t8ZD9 ztBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721838734; x=1722443534; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=laJ+e7Vkl3gYdiVfGw8qmmJGdgWWSLpTI0sGh6ijMwY=; b=I0DxYg5ycMJtZJdVJnKzJn+H/2bj//IzmwYACDd0HLIAR0jC/kjZYXfOEGmcS214H9 rr7rBXLboWL7YosyPF6Wp57blmSi3jJj7ovYB2VCX3/LoIr/1oQMPw0zX0K5QZ6aIGjg MC2IuGaF2+cw9TVpnrE25hQJCrv7T+23ywJHUh+dQEPWxchTKr0vtj/FhHGrwJTb6CIy bcT7vPr9GRmyCT/8u2YjOYs0X4oG4K4R1SLGqxJBYMtq2iVcpcYpJvqATLtoFHK/0xma j0lm/3eEdJpA+DQpIHLdMiqBSiJ11qizDibxjKoxPkEEynZZyah8Am/crhJwFAqd0Hyy uiNA== X-Forwarded-Encrypted: i=1; AJvYcCVb+iOv7PPkMUnZAJm6l+bBPDWaT3O2U/Hnfzraa35M/O4T4riBk+Mp0q/kyjgSlRtPzj64Dk8guRxnIxvnAJCzWwD8+L+8TZAoM0PRx5i2 X-Gm-Message-State: AOJu0YzP3zoNnsTL2E1gfb2tnydim6PLNvs7gVvctmfCaibApy2OKT+2 IlYNTThpb/iDN7vrRWMNKsNOLg9+m9Pn3Lx45okIwssmI4fzEOZtEDa+Ug== X-Google-Smtp-Source: AGHT+IFfL7bHBPSbzbfh2L/vh4Mb3+rQyEuhzuhf2vPjIZDAV802cJV+TVMuagavjAxtgG8J4eQs2w== X-Received: by 2002:a17:906:7952:b0:a7a:b070:92c0 with SMTP id a640c23a62f3a-a7ab070a82cmr213766866b.23.1721838717941; Wed, 24 Jul 2024 09:31:57 -0700 (PDT) Received: from smtpclient.apple ([178.92.183.227]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c7bea7esm659899666b.83.2024.07.24.09.31.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jul 2024 09:31:57 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-BAD86604-A562-4AD6-B0D0-81B5A5021654 Content-Transfer-Encoding: 7bit From: Yaroslav Saburov Mime-Version: 1.0 (1.0) Subject: Re: wrong field in example Date: Wed, 24 Jul 2024 19:31:55 +0300 Message-Id: <8EF645CB-0AE2-4113-80CB-97720A74939E@gmail.com> References: <1242015.1721837850@sss.pgh.pa.us> Cc: "David G. Johnston" , PostgreSQL Documentation In-Reply-To: <1242015.1721837850@sss.pgh.pa.us> To: Tom Lane X-Mailer: iPhone Mail (19H384) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-BAD86604-A562-4AD6-B0D0-81B5A5021654 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable first query =3D> SELECT * FROM test1; x | y ---+--- a | 3 c | 2 b | 5 a | 1 (4 rows) second query =3D> 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 lis= t since they have a single value in each group. > 24 =D0=BB=D0=B8=D0=BF. 2024 =D1=80. =D0=BE 19:17 Tom Lane =D0=BF=D0=B8=D1=88=D0=B5: >=20 > =EF=BB=BF"David G. Johnston" writes: >> I don't know that the existing wording is the most clear, but it is corre= ct. >=20 > 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. >=20 > regards, tom lane --Apple-Mail-BAD86604-A562-4AD6-B0D0-81B5A5021654 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
= first query
=3D> SELECT * FROM test1;
 x | y
---+---
 a | 3
 c | 2
 b | 5
 a | 1
(4 rows)

second query
=3D> SELECT x FROM test1 GR=
OUP 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 i= s 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 th= ey have a single value in each group.


<= /div>


24 =D0=BB=D0=B8=D0=BF. 2024 =D1=80. =D0=BE 19:17 Tom Lane <tgl@ss= s.pgh.pa.us> =D0=BF=D0=B8=D1=88=D0=B5:

=EF=BB=BF"David G. Johnston" <da= vid.g.johnston@gmail.com> writes:
I don't know that the existing wording is the most clear, but it is corre= ct.

Perhaps it'd be better to w= rite "... we could not have written
SELECT x, y FROM test1 G= ROUP BY x, because ..." ?  The first
half of the exampl= e uses "SELECT *", and this bit was meant
to be consistent w= ith that; but if the reader is confused about
how "y" got in= to the discussion then writing it out explicitly
should help= .

           = ;regards, tom lane
= --Apple-Mail-BAD86604-A562-4AD6-B0D0-81B5A5021654--