Example: Using JSON_AGG without GROUP BY and No Parameter Names - Advanced SQL Engine - Teradata Database

JSON Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
gzn1554761068186.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1150
lifecycle
previous
Product Category
Teradata Vantageā„¢
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" : "Teradata", "empName" : "Cameron", "empAge" : 24 },{ "empID" : 2, "company" : "Teradata", "empName" : "Justin", "empAge" : 34 },{ "empID" : 3, "company" : "Teradata", "empName" : "Someone", "empAge" : 24 }]