maxIntersections
Aggregate function that calculates the maximum number of times that a group of intervals intersects each other (if all the intervals intersect at least once).
This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See SQL interface scope.
Aggregate function that calculates the maximum number of times that a group of intervals intersects each other (if all the intervals intersect at least once).
Syntax
maxIntersections(start_column, end_column)Arguments
start_column— A numeric column that represents the start of each interval. Ifstart_columnisNULLor 0 then the interval will be skipped.(U)Int*orFloat*end_column— A numeric column that represents the end of each interval. Ifend_columnisNULLor 0 then the interval will be skipped.(U)Int*orFloat*
Returned value
Returns the maximum number of intersected intervals. UInt64
Examples
Calculating maximum intersections
CREATE TABLE my_events (
start UInt32,
end UInt32
)
ENGINE = MergeTree
ORDER BY tuple();
INSERT INTO my_events VALUES
(1, 3),
(1, 6),
(2, 5),
(3, 7);
SELECT maxIntersections(start, end) FROM my_events;┌─maxIntersections(start, end)─┐
│ 3 │
└──────────────────────────────┘Introduced in version 20.1.0.