Hard1 markMultiple Choice
Area I: Information SystemsData ManagementSQL

CPA · Question 06 · Area I: Information Systems

An auditor is reviewing a SQL query used to extract 'Active Customers' for a marketing report. The query is:<br/><br/>SELECT CustomerID, Name FROM Customers WHERE Status = 'Active' OR Status = 'Pending' AND CreditLimit > 1000<br/><br/>The auditor suspects the logic is flawed because of operator precedence. Which customers will this query actually return?

Answer options:

A.

Customers who are (Active OR Pending) AND have CreditLimit > 1000

B.

Customers who are Active AND have CreditLimit > 1000

C.

Only customers who are Pending AND have CreditLimit > 1000

D.

All 'Active' customers (regardless of credit), plus 'Pending' customers with CreditLimit > 1000

How to approach this question

Apply SQL Order of Operations: NOT > AND > OR. The AND is evaluated first.

Full Answer

D.All 'Active' customers (regardless of credit), plus 'Pending' customers with CreditLimit > 1000✓ Correct
D
SQL Order of Operations dictates that AND is evaluated before OR. Therefore, `Status = 'Pending' AND CreditLimit > 1000` is evaluated as one condition. The query returns anyone who meets that specific condition, OR anyone who is simply 'Active' (ignoring the credit limit for them).

Common mistakes

Assuming the query reads left-to-right without considering operator precedence.

Practice the full CPA ISC Practice Exam 3

82 questions · hints · full answers · grading

More questions from this exam