Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 0FD009F9F63 for ; Mon, 8 Oct 2007 08:59:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 44955-01 for ; Mon, 8 Oct 2007 08:59:11 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.183]) by postgresql.org (Postfix) with ESMTP id 463969F9CBA for ; Mon, 8 Oct 2007 08:59:11 -0300 (ADT) Received: from webserv.wug.de ([194.25.154.138]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis) id 0MKxQS-1IerGM43Uu-0002hN; Mon, 08 Oct 2007 13:59:08 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1IerGM-00076x-00 for pgsql-sql@postgresql.org; Mon, 08 Oct 2007 13:59:06 +0200 Date: Mon, 8 Oct 2007 13:59:06 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Get different sums from the same table in one query Message-ID: <20071008115906.GD15336@a-kretschmer.de> References: <470A0B20.40203@gmail.com> <20071008105422.GC15336@a-kretschmer.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX19ucNtS9VjT5qfAFauPV4YAb/kJt+xrTrByb8m +rccYhNhR47INgL6lmwpOGFT/5rQ5FY85RNIh2aOTEP6ycdIqc iqicuZN0jkmT6yo3UQwmCuz1zNGzV6s X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/41 X-Sequence-Number: 29413 am Mon, dem 08.10.2007, um 12:32:55 +0100 mailte Peter Childs folgendes: > > > On 08/10/2007, A. Kretschmer wrote: > > am Mon, dem 08.10.2007, um 12:49:04 +0200 mailte Dani Castaņos folgendes: > > Hi all! > > > > I want to put this three queries in only one... Take a look that the > > only thing that changes is the message_type_id. Any suggestions?? > > Yes, no problem, You can use UNION (ALL) for such. > > > > Not sure thats what he wants at all. Anyway Union all is going to produce a > very slow way of doing this needing to go back to the data 3 times where as > this only goes once. Right, conditional statements are a proper solution for this. Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net