|
1 | 1 | SQL Language Extension: LISTAGG |
2 | 2 |
|
3 | 3 | Function: |
4 | | - The current implementation has an aggregate function LIST which concatenates multiple row |
5 | | - fields into a blob. The SQL standard has a similar function called LISTAGG. The major |
6 | | - difference is that it also supports the ordered concatenation. |
| 4 | + LISTAGG is a SQL standard equivalent of the Firebird-specific aggregate function LIST. |
| 5 | + It provides concatenation of values within a group, with optional ordering. |
7 | 6 |
|
8 | 7 | Authors: |
9 | 8 | Chudaykin Alex <chudaykinalex@gmail.com> |
10 | 9 |
|
11 | 10 | Format: |
12 | 11 | <listagg set function> ::= |
13 | | - LISTAGG <left paren> [ <set quantifier> ] <character value expression> <comma> <listagg separator> [ <listagg overflow clause> ] <right paren> [ <within group specification> ] |
| 12 | + { LISTAGG | LIST } |
| 13 | + <left paren> |
| 14 | + [ ALL | DISTINCT ] <expression> |
| 15 | + [ <comma> <listagg separator> ] |
| 16 | + [ <listagg overflow clause> ] |
| 17 | + <right paren> |
| 18 | + [ <within group specification> ] |
14 | 19 |
|
15 | 20 | <listagg separator> ::= |
16 | | - <character string literal> |
| 21 | + <character string literal> |
17 | 22 |
|
18 | 23 | <listagg overflow clause> ::= |
19 | | - ON OVERFLOW <overflow behavior> |
| 24 | + ON OVERFLOW <overflow behavior> |
20 | 25 |
|
21 | 26 | <overflow behavior> ::= |
22 | | - ERROR | TRUNCATE [ <listagg truncation filler> ] <listagg count indication> |
| 27 | + ERROR |
| 28 | + | TRUNCATE [ <listagg truncation filler> ] <listagg count indication> |
23 | 29 |
|
24 | 30 | <listagg truncation filler> ::= |
25 | | - <character string literal> |
| 31 | + <character string literal> |
26 | 32 |
|
27 | 33 | <listagg count indication> ::= |
28 | | - WITH COUNT | WITHOUT COUNT |
| 34 | + WITH COUNT | WITHOUT COUNT |
29 | 35 |
|
30 | 36 | <within group specification> ::= |
31 | | - WITHIN GROUP <left paren> ORDER BY <sort specification list> <right paren> |
| 37 | + WITHIN GROUP <left paren> ORDER BY <sort specification list> <right paren> |
32 | 38 |
|
33 | 39 | Syntax Rules: |
34 | | - The legacy LIST syntax is preserved for backward compatibility, LISTAGG is added to cover the |
35 | | - standard features. |
| 40 | + The legacy LIST syntax is preserved for backward compatibility and is now an alias for LISTAGG. |
36 | 41 |
|
37 | | - There is a <listagg overflow clause> rule in the standard, which is intended to output an error |
38 | | - when the output value overflows. Since the LIST function always returns a BLOB, it was decided |
39 | | - that this rule would be meaningless. So the OVERFLOW clause is syntactically supported but |
40 | | - silently ignored if specified. |
| 42 | + The SQL standard defines the <listagg overflow clause>, which is intended to output an error |
| 43 | + or truncate when the output value overflows. Since LISTAGG always returns a BLOB, this rule |
| 44 | + does not apply. The OVERFLOW clause is syntactically supported but effectively ignored. |
41 | 45 |
|
42 | 46 | Examples: |
43 | 47 | CREATE TABLE TEST_T |
|
0 commit comments