Which query selects records from tickets where (status = 'open' AND priority = 'high') OR (status = 'new')?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which query selects records from tickets where (status = 'open' AND priority = 'high') OR (status = 'new')?

Explanation:
In SQL, AND is evaluated before OR, so how you group conditions matters for what the query actually selects. To express “either both status is open and priority is high, or the status is new,” you want the first two conditions treated as one unit and then OR that with the second condition. Using (status = 'open' AND priority = 'high') OR status = 'new' makes the intent explicit: either both open and high priority, or the status is new. This clear grouping helps readability and prevents mistakes if you later add more conditions. Other forms can still work due to precedence, but they’re easier to misread or modify, while this version makes the two alternatives unmistakable.

In SQL, AND is evaluated before OR, so how you group conditions matters for what the query actually selects. To express “either both status is open and priority is high, or the status is new,” you want the first two conditions treated as one unit and then OR that with the second condition.

Using (status = 'open' AND priority = 'high') OR status = 'new' makes the intent explicit: either both open and high priority, or the status is new. This clear grouping helps readability and prevents mistakes if you later add more conditions.

Other forms can still work due to precedence, but they’re easier to misread or modify, while this version makes the two alternatives unmistakable.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy