Saturday, July 26, 2008

[SQL] Efficiently determining the number of bits set in the contents of a VARBIT field

Hi all,
Am looking for a fast and efficient way to count the number of bits set
(to 1) in a VARBIT field. I am currently using
"LENGTH(REGEXP_REPLACE(CAST(a.somefield_bit_code AS TEXT),'0','','g'))".

Allan.


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

No comments: