Example: Using JSON_AGG without GROUP BY and with Parameter Names

Teradata Vantageā„¢ JSON Data Type

prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1150-162K
The example shows how to use JSON_Agg to assign parameter names in the resulting JSON object.
SELECT JSON_agg(empID AS id, company, empName AS name, empAge AS age) 
FROM emp_table;
Result:
JSON_agg
--------
{ "id" : 1, "company" : "Teradata", "name" : "Cameron", "age" : 24 },
{ "id" : 2, "company" : "Teradata", "name" : "Justin", "age" : 34 },
{ "id" : 3, "company" : "Teradata", "name" : "Someone", "age" : 24 }