PERCENTILE_CONT Function

The percentile function in SQL calculates the value at a given percentile (for example, 25th, 50th/median, or 90th) across a set of rows, effectively telling you “what value cuts off the bottom X% of the data.”

Sample Syntax

| id | name  | salary |
|----|-------|--------|
| 1  | Alice | 5000   |
| 2  | Bob   | 6000   |
| 3  | Carol | 7000   |
| 4  | Dave  | 8000   |
| 5  | Eve   | 9000   |
SELECT
  PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary) AS median_salary
FROM employees;
Powered by Forestry.md