You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: yql/essentials/docs/en/builtins/aggregation.md
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Counting the number of rows in the table (if `*` or constant is specified as the
6
6
7
7
Like other aggregate functions, it can be combined with [GROUP BY](../syntax/group_by.md) to get statistics on the parts of the table that correspond to the values in the columns being grouped. Use the modifier [DISTINCT](../syntax/group_by.md#distinct) to count distinct values.
8
8
9
-
### Examples
9
+
####Examples
10
10
11
11
```yql
12
12
SELECT COUNT(*) FROM my_table;
@@ -26,7 +26,7 @@ Minimum or maximum value.
26
26
27
27
As an argument, you may use an arbitrary computable expression with a numeric result.
28
28
29
-
### Examples
29
+
####Examples
30
30
31
31
```yql
32
32
SELECT MIN(value), MAX(value) FROM my_table;
@@ -52,7 +52,7 @@ As an argument, you may use an arbitrary computable expression with a numeric re
52
52
53
53
Integer values and time intervals are automatically converted to Double.
54
54
55
-
### Examples
55
+
####Examples
56
56
57
57
```yql
58
58
SELECT AVG(value) FROM my_table;
@@ -66,7 +66,7 @@ The value `NULL` is equated to `false` (if the argument type is `Bool?`).
66
66
67
67
The function *does not* do the implicit type casting to Boolean for strings and numbers.
68
68
69
-
### Examples
69
+
####Examples
70
70
71
71
```yql
72
72
SELECT
@@ -85,7 +85,7 @@ Sum or arithmetic average, but only for the rows that satisfy the condition pass
85
85
86
86
Therefore, `SUM_IF(value, condition)` is a slightly shorter notation for `SUM(IF(condition, value))`, same for `AVG`. The argument's data type expansion is similar to the same-name functions without a suffix.
87
87
88
-
### Examples
88
+
####Examples
89
89
90
90
```yql
91
91
SELECT
@@ -112,7 +112,7 @@ Get the value for an expression specified as an argument, for one of the table r
112
112
113
113
Because of no guarantee, `SOME` is computationally cheaper than [MIN / MAX](#min-max) often used in similar situations.
114
114
115
-
### Examples
115
+
####Examples
116
116
117
117
```yql
118
118
SELECT
@@ -141,7 +141,7 @@ By selecting accuracy, you can trade added resource and RAM consumption for decr
141
141
142
142
All the three functions are aliases at the moment, but `CountDistinctEstimate` may start using a different algorithm in the future.
143
143
144
-
### Examples
144
+
####Examples
145
145
146
146
```yql
147
147
SELECT
@@ -169,7 +169,7 @@ To return a list of multiple values from one line, **DO NOT** use the `AGGREGATE
169
169
170
170
For example, you can combine it with `DISTINCT` and the function [String::JoinFromList](../udf/list/string.md) (it's an equivalent of `','.join(list)` in Python) to output to a string all the values found in the column after [GROUP BY](../syntax/group_by.md).
171
171
172
-
### Examples
172
+
####Examples
173
173
174
174
```yql
175
175
SELECT
@@ -219,7 +219,7 @@ If the second argument is always `NULL`, the aggregation result is `NULL`.
219
219
220
220
When you use [aggregation factories](basic.md#aggregationfactory), a `Tuple` containing a value and a key is passed as the first [AGGREGATE_BY](#aggregate-by) argument.
221
221
222
-
### Examples
222
+
####Examples
223
223
224
224
```yql
225
225
SELECT
@@ -244,7 +244,7 @@ FROM my_table;
244
244
245
245
Return a list of the maximum/minimum values of an expression. The first argument is an expression, the second argument limits the number of items.
246
246
247
-
### Examples
247
+
####Examples
248
248
249
249
```yql
250
250
SELECT
@@ -269,7 +269,7 @@ Return a list of values of the first argument for the rows containing the maximu
269
269
270
270
When you use [aggregation factories](basic.md#aggregationfactory), a `Tuple` containing a value and a key is passed as the first [AGGREGATE_BY](#aggregate-by) argument. In this case, the limit for the number of items is passed by the second argument at factory creation.
271
271
272
-
### Examples
272
+
####Examples
273
273
274
274
```yql
275
275
SELECT
@@ -304,7 +304,7 @@ Optional arguments:
304
304
1. For `TOPFREQ`, the desired number of items in the result. `MODE` is an alias to `TOPFREQ` with this argument set to 1. For `TOPFREQ`, this argument is also 1 by default.
305
305
2. The number of items in the buffer used: lets you trade memory consumption for accuracy. Default: 100.
306
306
307
-
### Examples
307
+
####Examples
308
308
309
309
```yql
310
310
SELECT
@@ -328,7 +328,7 @@ Several abbreviated aliases are also defined, for example, `VARPOP` or `STDDEVSA
328
328
329
329
If all the values passed are `NULL`, it returns `NULL`.
330
330
331
-
### Examples
331
+
####Examples
332
332
333
333
```yql
334
334
SELECT
@@ -349,7 +349,7 @@ Unlike most other aggregate functions, they don't skip `NULL`, but accept it as
349
349
350
350
When you use [aggregation factories](basic.md#aggregationfactory), a `Tuple` containing two values is passed as the first [AGGREGATE_BY](#aggregate-by) argument.
351
351
352
-
### Examples
352
+
####Examples
353
353
354
354
```yql
355
355
SELECT
@@ -458,7 +458,7 @@ While FastGreedyShrink is used most of the time, SlowShrink is mostly used for h
458
458
459
459
When you use [aggregation factories](basic.md#aggregationfactory), a `Tuple` containing a value and a weight is passed as the first [AGGREGATE_BY](#aggregate-by) argument.
460
460
461
-
### Examples
461
+
#### Examples
462
462
463
463
```yql
464
464
SELECT
@@ -498,7 +498,7 @@ The format of the result is totally similar to [adaptive histograms](#histogram)
498
498
499
499
If the spread of input values is uncontrollably large, we recommend that you specify the minimum and maximum values to prevent potential failures due to high memory consumption.
500
500
501
-
### Examples
501
+
####Examples
502
502
503
503
```yql
504
504
SELECT
@@ -510,7 +510,7 @@ FROM my_table;
510
510
511
511
## BOOL_AND, BOOL_OR and BOOL_XOR {#bool-and-or-xor}
512
512
513
-
### Signature
513
+
####Signature
514
514
515
515
```yql
516
516
BOOL_AND(Bool?)->Bool?
@@ -543,7 +543,7 @@ Examples of such behavior can be found below.
543
543
544
544
To skip `NULL` values during aggregation, use the `MIN`/`MAX` or `BIT_AND`/`BIT_OR`/`BIT_XOR` functions.
545
545
546
-
### Examples
546
+
####Examples
547
547
548
548
```yql
549
549
$data = [
@@ -572,7 +572,7 @@ FROM AS_TABLE($data);
572
572
573
573
Apply the relevant bitwise operation to all values of a numeric column or expression.
574
574
575
-
### Examples
575
+
####Examples
576
576
577
577
```yql
578
578
SELECT
@@ -594,7 +594,7 @@ Applying an [aggregation factory](basic.md#aggregationfactory) to all values of
0 commit comments