DB2: How to Fix Column MASK Error When You Use GROUP BY

SQL Query to create column mask is 

CREATE (OR REPLACE) MASK (NAME) ON (TABLE) FOR COLUMN (NAME)
RETURN (EXPRESSION) ENABLE (OR DISABLE)
ALTER TABLE (NAME) ACTIVATE COLUMN ACCESS CONTROL

Why COLUMN Masking?

Essentially a data mask is nothing more than displaying a value based on a rule for a specific column.

Row access control is specifically geared for the government and a level of security needed for top secret projects. However, column access control was designed to protect sensitive information from table owners or even the database administrator. 

During GROUP BY You will receive an error:

THE STATEMENT CANNOT BE PROCESSED BECAUSE COLUMN MASK mask-name (DEFINED FOR COLUMN column-name) EXISTS AND THE COLUMN MASK CANNOT BE APPLIED OR THE DEFINITION OF THE MASK CONFLICTS WITH THE REQUESTED STATEMENT. REASON CODE reason-code.

THE STATEMENT CANNOT BE PROCESSED BECAUSE COLUMN MASK mask-name (DEFINED FOR COLUMN column-name) EXISTS AND THE COLUMN MASK CANNOT BE APPLIED OR THE DEFINITION OF THE MASK CONFLICTS WITH THE REQUESTED STATEMENT. REASON CODE reason-code.

Resolution

You need to remove column name from GROUP BY of SQL query

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.