pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: estanislao.gonzalez@projo.zone
Subject: documentation extension request - order with function over aggregated functions
Date: Tue, 04 Feb 2020 08:59:41 +0000
Message-ID: <158080678185.1098.6542165890616974586@wrigleys.postgresql.org> (raw)

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.5/queries-order.html
Description:

In https://www.postgresql.org/docs/9.5/queries-order.html it is said that
the following is intentionally not allowed:

```
SELECT a + b AS sum, c FROM table1 ORDER BY sum + c;          -- wrong
```

It took me a while to figure out how to do it properly so I propose to add
the following (or similar) info:

---
If you need to sort by this kind of expression, you will have to retrieve an
extra column with the required computation and use it as a sorting key:

```
SELECT a + b AS sum, c FROM table1, a + b + c AS my sorting_key  ORDER BY
my_sorting_key;          -- correct
```


view thread (2+ messages)  latest in thread

Message-ID: <158080678185.1098.6542165890616974586@wrigleys.postgresql.org>
Permalink:  ../158080678185.1098.6542165890616974586@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/158080678185.1098.6542165890616974586@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, estanislao.gonzalez@projo.zone
  Subject: Re: documentation extension request - order with function over aggregated functions
  In-Reply-To: <158080678185.1098.6542165890616974586@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox