Elaborate on which variables are seen by ORDER BY

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D480
This commit is contained in:
Teon Banek 2017-06-16 09:37:47 +02:00
parent 7d00c4eac0
commit 21277019e2

View File

@ -153,6 +153,15 @@ Example. Ordering by first name descending and last name ascending.
MATCH (n :Person) RETURN n ORDER BY n.name DESC, n.lastName
Note that `ORDER BY` sees only the variable names as carried over by `RETURN`.
This means that the following will result in an error.
MATCH (n :Person) RETURN old AS new ORDER BY old.name
Instead, the `new` variable must be used:
MATCH (n: Person) RETURN old AS new ORDER BY new.name
The `ORDER BY` sub-clause may come in handy with `SKIP` and/or `LIMIT`
sub-clauses. For example, to get the oldest person you can use the following.