15.10 - Example: Using JSON_AGG without GROUP BY and with Parameter Names - Teradata Database

Teradata Database Teradata JSON

prodname
Teradata Database
vrm_release
15.10
created_date
December 2015
category
Programming Reference
featnum
B035-1150-151K
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 }