# ORDER BY keyword

> **For AI agents:** the complete documentation index is at [llms.txt](https://questdb.com/docs/llms.txt). Every page is available as markdown by appending `.md` to its URL, or by sending an `Accept: text/markdown` request header.

ORDER BY SQL keyword reference documentation.

Sort the results of a query in ascending or descending order.

## Syntax

```questdb-sql
SELECT ...
ORDER BY columnName [ASC | DESC] [, columnName [ASC | DESC] ...];
```

Default order is `ASC`. You can omit to order in ascending order.

## Notes

Ordering data requires holding it in RAM. For large operations, we suggest you
check you have sufficient memory to perform the operation.

## Examples

```questdb-sql title="Omitting ASC will default to ascending order" demo
SELECT * FROM trades
WHERE timestamp IN '$now-1m..$now'
ORDER BY symbol;
```

```questdb-sql title="Ordering in descending order" demo
SELECT * FROM trades
WHERE timestamp IN '$now-1m..$now'
ORDER BY symbol DESC;
```

```questdb-sql title="Multi-level ordering" demo
SELECT * FROM trades
WHERE timestamp IN '$now-1m..$now'
ORDER BY symbol, side DESC;
```
