QuestionQ43

VerifiedRestricting and Sorting Data

Review the structure of the CUSTOMERS table shown below:

Question Image

For customers whose income level has a value, you need to display the first name along with a due amount calculated as 5% of their credit limit. Customers whose due amount is null must be excluded from the output.

Which query should you use?

Explanation

DUE_AMOUNT is only a column alias created in the SELECT clause (cust_credit_limit * .05 AS DUE_AMOUNT); it does not exist as an actual table column, so it cannot be referenced in the WHERE clause — WHERE clause filtering happens before SELECT-list aliases are resolved. This rules out any option that filters on 'due_amount' or the nonexistent 'cust_credit_level' column. Furthermore, NULL values can only be tested correctly with IS NULL / IS NOT NULL; using != or <> against NULL always evaluates to UNKNOWN and returns no rows, making those options invalid. The correct approach is to filter on the real columns: CUST_INCOME_LEVEL IS NOT NULL (to include only customers with a known income level) and CUST_CREDIT_LIMIT IS NOT NULL (since the due amount is computed directly from credit limit, a non-null credit limit guarantees a non-null due amount, satisfying the requirement to exclude customers with a null due amount).

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!