Example: Using JSON_AGG without GROUP BY and No Parameter Names - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
The example selects columns from a table and uses JSON_AGG to compose those columns into JSON objects.
SELECT JSON_agg(empID, company, empName, empAge)
FROM emp_table;

Result:

JSON_agg
--------
[{ "empID" : 1, "company" : "company1", "empName" : "Cameron", "empAge" : 24 },{ "empID" : 2, "company" : "company1", "empName" : "Justin", "empAge" : 34 },{ "empID" : 3, "company" : "company1", "empName" : "Someone", "empAge" : 24 }]