ClickHouse/tests/queries/0_stateless/01866_aggregate_function_range_sum.sql
2021-05-19 10:24:53 +00:00

22 lines
360 B
SQL

DROP TABLE IF EXISTS range;
CREATE TABLE range
(
`id` String,
`start` UInt64,
`end` UInt64
)
ENGINE = MergeTree
ORDER BY start;
INSERT INTO range VALUES ('a', 1, 3), ('a', 2, 4), ('a', 5, 6), ('a', 5, 7), ('b', 10, 12), ('b', 13, 19), ('b', 14, 16);
SELECT
id,
rangeSum(start, end)
FROM range
GROUP BY id
ORDER BY id;
DROP TABLE range;