~drizzle-trunk/drizzle/development

1994.4.16 by Marisa Plumb
new function and clause files, some placeholders for right now
1
Order By
1994.4.19 by Marisa Plumb
new orderby doc
2
========
3
4
The ORDER BY keyword is used to sort the result-set by column; by default, it sorts the records in ascending order.
5
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
6
SQL ORDER BY Syntax:
7
8
.. code-block:: mysql
1994.4.19 by Marisa Plumb
new orderby doc
9
10
	SELECT column_name(s)
11
	FROM table_name
12
	ORDER BY column_name(s) ASC|DESC;
13
14
**ORDER BY Example**
15
16
The "Persons" table:
17
18
+---------+------------+----------+----------+--------+
19
|Id 	  |LastName    |FirstName |Address   |  City  |
20
+=========+============+==========+==========+========+
21
| 1 	  | Larson     | Sue      |3 Cherry  | Chicago|
22
+---------+------------+----------+----------+--------+
23
| 2 	  | Roberts    | Teri 	  |21 Brown  | Chicago|
24
+---------+------------+----------+----------+--------+
25
| 3 	  | Peterson   | Kari 	  |30 Mell   | Reno   |
26
+---------+------------+----------+----------+--------+
27
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
28
To select all the persons from the table above, and also sort them by their last name, use the following SELECT statement:
29
30
.. code-block:: mysql
1994.4.19 by Marisa Plumb
new orderby doc
31
32
	SELECT * FROM Persons
33
	ORDER BY LastName;
34
35
The result-set will look like this:
36
37
+---------+------------+----------+----------+--------+
38
|Id 	  |LastName    |FirstName |Address   |  City  |
39
+=========+============+==========+==========+========+
40
| 1 	  | Larson     | Sue      |3 Cherry  | Chicago|
41
+---------+------------+----------+----------+--------+
42
| 3 	  | Peterson   | Kari 	  |30 Mell   | Reno   |
43
+---------+------------+----------+----------+--------+
44
| 2 	  | Roberts    | Teri 	  |21 Brown  | Chicago|
45
+---------+------------+----------+----------+--------+
46
2165.2.5 by Andrew Hutchings
Make fixes to temporal docs
47
ORDER BY DESC can be used to reverse the order of the result set.
48
49
.. code-block:: mysql
1994.4.19 by Marisa Plumb
new orderby doc
50
51
	SELECT * FROM Persons
52
	ORDER BY LastName DESC;
1994.5.18 by Stewart Smith
add some FIXMEs to ORDER BY docs about what should be added.
53
2165.2.3 by Andrew Hutchings
Add favicon to docs
54
.. todo::
55
56
   add something about SELECT * without ORDER BY being non-deterministic
57
58
.. todo::
59
60
   add something about how ORDER BY is executed. index scan vs filesort