Below is my source table, need expected result but getting incorrect result for the below query. Please help
Query:
select ID, metric, value from ( SELECT *, REGEXP_REPLACE(SPLIT(pair, ':')[OFFSET(0)], r'^"|"$', '') metric, REGEXP_REPLACE(SPLIT(pair, ':')[OFFSET(1)], r'^"|"$', '') value FROM, UNNEST(SPLIT(REGEXP_REPLACE(to_json_string(), r'{|}', ''))) pair ) where metric not in (ID) order by metric, value;
Expected result:
incorrect result with above query:
as far as I can see there is no need to touch the Value column as you only add a column named "metric"
I would suggest working with an Case statement
The source is having dynamic columns. Hence, we can't hard code any columns except ID.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.