Parentheses may be used within a compound condition to clarify or change the order in which the condition is evaluated. A condition within parentheses is evaluted before conditions outside the parentheses.
Example: Retrieve the department name, division name, and budget of all departments who have a budget of less than $12,000, and who are either in the Corporate or the Product Division.
If you enter the query:
SELECT DNAME, DIV, BUDGET
FROM DEPARTMENT
WHERE BUDGET < 12000
AND (DIV = 'CORP' OR DIV = 'PROD') ;
the result displayed will be:
DNAME DIV BUDGET Supplies and Procurement CORP 10500 Customer Support and Service PROD 11000 |
This query retrieves rows from the DEPARTMENT table that satisfy both of the following conditions: