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 1uchIe-00FtxR-L5 for pgsql-docs@arkaria.postgresql.org; Fri, 18 Jul 2025 09:22:40 +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 1uchIb-009pKR-Mc for pgsql-docs@arkaria.postgresql.org; Fri, 18 Jul 2025 09:22:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uchIb-009pKJ-Ef for pgsql-docs@lists.postgresql.org; Fri, 18 Jul 2025 09:22:38 +0000 Received: from forward501d.mail.yandex.net ([178.154.239.209]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uchIZ-008Pch-1s for pgsql-docs@lists.postgresql.org; Fri, 18 Jul 2025 09:22:37 +0000 Received: from mail-nwsmtp-mxback-production-main-48.iva.yp-c.yandex.net (mail-nwsmtp-mxback-production-main-48.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:3b1f:0:640:fb8a:0]) by forward501d.mail.yandex.net (Yandex) with ESMTPS id 20666636E8; Fri, 18 Jul 2025 12:22:34 +0300 (MSK) Received: from mail.yandex.ru (2a02:6b8:c0c:89a8:0:640:c417:0 [2a02:6b8:c0c:89a8:0:640:c417:0]) by mail-nwsmtp-mxback-production-main-48.iva.yp-c.yandex.net (mxback/Yandex) with HTTPS id WMKwDc5MuuQ0-UsIuXbEr; Fri, 18 Jul 2025 12:22:33 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1752830553; bh=0oQ8W+Yzs+DMoETHzPmsYnPXX2IHZszUBm2wUUqbadM=; h=Message-Id:References:Date:Subject:To:In-Reply-To:From; b=G3kPb6NYkWD8E2Nc64r6vKf6jUiigUjfq38twjck2mDRB3D26snsavjUIFghBaxbk wbZVPMHj03hiotsvEg1F4HG+MD1xBW54E3U3Ta1nM9fZO3Rx8ALY3hVsYuS8ozBaqw RC7gnHnAn5Z1kYRCXUU6glPIL7h4/ldw3Fj/e+98= Authentication-Results: mail-nwsmtp-mxback-production-main-48.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Received: by qnb4xdsvdwd5l2mw.iva.yp-c.yandex.net (sendbernar/Yandex) with HTTPS id ba1f06ea2872b151c278a742a65f8875; Fri, 18 Jul 2025 12:22:27 +0300 From: KES To: David G. Johnston , "pgsql-docs@lists.postgresql.org" In-Reply-To: References: <175241302040.858619.13742825859329909914@wrigleys.postgresql.org> Subject: Re: Add example to sort results by two composite types MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 18 Jul 2025 12:22:27 +0300 Message-Id: <221161752830249@mail.yandex.ru> Content-Transfer-Encoding: 8bit Content-Type: text/html; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk
I never saw such examples before and never thought that I can pass two composite types into ORDER BY clause. Because this section is about composite types, I found it could be useful to highlight that possibility. Otherwise it is too implicit. at least for not so experienced users like me.
 
 


----------------
Кому: kes-kes@yandex.ru (kes-kes@yandex.ru), pgsql-docs@lists.postgresql.org (pgsql-docs@lists.postgresql.org);
Тема: Add example to sort results by two composite types;
14.07.2025, 16:58, "David G. Johnston" <david.g.johnston@gmail.com>:
On Sunday, July 13, 2025, PG Doc comments form <noreply@postgresql.org> wrote:

I suggest to extend the example to sort results by first composite type and
then by the second:
SELECT * FROM invertory_type t, inventory_item c ORDER BY (c.name,
c.supplier_id, c.price), (t.name, t.value);

Though I did not checked this if it possible or not. It would be nice to
have it documented.

What new information does that add or uncertainty does it clarify?  This isn’t a section teaching order by - the reader is expected to already understand that an order by clause can accept two column names and how those are treated (i.e., ties among the first are broken by the second).  This is a section about how within that structure the comparisons happen.  A single column suffices to make that explanation.

David J.