Re: "UNION ALL" is failing

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joy Smith <freestuffanddeals(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "UNION ALL" is failing
Date: 2011-08-26 13:52:30
Message-ID: 4260.1314366750@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Joy Smith <freestuffanddeals(at)gmail(dot)com> writes:
> column types are the same so I don't know why this 'union all' is failing.

It's a syntax error --- got nothing to do with column types.

I think what you need to do is parenthesize the first subquery. ORDER
BY isn't allowed to be attached to a UNION subquery otherwise. You're
probably going to need to parenthesize the second subquery too ---
otherwise it will think that that ORDER BY applies to the UNION result,
not the subquery.

I don't offhand remember the syntactic precedence of WITH versus UNION,
but trying to attach WITHs to the subqueries might be another reason to
need parentheses.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joy Smith 2011-08-26 14:26:26 Re: "UNION ALL" is failing
Previous Message Guillaume Lelarge 2011-08-26 13:46:12 Re: "UNION ALL" is failing