Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
36
Добавлен:
18.03.2015
Размер:
608.7 Кб
Скачать

SQL Language Enhancements

Grouping by degree (ordinal number)

Using the degree number of the output column in the GROUP BY clause 'copies' the expression from the select list (as does the ORDER BY clause). This means that, when a degree number refers to a subquery, the subquery is executed at least twice.

(1.5) ORDER BY clause can specify expressions and nulls placement

Nickolay Samofatov

Order by expression

The ORDER BY clause lets you specify any valid expressions to sort query results. If the expression consists of a single number, it is interpreted as column (degree) number, as previously.

Nulls placement

The ordering of nulls in the result set can be controlled using a nulls placement clause.

Results can be sorted so that nulls are placed either above (NULLS FIRST) or below (NULLS LAST) the sorted non-nulls.

Behaviour when nulls placement is unspecified is NULLS LAST.

Syntax Pattern

SELECT ... FROM .... [ORDER BY order_list]....

;

order_list : order_item [, order_list];

order_item : <expression> [order_direction] [nulls_placement] order_direction : ASC | DESC;

nulls_placement : NULLS FIRST | NULLS LAST;

Restrictions

If NULLS FIRST is specified, no index will be used for sorting.

The results of a sort based on values returned from a UDF or a stored procedure will be unpredictable if the values returned cannot be used to determine a logical sorting sequence.

The number of procedure invocations from specifying a sort based on a UDF or stored procedure will be unpredictable, regardless of whether the ordering is specified by the expression itself or by an ordinal number representing an expression in the column-list specification.

An ordering clause for sorting the output of a union query may use only ordinal (degree) numbers to refer to the ordering columns.

Examples

36

Соседние файлы в папке doc