Example: Use ARRAY_AGG - 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
Aggregate the job positions into arrays containing the ages of the employees in those jobs.
The example uses the table(s) created earlier.
SELECT pos, ARRAY_AGG(age ORDER BY empId, NEW intarr5()) 
FROM employeeTable 
GROUP BY pos
ORDER BY pos;
Result:
pos         ARRAY_AGG(age ORDER BY empId ASC, NEW intarr5())
------------------------------------------------------------
engineer    (24,34,25,21)
executive   (50,51,52,52,60)
manager     (40,41,45,48)
salesman    (31,32,33,40)