Re: substr_count - Mailing list pgsql-sql

From scott.marlowe
Subject Re: substr_count
Date
Msg-id Pine.LNX.4.33.0307100936220.10734-100000@css120.ihs.com
Whole thread Raw
In response to substr_count  (Tom Rochester <tomr@chu.com.au>)
List pgsql-sql
On Thu, 10 Jul 2003, 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';

You'll likely have to code a bit in pl/pgsql.  The regex capable substring 
of 7.3 might come in handy.



pgsql-sql by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: max length of sql select statement ?
Next
From: "scott.marlowe"
Date:
Subject: Re: trigger proceedures in sql