Results per letter query

From: Dani Castaños <dcastanos(at)androme(dot)es>
To: pgsql-sql(at)postgresql(dot)org
Subject: Results per letter query
Date: 2007-06-21 09:10:02
Message-ID: 467A406A.3060907@androme.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-06-21 09:18:29 Re: Select last there dates
Previous Message Loredana Curugiu 2007-06-21 08:18:13 Select last there dates