>I have an application that tracks a person’s scheduled daily activities in two integer fields by setting a single bit for each 15-minute block of time. With 32 bits in each field, that gives me 16 hours of coverage for a day and I can safely ignore the back side of the clock, so that is sufficient.
>
>I now have to create an availability chart with a single record for each individual that shows all scheduled 15-minute blocks for a day. Since each person may have more than one record for a day, showing different scheduled periods, that involves a BITOR() of each of the relevant integer fields in those records to combine all scheduled blocks into a single record with the same pair of integer fields.
>
>Can any of you clever people come up with an elegant way to accomplish this—inside a SQL SELECT—or otherwise? Something better than a brute-force SCAN FOR or DO WHILE loop for each individual? I’ve wracked my brain for longer than I want to admit without coming up with anything approaching “elegant.”
If you can guarantee that no bit is set more than once, you can simply sum these fields.