|
| 1 | +====================== |
| 2 | +Statistical Functions |
| 3 | +====================== |
| 4 | + |
| 5 | +.. rubric:: Table of contents |
| 6 | + |
| 7 | +.. contents:: |
| 8 | + :local: |
| 9 | + :depth: 1 |
| 10 | + |
| 11 | + |
| 12 | +MAX |
| 13 | +--- |
| 14 | + |
| 15 | +Description |
| 16 | +>>>>>>>>>>> |
| 17 | + |
| 18 | +Usage: max(x, y, ...) returns the maximum value from all provided arguments. Strings are treated as greater than numbers, so if provided both strings and numbers, it will return the maximum string value (lexicographically ordered) |
| 19 | + |
| 20 | +Note: This function is only available in the eval command context and requires Calcite engine to be enabled. |
| 21 | + |
| 22 | +Argument type: Variable number of INTEGER/LONG/FLOAT/DOUBLE/STRING arguments |
| 23 | + |
| 24 | +Return type: Type of the selected argument |
| 25 | + |
| 26 | +Example:: |
| 27 | + |
| 28 | + os> source=accounts | eval max_val = MAX(age, 30) | fields age, max_val |
| 29 | + fetched rows / total rows = 4/4 |
| 30 | + +-----+---------+ |
| 31 | + | age | max_val | |
| 32 | + |-----+---------| |
| 33 | + | 32 | 32 | |
| 34 | + | 36 | 36 | |
| 35 | + | 28 | 30 | |
| 36 | + | 33 | 33 | |
| 37 | + +-----+---------+ |
| 38 | + |
| 39 | + os> source=accounts | eval result = MAX(firstname, 'John') | fields firstname, result |
| 40 | + fetched rows / total rows = 4/4 |
| 41 | + +-----------+---------+ |
| 42 | + | firstname | result | |
| 43 | + |-----------+---------| |
| 44 | + | Amber | John | |
| 45 | + | Hattie | John | |
| 46 | + | Nanette | Nanette | |
| 47 | + | Dale | John | |
| 48 | + +-----------+---------+ |
| 49 | + |
| 50 | + os> source=accounts | eval result = MAX(age, 35, 'John', firstname) | fields age, firstname, result |
| 51 | + fetched rows / total rows = 4/4 |
| 52 | + +-----+-----------+---------+ |
| 53 | + | age | firstname | result | |
| 54 | + |-----+-----------+---------| |
| 55 | + | 32 | Amber | John | |
| 56 | + | 36 | Hattie | John | |
| 57 | + | 28 | Nanette | Nanette | |
| 58 | + | 33 | Dale | John | |
| 59 | + +-----+-----------+---------+ |
| 60 | + |
| 61 | + |
| 62 | +MIN |
| 63 | +--- |
| 64 | + |
| 65 | +Description |
| 66 | +>>>>>>>>>>> |
| 67 | + |
| 68 | +Usage: min(x, y, ...) returns the minimum value from all provided arguments. Strings are treated as greater than numbers, so if provided both strings and numbers, it will return the minimum numeric value. |
| 69 | + |
| 70 | +Note: This function is only available in the eval command context and requires Calcite engine to be enabled. |
| 71 | + |
| 72 | +Argument type: Variable number of INTEGER/LONG/FLOAT/DOUBLE/STRING arguments |
| 73 | + |
| 74 | +Return type: Type of the selected argument |
| 75 | + |
| 76 | +Example:: |
| 77 | + |
| 78 | + os> source=accounts | eval min_val = MIN(age, 30) | fields age, min_val |
| 79 | + fetched rows / total rows = 4/4 |
| 80 | + +-----+---------+ |
| 81 | + | age | min_val | |
| 82 | + |-----+---------| |
| 83 | + | 32 | 30 | |
| 84 | + | 36 | 30 | |
| 85 | + | 28 | 28 | |
| 86 | + | 33 | 30 | |
| 87 | + +-----+---------+ |
| 88 | + |
| 89 | + os> source=accounts | eval result = MIN(firstname, 'John') | fields firstname, result |
| 90 | + fetched rows / total rows = 4/4 |
| 91 | + +-----------+--------+ |
| 92 | + | firstname | result | |
| 93 | + |-----------+--------| |
| 94 | + | Amber | Amber | |
| 95 | + | Hattie | Hattie | |
| 96 | + | Nanette | John | |
| 97 | + | Dale | Dale | |
| 98 | + +-----------+--------+ |
| 99 | + |
| 100 | + os> source=accounts | eval result = MIN(age, 35, firstname) | fields age, firstname, result |
| 101 | + fetched rows / total rows = 4/4 |
| 102 | + +-----+-----------+--------+ |
| 103 | + | age | firstname | result | |
| 104 | + |-----+-----------+--------| |
| 105 | + | 32 | Amber | 32 | |
| 106 | + | 36 | Hattie | 35 | |
| 107 | + | 28 | Nanette | 28 | |
| 108 | + | 33 | Dale | 33 | |
| 109 | + +-----+-----------+--------+ |
0 commit comments