public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G Johnston <[email protected]>
To: [email protected]
Subject: Re: Aggregate expression syntax
Date: Tue, 20 Jan 2015 10:44:50 -0700 (MST)
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAA-aLv7A9uqH=U=Czp5UBbukJW6_ip7NDZsAMf6-F72s6Ls+LA@mail.gmail.com>
	<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>

Tom Lane-2 wrote
> Thom Brown &lt;

> thom@

> &gt; writes:
>> Looking at the syntax for aggregate expressions in the docs, it seems the
>> first three forms could perhaps be merged since the ALL and DISTINCT
>> keywords are effectively optional.
> 
> Dunno, just seems harder to read to me...

I'm generally for making the syntax part more succinct and addressing
learning concerns with examples.  The extra noise that needs to be filtered
out when trying to figure out why different structures exist makes it
difficult to read too.

That said, having at least a bare-minimum expression would be helpful:

aggregate_name ( expression )

And now decide whether to have a combined syntax block or keep building
things up like:

aggregate_name ( [ ALL | DISTINCT ] expression [ , ... ] [ order_by_clause]
)
aggregate_name ( argument_clause ) [ FILTER ( WHERE [ filter_clause ] ) ]

argument_clause := " [ ALL | DISTINCT ] expression [ , ... ] [
order_by_clause ] "

If we are going to repeat long and complex parts of the syntax naming them
will make reading subsequent syntax expressions easier and provide semantic
meaning to the reader.  The existing forms, while correct, are repetitive
and that is what is being targeted but combining them into a single syntax
block.  But if that is too hard to read and understand then maybe some other
means of simplification, like my example above, would work better.

David J.







--
View this message in context: http://postgresql.nabble.com/Aggregate-expression-syntax-tp5834726p5834768.html
Sent from the PostgreSQL - docs mailing list archive at Nabble.com.


-- 
Sent via pgsql-docs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs




view thread (3+ messages)

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: [email protected]
  Cc: [email protected]
  Subject: Re: Aggregate expression syntax
  In-Reply-To: <[email protected]>

* 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