ClickHouse/tests/queries/0_stateless/02316_expressions_with_window_functions.reference
2022-06-16 13:40:12 +00:00

255 lines
2.4 KiB
Plaintext

-- { echoOn }
-- SELECT number, sum(number) + 1 OVER (PARTITION BY (number % 10))
-- FROM numbers(100)
-- ORDER BY number; -- { clientError SYNTAX_ERROR }
SELECT number, 1 + sum(number) OVER (PARTITION BY number % 10)
FROM numbers(100)
ORDER BY number;
0 451
1 461
2 471
3 481
4 491
5 501
6 511
7 521
8 531
9 541
10 451
11 461
12 471
13 481
14 491
15 501
16 511
17 521
18 531
19 541
20 451
21 461
22 471
23 481
24 491
25 501
26 511
27 521
28 531
29 541
30 451
31 461
32 471
33 481
34 491
35 501
36 511
37 521
38 531
39 541
40 451
41 461
42 471
43 481
44 491
45 501
46 511
47 521
48 531
49 541
50 451
51 461
52 471
53 481
54 491
55 501
56 511
57 521
58 531
59 541
60 451
61 461
62 471
63 481
64 491
65 501
66 511
67 521
68 531
69 541
70 451
71 461
72 471
73 481
74 491
75 501
76 511
77 521
78 531
79 541
80 451
81 461
82 471
83 481
84 491
85 501
86 511
87 521
88 531
89 541
90 451
91 461
92 471
93 481
94 491
95 501
96 511
97 521
98 531
99 541
SELECT sum(number) + 1 AS x
FROM numbers(100)
GROUP BY number % 10
ORDER BY x;
451
461
471
481
491
501
511
521
531
541
SELECT
number,
sum(number) OVER (PARTITION BY number % 10) / count() OVER (PARTITION BY number % 10),
avg(number) OVER (PARTITION BY number % 10)
FROM numbers(100)
ORDER BY number ASC;
0 45 45
1 46 46
2 47 47
3 48 48
4 49 49
5 50 50
6 51 51
7 52 52
8 53 53
9 54 54
10 45 45
11 46 46
12 47 47
13 48 48
14 49 49
15 50 50
16 51 51
17 52 52
18 53 53
19 54 54
20 45 45
21 46 46
22 47 47
23 48 48
24 49 49
25 50 50
26 51 51
27 52 52
28 53 53
29 54 54
30 45 45
31 46 46
32 47 47
33 48 48
34 49 49
35 50 50
36 51 51
37 52 52
38 53 53
39 54 54
40 45 45
41 46 46
42 47 47
43 48 48
44 49 49
45 50 50
46 51 51
47 52 52
48 53 53
49 54 54
50 45 45
51 46 46
52 47 47
53 48 48
54 49 49
55 50 50
56 51 51
57 52 52
58 53 53
59 54 54
60 45 45
61 46 46
62 47 47
63 48 48
64 49 49
65 50 50
66 51 51
67 52 52
68 53 53
69 54 54
70 45 45
71 46 46
72 47 47
73 48 48
74 49 49
75 50 50
76 51 51
77 52 52
78 53 53
79 54 54
80 45 45
81 46 46
82 47 47
83 48 48
84 49 49
85 50 50
86 51 51
87 52 52
88 53 53
89 54 54
90 45 45
91 46 46
92 47 47
93 48 48
94 49 49
95 50 50
96 51 51
97 52 52
98 53 53
99 54 54
SELECT sum(number) / sum(sum(number)) OVER (PARTITION BY (number % 10))
FROM numbers(10000)
GROUP BY number % 10;
1
1
1
1
1
1
1
1
1
1
SELECT 1 + sum(number) / sum(sum(number)) OVER (PARTITION BY (number % 10))
FROM numbers(10000)
GROUP BY number % 10;
2
2
2
2
2
2
2
2
2
2