Output 2.10 Referring to a Calculated Column by Alias
Note: Because this query sets a numeric format of 4.1 on the HighC, LowC, and Range
columns, the values in those columns are rounded to the nearest tenth. As a result of
the rounding, some of the values in the HighC and LowC columns do not reflect the
range value output for the Range column. When you round numeric data values, this
type of error sometimes occurs. If you want to avoid this problem, then you can
specify additional decimal places in the format.
For more information, see “Using Column Aliases” on page 146.
Assigning Values Conditionally
Using a Simple CASE Expression
CASE expressions enable you to interpret and change some or all of the data values in a
column to make the data more useful or meaningful.
You can use conditional logic within a query by using a CASE expression to
conditionally assign a value. You can use a CASE expression anywhere that you can use
a column name.
The following table, which is used in the next example, describes the world climate
zones (rounded to the nearest degree) that exist between Location 1 and Location 2:
32 Chapter 2 • Retrieving Data from a Single Table