CQL keyword
ORDER BY keyword in CQL (Confluence): fields and examples
ORDER BY sorts the results of a CQL query. Name one field or several, each with asc or desc. It goes at the end of the query, after every filter clause.
Syntax
query ORDER BY field [asc|desc]
query order by field1 desc, field2 asc
Arguments
| Argument | What it does | Optional |
|---|---|---|
field | A field that supports ordering, for example created, lastmodified or title. | yes |
asc / desc | Sort direction. If you leave it out, the field's own default order is used. | no |
Works with
- Operators: it sorts the results of any query. It is not a filter.
- Functions: none.
- Not with: space, label, text, ancestor, parent, macro, fileExtension, pageStatus and subtype (see the pitfalls). Sorting worked on created, lastmodified, title, id, type, creator, contributor, owner, watcher, favourite, mention, content and creator.fullname.
Examples
type = page and space = SD order by lastmodified descPuts the most recently changed pages at the top, for a stale-page review in reverse.
Run on Confluence Cloud on .
type = page and space = SD order by title ascGives an alphabetical page index for a space.
Run on Confluence Cloud on .
type = page and space = SD order by created desc, title ascSorts by creation date, newest first, and uses the title to order pages made at the same time.
Run on Confluence Cloud on .
type = attachment order by created descLists the latest uploaded files first.
Run on Confluence Cloud on .
type = page and space = SD ORDER BY title ASCSame as the lowercase form. The keyword and the direction are not case sensitive.
Run on Confluence Cloud on .
Pitfalls
- The documentation example
creator = "..." order by space, title ascfails.order by spacereturns HTTP 501 "space does not support ordering" (checked on Confluence Cloud, November 2026). Sort by title or date instead. - Several fields fail in different ways.
label,text,ancestor,parentandmacroall give "Could not parse cql", which looks the same as a misspelt field.fileExtension,pageStatusandsubtypegive HTTP 500 "supports ordering but does not implement buildOrder". - ORDER BY needs a query before it. A query that is only
order by title ascfails with "Could not parse cql". Onlyascanddescare accepted;descendingand a trailing comma fail the same way. - ORDER BY does not take a limit. Paging is a parameter of the REST call, not part of the query.