SELECT AS JSON Statement Example | Teradata Vantage - SELECT AS JSON Examples - Advanced SQL Engine - Teradata Database

JSON Data Type

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-27
dita:mapPath
uwa1591040057999.ditamap
dita:ditavalPath
uwa1591040057999.ditaval
dita:id
B035-1150
lifecycle
previous
Product Category
Teradata Vantageā„¢
If you specify ORDER BY in the SELECT statement, you must explicitly specify the field being ordered as shown in the following query:
SELECT AS JSON pkey, val FROM MyTable ORDER BY pkey ASC;
Similarly, if you specify TOP n in the SELECT statement, you must explicitly specify the field being sorted:
SELECT AS JSON TOP 2 pkey, val FROM MyTable ORDER BY pkey DESC;
The following query fails because comparisons are not allowed for the JSON type.
SELECT AS JSON a, b FROM MyTable ORDER BY 1 ASC;
The following query fails because sorting is not supported for the JSON type.
SELECT AS JSON TOP 10 a, b FROM MyTable ORDER BY 1 DESC;