2024-04-02 16:06:02 +00:00
|
|
|
-- https://github.com/ClickHouse/ClickHouse/issues/48308
|
2024-07-12 12:49:26 +00:00
|
|
|
SET enable_analyzer=1;
|
2024-04-02 16:06:02 +00:00
|
|
|
DROP TABLE IF EXISTS 03038_table;
|
|
|
|
|
|
|
|
CREATE TABLE 03038_table
|
|
|
|
(
|
|
|
|
`time` DateTime
|
|
|
|
)
|
|
|
|
ENGINE = MergeTree
|
|
|
|
ORDER BY time;
|
|
|
|
|
|
|
|
SELECT *
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
toUInt64(time) AS time,
|
|
|
|
toHour(03038_table.time)
|
|
|
|
FROM 03038_table
|
|
|
|
)
|
|
|
|
ORDER BY time ASC;
|
|
|
|
|
|
|
|
WITH subquery AS (
|
|
|
|
SELECT
|
|
|
|
toUInt64(time) AS time,
|
|
|
|
toHour(03038_table.time)
|
|
|
|
FROM 03038_table
|
|
|
|
)
|
|
|
|
SELECT *
|
|
|
|
FROM subquery
|
|
|
|
ORDER BY subquery.time ASC;
|
|
|
|
|
|
|
|
SELECT *
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT
|
|
|
|
toUInt64(time) AS time,
|
|
|
|
toHour(03038_table.time) AS hour
|
|
|
|
FROM 03038_table
|
|
|
|
)
|
|
|
|
ORDER BY time ASC, hour;
|
|
|
|
|
|
|
|
DROP TABLE IF EXISTS 03038_table;
|