'Group by issue in Hive

I have table having three field Tab1(user_id,flag1,flag2). sample data:

user_id    Flag1     Flag2
10001       0          1 
10001       1          0
10001       0          1
10002       1          0
10002       0          1 

How to get output as:

User_id.   Flag1.     Flag2
10001       1         1
10002       1         1


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source