The SELECT statement retrieves field values from a table using a query. SELECT can be:
  • The first statement of the query, known as OUTER SELECT—Sends data out of the SQL engine.
  • Present in any inner part of the query, known as INNER SELECT—Provides data to the other parts of the query for internal processing. Typically, INNER SELECT is used in subqueries.
SELECT statements can either use simple table fields or use complex expressions, aggregate functions, or scalar functions on the field data. If you do not have access to sensitive data or lack the unmasking privileges over DDM-configured fields that are referenced by an OUTER SELECT statement, the query result set contains masked values for these fields. Regardless of your DDM privileges, INNER SELECT statements always use unmasked field values for internal processing.
Note: Fields used in the SELECT list of the SELECT query display the data at the client application and are therefore always masked for unauthorized users.

Examples

The following example illustrates a simple SELECT query that retrieves a DDM-configured field.
SELECT CustNum, Name, Phone FROM pub.Customer;
In this example, Phone is a DDM-configured field. The query displays the unmasked values of Phone if you have the necessary unmasking privileges. In the absence of these privileges, the query displays masked values.

The following example illustrates a SELECT query with a mathematical expression involving a DDM-configured field.
SELECT InvoiceNum, CustNum, TotalPaid -(Amount + ShipCharge) 
FROM pub.Invoice; 
In this example, TotalPaid is a DDM-configured field. The SQL engine uses the unmasked value of TotalPaid to calculate the expression TotalPaid -(Amount + ShipCharge) and returns an expected result, provided that you have the necessary unmasking privileges. However, in the absence of these privileges, the SQL engine calculates the expression using the masked value of TotalPaid and returns an inaccurate result, which is an expected behavior.