---
schema_version: "1"
id: 3cd290bc5e92a29d5b157c41702a88c4cef0780dd40f15bf3d22036755f4dc71
title: PERCENTILE_CONT
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/aggregate-func/percentile-cont.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/percentile-cont.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1185267f646408e803b14598090a5f0b665f945bcc6aea88f8108e54387b51a9
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `PERCENTILE_CONT`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Computes a continuous percentile, interpolating between adjacent input values if needed.

## Syntax

```sql
percentile_cont(<fraction>) WITHIN GROUP (ORDER BY <sort_expression>)
```

## Arguments

### Required

- `<fraction>`: A `double precision` value between 0 and 1 specifying the percentile to compute.
- `<sort_expression>`: An expression of `double precision` or `interval` type.

## Returns

Returns the same type as the sort expression. Returns NULL if the fraction is NULL.

## Considerations

- This is an ordered-set aggregate function.
- NULL values in the sorted input are ignored.
- Interpolates between adjacent values when the exact percentile falls between two data points.
- Use `PERCENTILE_DISC` for discrete percentiles without interpolation.

## Examples

### Calculate Median

Find the median (50th percentile).

```sql
SELECT percentile_cont(0.5) WITHIN GROUP (ORDER BY salary) AS median_salary
FROM employees;
```

### Calculate Quartiles

Find the 25th and 75th percentiles.

```sql
SELECT
    percentile_cont(0.25) WITHIN GROUP (ORDER BY score) AS q1,
    percentile_cont(0.5) WITHIN GROUP (ORDER BY score) AS median,
    percentile_cont(0.75) WITHIN GROUP (ORDER BY score) AS q3
FROM test_results;
```

### Percentile by Group

Calculate percentiles for each group.

```sql
SELECT department,
    percentile_cont(0.5) WITHIN GROUP (ORDER BY salary) AS median_salary
FROM employees
GROUP BY department;
```

## Related Documentation

- [PERCENTILE_DISC](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/percentile-disc.md)
- [MODE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/mode.md)
- [Aggregate Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.md)
