Skip to content
Advertisement

Iterate an array using only select query in teradata

I’m trying to achieve the output table using the input table. The input table contains id and name where id has the numerical values and name contains JSON value. I can get the output by writing a procedure query by using ‘LOOP’, ‘Cursor’ etc. But how can we achieve this same using select query statement in Teradata.

Input table

S.No Name
1 { “id”: 4, “item” : [“Apple”, “google”, “IBM” ] }

Output table

Id Index Name
4 0 apple
4 1 google
4 2 ibm

Query

Advertisement

Answer

Using JSONExtractValue / JSONExtract

Or with JSON_Table:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement