SELECT AS JSON Statement Example | VantageCloud Lake - SELECT AS JSON Examples - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
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;