例: JSON_COMPOSEを使用して、テーブルから値を抽出し、JSONオブジェクトを作成 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - JSONデータ型

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
2020年9月
Language
日本語
Last Update
2021-03-30
dita:mapPath
ja-JP/gzn1554761068186.ditamap
dita:ditavalPath
ja-JP/gzn1554761068186.ditaval
dita:id
evi1472243742653
Product Category
Software
Teradata Vantage
JSON_COMPOSEを使用して、テーブルから選択した値からJSONオブジェクトを作成します。
SELECT JSON_Compose(T.company, T.employees)
FROM
 (
  SELECT company, JSON_agg(empID AS id, 
     empName AS name, 
     empAge AS age) AS employees
  FROM emp_table
  GROUP BY company
 ) AS T;
結果:
JSON_Compose
------------
{
  "company" : "Teradata",
  "employees" : [ 
     { "id" : 1, "name" : "Cameron", "age" : 24 },
     { "id" : 2, "name" : "Justin", "age" : 34 }
  ]
}
{
  "company" : "Apple",
  "employees" : [ 
     { "id" : 3, "name" : "Someone", "age" : 24 } 
  ]
}