Bitwise interview question

SQL queries and Java pattern