On Thu, 2021-06-10 at 10:39 +0200, Luca Ferrari wrote: > I also realized that this "table to tuples" expansion works for GROUP BY too. > However, I'm not able to find this documented in GROUP BY, WHERE, > ORDER BY clauses sections into select documentation > <fgrouphttps://www.postgresql.org/docs/12/sql-select.html>;. Could be > my fault, of course. I don't think it is really documented outside the source, but it is called a "whole-row reference" and behaves in SQL like composite data type that belongs to the table. So ordering is lexicographical, equality is equality of all members, and don't ask me about IS NULL and IS NOT NULL, else I point you to https://www.postgresql.org/message-id/flat/48BDABE9-88AB-46E9-BABE-F70DDBFB98BD%40kineticode.com Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com