Skip to content

Aggregate function.

The QUANTILE_CONT() function computes the interpolated quantile number of a numeric data sequence.

func.quantile_cont(<levels>, <expr>)
func.quantile_cont(0.5, table.sales_amount).alias('median_sales_amount')
| median_sales_amount |
|-----------------------|
| 6000.0 |
QUANTILE_CONT(<levels>)(<expr>)
QUANTILE_CONT(level1, level2, ...)(<expr>)
ArgumentsDescription
<level(s)level(s) of quantile. Each level is constant floating-point number from 0 to 1. We recommend using a level value in the range of [0.01, 0.99]
<expr>Any numerical expression

Float64 or float64 array based on level number.

Create a Table and Insert Sample Data

CREATE TABLE sales_data (
id INT,
sales_person_id INT,
sales_amount FLOAT
);
INSERT INTO sales_data (id, sales_person_id, sales_amount)
VALUES (1, 1, 5000),
(2, 2, 5500),
(3, 3, 6000),
(4, 4, 6500),
(5, 5, 7000);

Query Demo: Calculate 50th Percentile (Median) of Sales Amount using Interpolation

SELECT QUANTILE_CONT(0.5)(sales_amount) AS median_sales_amount
FROM sales_data;

Result

| median_sales_amount |
|-----------------------|
| 6000.0 |