Link Search Menu Expand Document

MEDIAN

Calculates an approximate median for a given column.

Syntax

MEDIAN(<col>)
Parameter Description
<col> The column used to calculate the median value. This column can consist of numeric data types or DATE and DATETIME.

Example

For this example, we’ll create a new table num_test as shown below:

CREATE DIMENSION TABLE IF NOT EXISTS num_test
	(
		num int
	);

INSERT INTO
	num_test
VALUES
	(1),
	(7),
	(12),
	(30),
	(59),
	(76),
	(100);

MEDIAN returns the approximate middle value between the lower and higher halves of the values.

SELECT
	MEDIAN(num)
FROM
	number_test

Returns: 30