Bitwise interview question

Sql queries , different approaches for backend logics.