リファレンスガイド> SQL関数のTDVサポート> 集計関数> JSON_ARRAYAGG
 
JSON_ARRAYAGG
各入力SQL式の集計をJSON値に変換し、それらのJSON値を含む単一のJSON配列を返します。
構文
<JSON array aggregate constructor> ::= “JSON_ARRAYAGG” “(“ <JSON value expression>
[ "ORDER BY" <sort specification list> ] [ "NULL ON NULL" | "ABSENT ON NULL" ] “)”
<sort specification list> ::= <sort specification> [ { "," <sort specification> }... ]
<sort specification> ::= <sort key> [ "ASC" | "DESC" ] [ NULLS FIRST | NULLS LAST ]
ルール
1. 戻りタイプは文字列です。
2. ABSENT ON NULLは暗黙的です。
3. 数値、ブール、nullタイプに加えて、JSON値は文字列であるか文字列としてキャストする必要があります。
4. 関数によって取得された行が0の場合、nullを返します。
SELECT JSON_ARRAYAGG(customerid) a1 FROM /shared/examples/ds_orders/tutorial/customers GROUP BY customerid HAVING JSON_ARRAYAGG(customerid)='[]'