Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 712CD9FBEC0 for ; Thu, 21 Jun 2007 06:29:07 -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 25692-08-2 for ; Thu, 21 Jun 2007 06:28:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id C6EFE9FBF25 for ; Thu, 21 Jun 2007 06:28:56 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from fafnir.androme.com (fafnir.androme.com [62.58.96.158]) by svr4.postgresql.org (Postfix) with ESMTP id 693F05AF04F for ; Thu, 21 Jun 2007 09:10:06 +0000 (GMT) Received: by fafnir.androme.com (Postfix, from userid 1003) id F267CB92365; Thu, 21 Jun 2007 11:10:03 +0200 (CEST) Message-ID: <467A406A.3060907@androme.es> Date: Thu, 21 Jun 2007 11:10:02 +0200 From: =?ISO-8859-1?Q?Dani_Casta=F1os?= User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Results per letter query 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=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001, UPPERCASE_25_50=0 X-Spam-Level: X-Archive-Number: 200706/155 X-Sequence-Number: 28645 Hi! I'm trying to build a query to get if there is an occurrence for a field for each alphabetical letter. My first thought to know it was to do something like: SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'B%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'C%' ) LIMIT 1; ... and so on... Is there any way to do it in only one query?? Thank you in advance!