Hard1 markMultiple Choice
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?
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
Q01A CPA is advising a client who is migrating their legacy on-premise ERP system to a cloud-based s...MediumQ02During a review of a client's cloud governance structure, an auditor notes that the client uses a...MediumQ03An auditor is evaluating the 'Processing Integrity' principle for a financial institution's loan ...HardQ04A company uses a batch processing system to update inventory records overnight. The 'Grandfather-...HardQ05During a walkthrough of the change management process, an auditor observes that the 'Developer' r...Medium
Expert