From: Dani CastaƱos <dcastanos@androme.es>
To: pgsql-sql@postgresql.org
Subject: Results per letter query
Date: Thu, 21 Jun 2007 11:10:02 +0200
Message-ID: <467A406A.3060907@androme.es> (raw)
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!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dcastanos@androme.es
Subject: Re: Results per letter query
In-Reply-To: <467A406A.3060907@androme.es>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox