From: Tom Lane <tgl@sss.pgh.pa.us>
To: Howard Smith <hsmith@visualmining.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: UNION and LIMIT issue
Date: Thu, 19 Jul 2007 18:27:59 -0400
Message-ID: <10865.1184884079@sss.pgh.pa.us> (raw)
In-Reply-To: <469FDF17.9060701@visualmining.com>
References: <469FDF17.9060701@visualmining.com>
Howard Smith <hsmith@visualmining.com> writes:
> SELECT name,quantity FROM fruit limit 3
> UNION
> select name,CAST(SUM(quantity) as integer) from (
> select Cast('Other' as varchar) as name,quantity from fruit
> limit ALL offset 3
> ) w group by name
You need parentheses:
(SELECT ... limit 3) UNION ...
ISTM that a LIMIT without an ORDER BY is a pretty bad idea, btw.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, hsmith@visualmining.com
Subject: Re: UNION and LIMIT issue
In-Reply-To: <10865.1184884079@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox