db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpendle...@apache.org
Subject svn commit: r817266 - /db/derby/docs/trunk/src/ref/rrefsqlj13658.dita
Date Mon, 21 Sep 2009 14:21:41 GMT
Author: bpendleton
Date: Mon Sep 21 14:21:40 2009
New Revision: 817266

URL: http://svn.apache.org/viewvc?rev=817266&view=rev
Log:
DERBY-4382: Update ref guide doc for ORDER BY null ordering (NULLS FIRST/LAST)

This change updates the ORDER BY page in the reference guide to reflect the
ability to specify the ordering of null values (NULLS FIRST or NULLS LAST).

The null ordering functionality was added in DERBY-2887.


Modified:
    db/derby/docs/trunk/src/ref/rrefsqlj13658.dita

Modified: db/derby/docs/trunk/src/ref/rrefsqlj13658.dita
URL: http://svn.apache.org/viewvc/db/derby/docs/trunk/src/ref/rrefsqlj13658.dita?rev=817266&r1=817265&r2=817266&view=diff
==============================================================================
--- db/derby/docs/trunk/src/ref/rrefsqlj13658.dita (original)
+++ db/derby/docs/trunk/src/ref/rrefsqlj13658.dita Mon Sep 21 14:21:40 2009
@@ -35,8 +35,11 @@
 <refsyn><title>Syntax</title><codeblock><b>ORDER BY { <i><xref
href="rrefcolumnname.dita#rrefcolumnname"></xref></i> | <i>ColumnPosition</i>
| <i
 >Expression</i> }
     [ ASC | DESC ]
+    [ NULLS FIRST | NULLS LAST ]
     [ , <i><xref href="rrefcolumnname.dita#rrefcolumnname"></xref></i>
| <i>ColumnPosition</i> | <i>Expression</i> 
-        [ ASC | DESC ] ] * </b></codeblock><dl><dlentry>
+    [ ASC | DESC ]
+    [ NULLS FIRST | NULLS LAST ]
+    ] * </b></codeblock><dl><dlentry>
 <dt>column-Name</dt>
 <dd>Refers to the names visible from the <varname>SelectItems</varname>
in
 the underlying query of the <xref href="rrefsqlj41360.dita#rrefsqlj41360"></xref>.
@@ -61,14 +64,34 @@
 </dlentry><dlentry>
 <dt>DESC</dt>
 <dd>Specifies that the results should be returned in descending order.</dd>
-</dlentry></dl> </refsyn>
+</dlentry>
+<dlentry>
+<dt>NULLS FIRST</dt>
+<dd>Specifies that NULL values should be returned before non-NULL values.</dd>
+</dlentry>
+<dlentry>
+<dt>NULLS LAST</dt>
+<dd>Specifies that NULL values should be returned after non-NULL values.</dd>
+</dlentry>
+</dl>
+</refsyn>
 <section><title>Notes</title><ul>
 <li>If SELECT DISTINCT is specified or if the SELECT statement contains a
 GROUP BY clause, the ORDER BY columns must be in the SELECT list. </li>
 <li>An ORDER BY clause prevents a SELECT statement from being an updatable
 cursor. For more information, see <xref href="rrefsqlj41360.dita#rrefsqlj41360/sqlj15384"></xref>.
-For example, if an INTEGER column contains integers, NULL is considered greater
-than 1 for purposes of sorting. In other words, NULL values are sorted high.</li>
+</li>
+<li>If the null ordering is not specified then the handling of the null
+    values is:
+    <ul>
+        <li>NULLS LAST if the sort is ASC</li>
+        <li>NULLS FIRST if the sort is DESC</li>
+    </ul>
+</li>
+<li>If neither ascending nor descending order is specified, and the null
+    ordering is also not specified, then both defaults are used and thus
+    the order will be ascending with NULLS LAST.
+</li>
 </ul></section>
 <example><title>Example using a correlation name</title><p>You can
sort the
 result set by a correlation name, if the correlation name is specified in
@@ -86,5 +109,13 @@
 set by invoking a function, for example:<codeblock>SELECT i, len FROM measures 
    ORDER BY sin(i) 
 </codeblock></p></example>
+<example>
+    <title>Example specifying null ordering</title>
+    <p>
+        You can specify the position of NULL values using
+        the null ordering specification:
+        <codeblock>SELECT * FROM t1 ORDER BY c1 DESC NULLS LAST</codeblock>
+    </p>
+</example>
 </refbody>
 </reference>



Mime
View raw message