JSON Data Type | Dot Notation in a WHERE Clause Examples | Teradata Vantage - Examples: Using Dot Notation in the WHERE Clause - 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 examples in this section reference the table and data set up in Setting Up the Examples Using Dot Notation in SELECT and WHERE Clause.

Retrieve the Name of a Customer Who Has Ordered a Disk

SELECT jsonCol01.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 'disk' = ANY(jsonCol01.items..name);
Result:
> CustomerName
SELECT jsonCol02.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 'disk' = ANY(jsonCol02.items..name);
Result:
> CustomerName
SELECT jsonCol03.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 'disk' = ANY(jsonCol03.items..name);
Result:
> CustomerName
SELECT jsonCol04.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 'disk' = ANY(jsonCol04.items..name);
Result:
> CustomerName
SELECT jsonCol01.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 'disk' = ALL(jsonCol01.items..name);
Result:
*** No rows found

Retrieve the Name of a Customer Who Ordered More Than 40 Pieces of an Item

SELECT jsonCol01.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 40 < ANY(jsonCol01.items..amt);
Result:
> CustomerName 
SELECT jsonCol02.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 40 < ANY(jsonCol02.items..amt);
Result:
> CustomerName 
SELECT jsonCol03.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 40 < ANY(jsonCol03.items..amt);
Result:
> CustomerName 
SELECT jsonCol04.customer 
FROM jsonEnhancedDotNotationTbl
WHERE 40 < ANY(jsonCol04.items..amt);
Result:
> CustomerName