agora inbox for pgsql-docs@postgresql.org  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: kes-kes@yandex.ru
Subject: Add example to sort results by two composite types
Date: Sun, 13 Jul 2025 13:23:40 +0000
Message-ID: <175241302040.858619.13742825859329909914@wrigleys.postgresql.org> (raw)

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/rowtypes.html
Description:

The doc has example:
All of these ORDER BY clauses specify the row's composite value, resulting
in sorting the rows according to the rules described in Section 9.25.6.
However, if inventory_item contained a column named c, the first case would
be different from the others, as it would mean to sort by that column only.
Given the column names previously shown, these queries are also equivalent
to those above:

SELECT * FROM inventory_item c ORDER BY ROW(c.name, c.supplier_id, c.price);
SELECT * FROM inventory_item c ORDER BY (c.name, c.supplier_id, c.price);

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.

Thank you.


view thread (3+ messages)  latest in thread

Message-ID: <175241302040.858619.13742825859329909914@wrigleys.postgresql.org>
Permalink:  ../175241302040.858619.13742825859329909914@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/175241302040.858619.13742825859329909914@wrigleys.postgresql.org

reply

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: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, kes-kes@yandex.ru
  Subject: Re: Add example to sort results by two composite types
  In-Reply-To: <175241302040.858619.13742825859329909914@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox