mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-09 07:52:19 +00:00
101 lines
1.6 KiB
Plaintext
101 lines
1.6 KiB
Plaintext
1
|
|
-- { echoOn }
|
|
|
|
SELECT
|
|
nw,
|
|
sum(WR) AS R,
|
|
sumIf(WR, uniq_rows = 1) AS UNR
|
|
FROM
|
|
(
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
GROUP BY ac, nw
|
|
)
|
|
GROUP BY nw
|
|
ORDER BY nw ASC, R DESC
|
|
LIMIT 10;
|
|
0 2 0
|
|
1 2 0
|
|
2 2 0
|
|
SELECT
|
|
nw,
|
|
sum(WR) AS R,
|
|
sumIf(WR, uniq_rows = 1) AS UNR
|
|
FROM
|
|
(
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
GROUP BY ac, nw
|
|
)
|
|
GROUP BY nw
|
|
ORDER BY nw ASC, R DESC
|
|
LIMIT 10
|
|
SETTINGS max_threads = 1;
|
|
0 2 0
|
|
1 2 0
|
|
2 2 0
|
|
SELECT
|
|
nw,
|
|
sum(WR) AS R,
|
|
sumIf(WR, uniq_rows = 1) AS UNR
|
|
FROM
|
|
(
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
WHERE (ac % 4) = 0
|
|
GROUP BY
|
|
ac,
|
|
nw
|
|
UNION ALL
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
WHERE (ac % 4) = 1
|
|
GROUP BY
|
|
ac,
|
|
nw
|
|
UNION ALL
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
WHERE (ac % 4) = 2
|
|
GROUP BY
|
|
ac,
|
|
nw
|
|
UNION ALL
|
|
SELECT
|
|
uniq(nw) OVER (PARTITION BY ac) AS uniq_rows,
|
|
AVG(wg) AS WR,
|
|
ac,
|
|
nw
|
|
FROM window_funtion_threading
|
|
WHERE (ac % 4) = 3
|
|
GROUP BY
|
|
ac,
|
|
nw
|
|
)
|
|
GROUP BY nw
|
|
ORDER BY nw ASC, R DESC
|
|
LIMIT 10;
|
|
0 2 0
|
|
1 2 0
|
|
2 2 0
|