documentation extension request - order with function over aggregated functions

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: estanislao(dot)gonzalez(at)projo(dot)zone
Subject: documentation extension request - order with function over aggregated functions
Date: 2020-02-04 08:59:41
Message-ID: 158080678185.1098.6542165890616974586@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

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
```

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Stephen Frost 2020-02-04 16:23:36 Re: Documentation: 21.5. Default Roles
Previous Message Magnus Hagander 2020-02-04 08:34:37 Re: Documentation: 21.5. Default Roles