Tuckheng <Tuckheng@vads.com> writes:
> I encountered this error when trying to run a SELECT statement from within a
> Perl program. Would appreciate if someone could help shed some light on what
> may be causing this or how it can be resolved.
ORDER BY on a UNION result can only refer to column names of the UNION
output columns. Lose the "p." and "s." in the ORDER BY and you'll be
fine.
regards, tom lane