---
updatedAt: 2026-04-13T21:50:14.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# nullslast

```
nullslast(value: storable or ordering) -> ordering
```

Specify the ordering as nulls last when processing data.

This is used by ordered windowing functions (like [lag](function-lag) and [last](function-last)), ordered aggregation functions (like [array\_agg](function-array_agg)) and the [sort](verb-sort) verb.

# Domain

This is a scalar function (calculates a single output value for a single input row).

# Categories

* [Misc](function#misc-functions)

# Examples

<OpalCodeBlock code={
`sort nullslast(desc(foo))
`}/>

Sort the dataset in with nulls appearing last in descending order by values in column `foo`.

<OpalCodeBlock code={
`statsby list:array_agg(username, nullslast(timestamp)), group_by(hostname)
`}/>

Lists all users for each host, in order of ascending timestamp (default ordering) with nulls appearing last within each host assuming you have a table with columns `timestamp`, `hostname` and `username`.