Snowflake table has a varchar column with following JSON array as value.
[{"$":6394.2,"@":"decisionMetricValue","@id":"Month 1"},{"$":6672.25,"@":"decisionMetricValue","@id":"Month 2"},{"$":5643.05,"@":"decisionMetricValue","@id":"Month 3"},{"$":5564.79,"@":"decisionMetricValue","@id":"Month 4"},{"$":6966.75,"@":"decisionMetricValue","@id":"Month 5"},{"$":7605.15,"@":"decisionMetricValue","@id":"Month 6"}]
Using snowflake sql, I would like to extract data in following format.
Month1,Month2,Month3,Month4,Month5,Month6
6394.2,6672.25,5643.05,5564.79,6966.75,7605.15
I was trying to implement solution https://stackoverflow.com/a/77319223/20535715 , but my json is organized differently.
Thanks.
2
Answers
Had to use use index position differently, it works with a query as blow,
You can try this one. I write it assuming that you may have multiple rows:
This is the result: