mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-06 07:32:27 +00:00
22 lines
360 B
SQL
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;
|