UNION and LIMIT issue

From: Howard Smith <hsmith(at)visualmining(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: UNION and LIMIT issue
Date: 2007-07-19 22:00:55
Message-ID: 469FDF17.9060701@visualmining.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

in pgsql 8.2 using LIMIT with UNION is throwing errors...

table is
-------------------------------

name quantity
character varying integer
-------------------------------
Banana 10
Cherry 10
Apple 5
Persimmon 3
Mango 2

the query :

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

throws an error on the UNION. Removing the first 'Limit 3' fixes the query,
but i need the limit statement. Anybody seen this behavior?

--
Howard Smith
professional services engineer
Visual Mining Inc
15825 Shady Grove Road, Suite 20
Rockville, MD 20850
tel 301.795.2239 fax 301.947.8293

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2007-07-19 22:27:59 Re: UNION and LIMIT issue
Previous Message Hannes Dorbath 2007-07-19 07:31:12 Re: pgmemcache