mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
23 lines
417 B
SQL
23 lines
417 B
SQL
DROP TABLE IF EXISTS tab;
|
|
|
|
CREATE TABLE tab
|
|
(
|
|
`machine_id` UInt64,
|
|
`name` String,
|
|
`timestamp` DateTime
|
|
)
|
|
ENGINE = MergeTree
|
|
PARTITION BY toYYYYMM(timestamp)
|
|
ORDER BY machine_id;
|
|
|
|
insert into tab(machine_id, name, timestamp)
|
|
select 1, 'a_name', '2022-11-24 12:00:00';
|
|
|
|
SELECT
|
|
toStartOfInterval(timestamp, INTERVAL 300 SECOND) AS ts
|
|
FROM tab
|
|
WHERE ts > '2022-11-24 11:19:00'
|
|
GROUP BY ts;
|
|
|
|
DROP TABLE tab;
|