Brandon Metcalf <bran...@geronimoalloys.com> writes:
> I tried moving the last group of WHERE, GROUP BY, and ORDER BY before
> the UNION with the query it belongs to, but that results in a
> different syntax error.

I think that's probably what you want to do.  What you're missing is
you need parentheses to put an ORDER BY into an arm of a UNION:

(SELECT ... ORDER BY ...) UNION SELECT ...

Otherwise it wants to consider the ORDER BY as applying to the UNION
output.

                        regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to