From: | Brandon Metcalf <brandon(at)geronimoalloys(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: UNION question |
Date: | 2009-07-10 16:34:48 |
Message-ID: | Pine.LNX.4.58L.0907101133520.6574@cedar.geronimoalloys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
t == tgl(at)sss(dot)pgh(dot)pa(dot)us writes:
t> Brandon Metcalf <brandon(at)geronimoalloys(dot)com> writes:
t> > I tried moving the last group of WHERE, GROUP BY, and ORDER BY before
t> > the UNION with the query it belongs to, but that results in a
t> > different syntax error.
t> I think that's probably what you want to do. What you're missing is
t> you need parentheses to put an ORDER BY into an arm of a UNION:
t> (SELECT ... ORDER BY ...) UNION SELECT ...
t> Otherwise it wants to consider the ORDER BY as applying to the UNION
t> output.
Indeed. It was the fact that I was trying to move the ORDER BY along
with WHERE and GROUP BY that was giving me grief.
Thanks.
--
Brandon
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2009-07-10 17:17:08 | Re: SELECT DISTINCT very slow |
Previous Message | Brandon Metcalf | 2009-07-10 16:33:50 | Re: UNION question |