select unit, sum(1 << bit_position) from table1 where val group by unit;

To make it more complex.. Is it possible to select into "different bytes" depending on bit_position? (For example that bit_position 0-7 represent byte 1, bit_position 8-15 represent another)

To get a second "byte" I can tweak your initial idea to:

select unit, sum(1 << (bit_position-9)) from table1 where val and bit_position between 8 and 15 group by unit;

But that would need to get merged into the initial solution some way on the same select row result.

sqlite-users mailing list

Reply via email to