Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 057609FA5F9 for ; Mon, 16 Jul 2007 09:17:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 22299-04 for ; Mon, 16 Jul 2007 09:17:13 -0300 (ADT) X-Greylist: delayed 00:20:01.025475 by SQLgrey-1.7.5 Received: from dfbsa63.conab.gov.br (dfbsa63.conab.gov.br [200.140.131.205]) by postgresql.org (Postfix) with ESMTP id 59B3F9FA4B8 for ; Mon, 16 Jul 2007 09:17:29 -0300 (ADT) Received: from [10.131.1.6] (unknown [10.131.1.6]) by dfbsa63.conab.gov.br (Postfix) with ESMTP id 145BA940CE; Mon, 16 Jul 2007 08:57:13 -0300 (BRT) Message-ID: <469B5D14.4090700@conab.gov.br> Date: Mon, 16 Jul 2007 08:57:08 -0300 From: Roberto Spier User-Agent: Thunderbird 2.0.0.0 (Windows/20070326) MIME-Version: 1.0 To: =?ISO-8859-1?Q?Dani_Casta=F1os?= CC: pgsql-sql@postgresql.org Subject: Re: Having the sum of two queries References: <469B512D.70507@gmail.com> In-Reply-To: <469B512D.70507@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.5 tagged_above=0 required=5 tests=AWL=0.499, BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200707/93 X-Sequence-Number: 28828 Dani Castaņos escreveu: ... > > And have the result of both added. > > I've tried something like > > SELECT tot.status, COUNT(total) Should be SELECT tot.status, SUM(total) > FROM( QUERY A UNION QUERY B ) AS tot > GROUP BY tot.status > > But it doesn't works. It doesn't add the total columns with the same > status...