"Gurjeet Singh" <singh.gurjeet@gmail.com> writes:
> Probably this explains the ERROR for the last query... The ORDER BY
> and LIMIT clauses are expected to end a query (except for subqueries,
> of course), and hence the keyword UNION is not expected after the
> LIMIT clause...
Yeah. In theory that's unambiguous, but IIRC we couldn't persuade
bison of the fact, so you have to add parens.
regards, tom lane