> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# percentile_cont

> Computes the percentile value of expr with linear interpolation.

Computes the percentile value of `expr` with linear interpolation.

## Syntax

```Haskell theme={null}
PERCENTILE_CONT (expr, percentile) 
```

## Parameters

* `expr`: the expression by which to order the values. It must be of numeric data types, DATE, or DATETIME. For example, if you want to find the median score of physics, specify the column that contains the physics scores.

* `percentile`: the percentile of the value you want to find. It is a constant floating-point number from 0 to 1. For example, if you want to find the median value, set this parameter to `0.5`.

## Return value

Returns a value that is at the specified percentile. If no input value lies exactly at the desired percentile, the result is calculated using linear interpolation of the two nearest input values.

The data type is the same as `expr`.

## Usage notes

This function ignores NULLs.

## Examples

Suppose there is a table named `exam` with the following data.

```Plain theme={null}
select * from exam order by Subject;
+-----------+-------+
| Subject   | Score |
+-----------+-------+
| chemistry |    80 |
| chemistry |   100 |
| chemistry |  NULL |
| math      |    60 |
| math      |    70 |
| math      |    85 |
| physics   |    75 |
| physics   |    80 |
| physics   |    85 |
| physics   |    99 |
+-----------+-------+
```

Calculate the median score of each subject while ignoring NULLs.

Query:

```SQL theme={null}
SELECT Subject, PERCENTILE_CONT (Score, 0.5)  FROM exam group by Subject;
```

Result:

```Plain theme={null}
+-----------+-----------------------------+
| Subject   | percentile_cont(Score, 0.5) |
+-----------+-----------------------------+
| chemistry |                          90 |
| math      |                          70 |
| physics   |                        82.5 |
+-----------+-----------------------------+
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.