SQL to check user details and its activities