SQL/MP Query Guide
Retrieving Data: How to Write Queries
HP NonStop SQL/MP Query Guide—524488-003
1-44
Evaluating Multiple Conditions
This is the result:
LAST_NAME FIRST_NAME (EXPR)
------------- ------------- --------
CHENG TINA MARRIED
GONZALES LINDA SINGLE
LEBLANC PIERRE DIVORCED
PETSKI STEVE SINGLE
--- 4 row(s) selected.
Although the marital statuses of the employees were encoded as 1, 2, and 3, the result
contains marital statuses that are decoded.
Evaluating Multiple Conditions
When you use CASE with a search condition, SQL can evaluate multiple conditions in
a single query, eliminating your need to write several queries that scan tables multiple
times. Processing takes place within the SQL statement, reducing the coding required
for the application program.
Suppose that you want to know the salaries of employees after you give a 10 percent
raise to those in Department 9000 and a 12 percent raise to those in Department 1000.
You can determine these salaries by using CASE with a search condition.
This example shows your employees with their current salaries:
SELECT LAST_NAME, FIRST_NAME, DEPTNUM, SALARY FROM EMPLOYEE ;
LAST_NAME FIRST_NAME DEPTNUM SALARY
------------- ------------- ------ ----------
CHENG TINA 1000 65000.00
GONZALES LINDA 9000 75500.00
LEBLANC PIERRE 9000 37000.00
PETSKI STEVE 3500 50000.00
--- 4 row(s) selected.
When you perform a query using a CASE expression with a search condition, you can
see each employee’s new salary: