To add to the inefficiency :^).......

select unit, (sum(1 << bit_position) & 0xff) AS byte1, ((sum(1 << bit_position) 
>> 8) & 0xff) AS byte2 from table1 where val group by unit;


-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Daniel Polski
Sent: Mon 17 October 2016 15:47
To: SQLite mailing list
Subject: Re: [sqlite] Pivot & concat SELECT?


> 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
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
---------------------------------------------------------------------------------------
This email has been scanned for email related threats and delivered safely by 
Mimecast.
For more information please visit http://www.mimecast.com
---------------------------------------------------------------------------------------

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to