Table: user_permissions
+-------------+---------+ | Column Name | Type | +-------------+---------+ | user_id | int | | permissions | int | +-------------+---------+ user_id is the primary key. Each row of this table contains the user ID and their permissions encoded as an integer.
Consider that each bit in the permissions integer represents a different access level or feature that a user has.
Write a solution to calculate the following:
permissions column.permissions column.Return the result table in any order.
The result format is shown in the following example.
Example:
Input:
user_permissions table:
+---------+-------------+ | user_id | permissions | +---------+-------------+ | 1 | 5 | | 2 | 12 | | 3 | 7 | | 4 | 3 | +---------+-------------+
Output:
+-------------+--------------+
| common_perms | any_perms |
+--------------+-------------+
| 0 | 15 |
+--------------+-------------+
Explanation:
Loading editor...
{"headers":{"user_permissions":["user_id","permissions"]},"rows":{"user_permissions":[[1,5],[2,12],[3,7],[4,3]]}}