From: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
---|---|
To: | Ben-Nes Michael <miki(at)canaan(dot)co(dot)il> |
Cc: | postgres <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to count string occurrence in column |
Date: | 2002-08-27 09:17:44 |
Message-ID: | Pine.LNX.4.21.0208271011310.667-100000@ponder.fairway2k.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 27 Aug 2002, Ben-Nes Michael wrote:
> Hi All
>
>
> How can i count how many time a string 'hello' appear in a column.
>
> for example.
>
> select *, count_num_of_string(column, 'hello') from table;
SELECT colname, count(1) FROM mytable WHERE colname = 'hello';
or case insensitively
SELECT colname, count(1) FROM mytable WHERE lower(colname) = 'hello';
or get a list of frequencies, most frequent listed first:
SELECT colname, count(1) FROM mytable GROUP BY colname ORDER BY 2 DESC;
I don't know any good books on SQL but I suggest you see what you can
find. Of course there may well be some tutorials available on the web.
--
Nigel J. Andrews
Director
---
Logictree Systems Limited
Computer Consultants
From | Date | Subject | |
---|---|---|---|
Next Message | Lee Kindness | 2002-08-27 09:35:59 | Re: how to count string occurrence in column |
Previous Message | Thirumoorthy Bhuvneswari | 2002-08-27 09:10:29 | Cast Type |