# percentile()

`percentile(n, col)` returns the `n`-th percentile value of the provided column in the input datastream. A value at the `n`-th percentile means that `n`% of the values in the input datastream are below that value.

`n` must be a numeric value between 0 and 100. Floating point numbers are accepted.

If the provided column does not have numeric values or does not exist, `percentile` will return `null`; otherwise, `percentile` will always return a numeric value that was part of the input datastream.

## Technical Notes

* If there are at most 1000 values in the input stream, `percentile` uses the [nearest rank algorithm ](https://en.wikipedia.org/wiki/Percentile#The_nearest-rank_method)to return the exact value.
* If there are more than 1000 values in the input stream, `percentile` uses the [Karnin, Lang, and Liberty (KLL) algorithm ](https://arxiv.org/pdf/1603.05346.pdf)to return an approximation. The approximation is generally within 1% rank error, e.g. the value returned for the 90th percentile will usually be between the 89th and 91st percentile.

## Returns

A table with one row and one column, called `@q.value`.

## Examples

<pre class="language-python"><code class="lang-python"><strong># Return the median (value at the 50th percentile) of `elapsed_ms` column
</strong><strong>* | percentile(50, elapsed_ms)
</strong>
# Return the value at the 99.9th percentile of `elapsed_ms` column.
* | percentile(99.9, elapsed_ms)
</code></pre>
