On 21 February 2012 17:44, Richard Broersma <richard(dot)broersma(at)gmail(dot)com> wrote:
> There are probably fast better ways. But this is one way:
> postgres=> SELECT LENGTH( REPLACE( CAST( B'101000000000000000000010'
> AS TEXT ), '0', ''));
That seems like a good way to do it, unless you need to do this on a
lot of data and need it to be very fast or something.
If so, then maybe have a look at this:
and maybe even this:
and implement it as a user defined function in C.
Michael Wood <esiotrot(at)gmail(dot)com>
In response to
pgsql-novice by date
|Next:||From: Matthias Leopold||Date: 2012-02-21 16:44:17|
|Subject: return values from plperl function|
|Previous:||From: Richard Broersma||Date: 2012-02-21 15:44:22|
|Subject: Re: How to count ones in a bit string?|