SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
2-190
Considerations for SELECT
the UNION are the same as the corresponding names in the select list of the left
SELECT statement. A column resulting from the UNION of expressions or
constants has the name (EXPR).
See Considerations for UNION on page 2-196.
ORDER BY {colname | colnum} [ASC[ENDING] | DESC[ENDING]]
[,{colname | colnum} [ASC[ENDING] | DESC[ENDING]]]...
specifies the order in which to sort the rows of the final result table.
colname
names a column in select-list or a column in a table reference in the
FROM clause of the SELECT statement. colname is optionally qualified by a
table, view, or correlation name; for example, CUSTOMER.CITY. If a column
has been aliased to another name you must use the alias name.
colnum
specifies a column by its position in select-list. Use colnum to refer to
unnamed columns, such as derived columns.
ASC | DESC
specifies the sort order. The default is ASC. For ordering a result table on a
column that can contain null, nulls are considered equal to one another but
greater than all other nonnull values.
See Considerations for ORDER BY on page 2-195.
Considerations for SELECT
Multiple Row and Single Row SELECT Statements
Use a multiple row SELECT statement (without the INTO clause) within a CREATE
VIEW statement to specify views. You can also use it to query a database within MXCI.
In embedded SQL, a multiple row SELECT statement can also be a cursor
specification—a special case of a query expression. For more information, see the
SQL/MX Programming Manual for C and COBOL. See syntax for query-expr on
page 2-175.
In embedded SQL, if rowset host variables are not used, you use a single row SELECT
statement (with the INTO clause) to retrieve only one row. If the SELECT statement
(with the INTO clause) retrieves more than one row, and rowsets are not used,
NonStop SQL/MX raises an error. If rowset host variables are used in the INTO clause
multiple rows can be retrieved with a multiple row SELECT statement.
Embed