Skip to content
Advertisement

issues converting output from a view to json and array in snowflake using SQL

I am new to snowflake and have successfully created a view from a table using sql, but I am having issues creating a view that transforms the whole table into Json and array

my view

my_view output

id town created_date updated_at Services
123 modak 2024-03-29 2024-03-29 [{ “service”: “green”, “period”:{“Type”: “definite”, “end_date”: “2024-03-29 11:17:42.000”}}]

my objective is to create two views from my_view that will do the following:

  1. convert my_view to json
  2. Convert my_view to array

The below codes are able to convert my_view to json and array successfully

But when I try to create a view with it I get errors

error generated

Advertisement

Answer

The expression has to be aliased:

or:

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