Considerations For Sort By; Considerations For Order By; Considerations For Distinct; Considerations For Union - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

You can specify GROUP BY using ordinals to refer to the relative position within the SELECT
list. For example, GROUP BY 3, 2, 1.
If you do not include a GROUP BY clause but you specify an aggregate function in the
select-list, all rows of the result table form the one and only group. The result of AVG,
for example, is a single value for the entire table.
The GROUP BY clause must precede a HAVING clause.
The RANDOM function cannot be part of the GROUP BY clause of a sampling method.

Considerations for SORT BY

The RANDOM function cannot be part of the SORT BY clause of a sampling method.

Considerations for ORDER BY

When you specify an ORDER BY clause and its ordering columns, consider:
If you specify DISTINCT, the ordering column must be in select-list.
If you specify a GROUP BY clause, the ordering column must also be a grouping column.
If an ORDER BY clause applies to a union of SELECT statements, the ordering column must
be explicitly referenced, and not within an aggregate function or an expression, in the
select-list of the leftmost SELECT statement.
SQL does not guarantee a specific or consistent order of rows unless you specify an ORDER
BY clause. ORDER BY can reduce performance, however, so use it only if you require a
specific order.
The RANDOM function cannot be part of the ORDER BY clause of a sampling method.

Considerations for DISTINCT

The RANDOM function cannot be part of the DISTINCT clause of a sampling method.

Considerations for UNION

Suppose that the contributing SELECT statements are named SELECT1 and SELECT2, the
contributing tables resulting from the SELECT statements are named TABLE1 and TABLE2, and
the table resulting from the UNION operation is named RESULT.

Characteristics of the UNION Columns

For columns in TABLE1 and TABLE2 that contribute to the RESULT table:
If both columns contain character strings, the corresponding column in RESULT contains a
character string whose length is equal to the greater of the two contributing columns.
If both columns contain variable-length character strings, RESULT contains a variable-length
character string whose length is equal to the greater of the two contributing columns.
If both columns are of exact numeric data types, RESULT contains an exact numeric value
whose precision and scale are equal to the greater of the two contributing columns.
If both columns are of approximate numeric data types, RESULT contains an approximate
numeric value whose precision is equal to the greater of the two contributing columns.
If both columns are of datetime data type (DATE, TIME, or TIMESTAMP), the corresponding
column in RESULT has the same data type.
If both columns are INTERVAL data type and both columns are year-month or day-time,
RESULT contains an INTERVAL value whose range of fields is the most significant start
field to the least significant end field of the INTERVAL fields in the contributing columns.
154
SQL Statements

Advertisement

Table of Contents
loading

Table of Contents