Re: substr_count - Mailing list pgsql-sql

From Rod Taylor
Subject Re: substr_count
Date
Msg-id 1057844586.46100.129.camel@jester
Whole thread Raw
In response to substr_count  (Tom Rochester <tomr@chu.com.au>)
List pgsql-sql
On Thu, 2003-07-10 at 04:38, Tom Rochester wrote:
> Hey all,
>
> I would like to achive something along the lines of:
>
> SELECT field FROM table WHERE field ILIKE '$searchterm' ORDER BY
> substr_count(field, '$searchterm');
>
> Of course the substr_count function does not exist. Is there anyway to
> do this?
>
> I had a thought char_count(replace(field, !$searchterm, '')) might do
> the job but replace doesn't allow for 'replace everything NOT string';

How about:

(char_count(field) - char_count(replace(field, $searchterm, '')))

pgsql-sql by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: help yourself by helping others
Next
From: Yasir Malik
Date:
Subject: Re: help yourself by helping others