$ clickhouse-client -q "SELECT
t,
v1
FROM (
WITH
toDateTime('2020-01-01 12:10:00') AS start_datetime
SELECT
addMinutes(start_datetime, number) AS t,
nullIf(toMinute(t), 0) AS v1
FROM system.numbers
WHERE number NOT IN (3, 4)
LIMIT 5
) ORDER BY t WITH FILL STEP 60"
2020-01-01 12:10:00 10
2020-01-01 12:11:00 11
2020-01-01 12:12:00 12
2020-01-01 12:13:00 \N
2020-01-01 12:14:00 \N
2020-01-01 12:15:00 15
2020-01-01 12:16:00 16$ clickhouse-client -q "SELECT
t,
coalesce(v1, neighbor(v1, -1)) AS v1
FROM (
SELECT
t,
v1
FROM (
WITH
toDateTime('2020-01-01 12:10:00') AS start_datetime
SELECT
addMinutes(start_datetime, number) AS t,
nullIf(toMinute(t), 0) AS v1
FROM system.numbers
WHERE number NOT IN (3, 4)
LIMIT 5
) ORDER BY t WITH FILL STEP 60
)"
2020-01-01 12:10:00 10
2020-01-01 12:11:00 11
2020-01-01 12:12:00 12
2020-01-01 12:13:00 12
2020-01-01 12:14:00 \N
2020-01-01 12:15:00 15
2020-01-01 12:16:00 16--
You received this message because you are subscribed to the Google Groups "ClickHouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clickhouse+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clickhouse/678a1c3e-00f7-452c-bfbc-2df28b0b2fe1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to click...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clickhouse/678a1c3e-00f7-452c-bfbc-2df28b0b2fe1%40googlegroups.com.
--Артем
SELECT *
FROM test_data
┌───────────────────t─┬───v1─┬───v2─┐
│ 2020-01-01 12:10:00 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │
│ 2020-01-01 12:11:00 │ 56 │ 34 │
│ 2020-01-01 12:12:00 │ 57 │ 35 │
│ 2020-01-01 12:13:00 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │
│ 2020-01-01 12:14:00 │ ᴺᵁᴸᴸ │ ᴺᵁᴸᴸ │
│ 2020-01-01 12:15:00 │ ᴺᵁᴸᴸ │ 38 │
│ 2020-01-01 12:16:00 │ 61 │ ᴺᵁᴸᴸ │
│ 2020-01-01 12:17:00 │ 62 │ 40 │
│ 2020-01-01 12:18:00 │ 63 │ 41 │
│ 2020-01-01 12:19:00 │ 64 │ ᴺᵁᴸᴸ │
│ 2020-01-01 12:20:00 │ ᴺᵁᴸᴸ │ 43 │
│ 2020-01-01 12:21:00 │ 66 │ 44 │
└─────────────────────┴──────┴──────┘
SELECT
t,
runningAccumulate(v1State) AS v1,
runningAccumulate(v2State) AS v2
FROM
(
SELECT
t,
anyLastState(v1) AS v1State,
anyLastState(v2) AS v2State
FROM test_data
GROUP BY t
ORDER BY t ASC
)
┌───────────────────t─┬─v1─┬─v2─┐
│ 2020-01-01 12:10:00 │ 0 │ 0 │
│ 2020-01-01 12:11:00 │ 56 │ 34 │
│ 2020-01-01 12:12:00 │ 57 │ 35 │
│ 2020-01-01 12:13:00 │ 57 │ 35 │
│ 2020-01-01 12:14:00 │ 57 │ 35 │
│ 2020-01-01 12:15:00 │ 57 │ 38 │
│ 2020-01-01 12:16:00 │ 61 │ 38 │
│ 2020-01-01 12:17:00 │ 62 │ 40 │
│ 2020-01-01 12:18:00 │ 63 │ 41 │
│ 2020-01-01 12:19:00 │ 64 │ 41 │
│ 2020-01-01 12:20:00 │ 64 │ 43 │
│ 2020-01-01 12:21:00 │ 66 │ 44 │
└─────────────────────┴────┴────┘