Retrieval Using Parentheses

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:

     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:

  1. The department has a budget of under $12,000.

  2. The department is in either the Corporate Division or the Product Division.

Copyright © Thunderstone Software     Last updated: Oct 5 2023
Copyright © 2024 Thunderstone Software LLC. All rights reserved.