2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
k,
|
|
|
|
v,
|
|
|
|
d,
|
|
|
|
i
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
t.1 AS k,
|
|
|
|
t.2 AS v,
|
|
|
|
runningDifference(v) AS d,
|
|
|
|
runningDifference(cityHash64(t.1)) AS i
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT arrayJoin([(\'a\', 1), (\'a\', 2), (\'a\', 3), (\'b\', 11), (\'b\', 13), (\'b\', 15)]) AS t
|
|
|
|
)
|
|
|
|
)
|
|
|
|
WHERE i = 0
|
2020-01-06 03:55:07 +00:00
|
|
|
a 1 0 0
|
|
|
|
a 2 1 0
|
|
|
|
a 3 1 0
|
|
|
|
b 13 2 0
|
|
|
|
b 15 2 0
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
co,
|
|
|
|
co2,
|
|
|
|
co3,
|
|
|
|
num
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
co,
|
|
|
|
co2,
|
|
|
|
co3,
|
|
|
|
count() AS num
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
1 AS co,
|
|
|
|
2 AS co2,
|
|
|
|
3 AS co3
|
|
|
|
)
|
2020-09-08 20:05:47 +00:00
|
|
|
GROUP BY
|
2020-06-22 14:37:42 +00:00
|
|
|
co,
|
|
|
|
co2,
|
|
|
|
co3
|
|
|
|
WITH CUBE
|
|
|
|
HAVING (co2 != 2) AND (co != 0)
|
|
|
|
)
|
|
|
|
WHERE (co != 0) AND (co2 != 2)
|
2020-01-06 03:55:07 +00:00
|
|
|
1 0 3 1
|
|
|
|
1 0 0 1
|
2020-06-22 14:37:42 +00:00
|
|
|
SELECT alias AS name
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT name AS alias
|
|
|
|
FROM system.settings
|
|
|
|
WHERE alias = \'enable_optimize_predicate_expression\'
|
|
|
|
)
|
2021-05-15 09:11:13 +00:00
|
|
|
ANY INNER JOIN
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT name
|
|
|
|
FROM system.settings
|
|
|
|
) USING (name)
|
|
|
|
WHERE name = \'enable_optimize_predicate_expression\'
|
2020-01-06 03:55:07 +00:00
|
|
|
enable_optimize_predicate_expression
|
|
|
|
1 val11 val21 val31
|
2020-06-22 14:37:42 +00:00
|
|
|
SELECT ccc
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT 1 AS ccc
|
|
|
|
WHERE 0
|
|
|
|
UNION ALL
|
|
|
|
SELECT ccc
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT 2 AS ccc
|
|
|
|
)
|
2021-05-15 09:11:13 +00:00
|
|
|
ANY INNER JOIN
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT 2 AS ccc
|
|
|
|
) USING (ccc)
|
|
|
|
WHERE ccc > 1
|
|
|
|
)
|
|
|
|
WHERE ccc > 1
|
2020-01-06 03:55:07 +00:00
|
|
|
2
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
ts,
|
|
|
|
id,
|
|
|
|
id_b,
|
|
|
|
b.ts,
|
|
|
|
b.id,
|
|
|
|
id_c
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
ts,
|
|
|
|
id,
|
|
|
|
id_b
|
|
|
|
FROM A
|
|
|
|
WHERE ts <= toDateTime(\'1970-01-01 03:00:00\')
|
|
|
|
) AS a
|
|
|
|
ALL LEFT JOIN B AS b ON b.id = id_b
|
|
|
|
WHERE ts <= toDateTime(\'1970-01-01 03:00:00\')
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
ts AS `--a.ts`,
|
|
|
|
id AS `--a.id`,
|
|
|
|
id_b AS `--a.id_b`,
|
|
|
|
b.ts AS `--b.ts`,
|
|
|
|
b.id AS `--b.id`,
|
|
|
|
id_c AS `--b.id_c`
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
ts,
|
|
|
|
id,
|
|
|
|
id_b
|
|
|
|
FROM A
|
|
|
|
WHERE ts <= toDateTime(\'1970-01-01 03:00:00\')
|
|
|
|
) AS a
|
|
|
|
ALL LEFT JOIN B AS b ON `--b.id` = `--a.id_b`
|
|
|
|
WHERE `--a.ts` <= toDateTime(\'1970-01-01 03:00:00\')
|
2020-01-06 04:18:56 +00:00
|
|
|
2 3
|
|
|
|
3 4
|
|
|
|
4 5
|
|
|
|
5 0
|
|
|
|
2 4
|
|
|
|
4 0
|
|
|
|
2 3
|
|
|
|
4 5
|
2020-06-22 14:37:42 +00:00
|
|
|
SELECT dummy
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
|
|
|
SELECT dummy
|
|
|
|
FROM system.one
|
|
|
|
WHERE arrayMap(x -> (x + 1), [dummy]) = [1]
|
|
|
|
)
|
|
|
|
WHERE arrayMap(x -> (x + 1), [dummy]) = [1]
|
2020-01-06 10:33:08 +00:00
|
|
|
0
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
id,
|
|
|
|
value,
|
|
|
|
value_1
|
2021-05-15 09:11:13 +00:00
|
|
|
FROM
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
1 AS id,
|
|
|
|
2 AS value
|
|
|
|
)
|
2021-05-15 09:11:13 +00:00
|
|
|
ALL INNER JOIN
|
2020-06-22 14:37:42 +00:00
|
|
|
(
|
2020-09-08 20:05:47 +00:00
|
|
|
SELECT
|
2020-06-22 14:37:42 +00:00
|
|
|
1 AS id,
|
|
|
|
3 AS value_1
|
|
|
|
) USING (id)
|
|
|
|
WHERE arrayMap(x -> ((x + value) + value_1), [1]) = [6]
|
2020-01-07 03:31:03 +00:00
|
|
|
1 2 3
|
2020-06-22 14:37:42 +00:00
|
|
|
SELECT dummy
|
|
|
|
FROM system.one
|
|
|
|
WHERE (dummy > 0) AND (dummy < 0)
|