- One column or a list of columns to sort by
- Each column can be prefixed with:
- When using prefixes, even a single column needs to be in a list or parentheses. (Otherwise,
sort -foo
is parsed as a subtraction between sort
and foo
.)
from employees
sort age
SELECT
*
FROM
employees
ORDER BY
age
from employees
from employees
sort [age, -tenure, +salary]
SELECT
*
FROM
employees
age,
tenure DESC,
salary
from employees
sort [s"substr({first_name}, 2, 5)"]
sort tenure
derive name = f"{first_name} {last_name}"
SELECT
*,
CONCAT(first_name, ' ', last_name) AS name
FROM
employees
ORDER BY
tenure
- This is an implementation detail of the DB. If there are instances where this doesn’t hold, please open an issue, and we’ll consider how to manage it.
- Some transforms which change the existence of rows, such as
join
or group
, won’t persist ordering; for example:
from employees