Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id ADED19FB901 for ; Thu, 19 Jul 2007 19:07:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 01663-07 for ; Thu, 19 Jul 2007 19:07:48 -0300 (ADT) X-Greylist: delayed 00:06:40.917456 by SQLgrey-1.7.5 Received: from visualmining.com (mail.visualmining.com [12.153.42.2]) by postgresql.org (Postfix) with SMTP id B2BE89FB6B5 for ; Thu, 19 Jul 2007 19:07:47 -0300 (ADT) Received: (qmail 10722 invoked from network); 19 Jul 2007 21:58:28 -0000 Received: from hsmith.visualmining.com (HELO [192.168.1.170]) (192.168.1.170) by powerelf.visualmining.com (192.168.1.214) with ESMTP; 19 Jul 2007 21:58:27 -0000 Message-ID: <469FDF17.9060701@visualmining.com> Date: Thu, 19 Jul 2007 18:00:55 -0400 From: Howard Smith User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: UNION and LIMIT issue Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.961 tagged_above=0 required=5 tests=BAYES_50=0.001, RCVD_IN_BL_SPAMCOP_NET=1.96 X-Spam-Level: * X-Archive-Number: 200707/120 X-Sequence-Number: 28855 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