Progress
SQL-92
Guide and Reference


Expressions

An expression is a symbol or string of symbols used to represent or calculate a single value in a SQL statement. When you specify an expression in a statement, SQL retrieves or calculates the value represented by the expression and uses that value when it executes the statement. Expressions are also called scalar expressions or value expressions.

This is the syntax for an expression (expression):

SYNTAX
[ table_name.| alias. ] column_name
    | character_literal
    | numeric_literal
    | date_time_literal
    | aggregate_function
    | scalar_function
    | numeric_arith_expr
    | date_arith_expr
    | conditional_expr
    | (expression) 

[ table_name.| alias.]column_name

Specifies a column in a table. You can qualify a column name with the name of the table or the alias it belongs to.

character_literal | numeric_literal | date_time_literal

Specify constant values. See the "Literals" section for information on specifying literals.

aggregate_function | scalar_function

SQL functions. See "SQL-92 Functions" for more information on “Aggregate Functions” and “Scalar Functions.”

numeric_arith_expr

Computes a value from numeric values. See "Numeric Arithmetic Expressions" for more information.

date_arith_expr

Computes a value from date-time values. See "Date Arithmetic Expressions" for more information.

conditional_expr

Evaluates a search condition or expression and returns one of multiple possible results depending on that evaluation.

(expression)

SQL evaluates expressions in parentheses first.

EXAMPLES

The following example illustrates specifying a table name for the customer_id field:

SELECT customer.customer_id FROM customers ; 

You must qualify a column name if it occurs in more than one table specified in the FROM clause:

SELECT customer.customer_id FROM customers, orders ; 

NOTES

The following example shows a query expression that joins the table customer with itself. It uses the aliases x and y and returns information on customers in the same city as customer SMITH:

SELECT y.cust_no, y.last_name 
     FROM customer x, customer y
     WHERE x.last_name = ’SMITH’ 
     AND y.city = x.city ; 


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095