this script i wrote in sql extracts the jsons from a column in a table an brings out the…
- User
this script i wrote in sql extracts the jsons from a column in a table an brings out the important values, but i noticed its not bringing out some of them. it extracts from the column FIELD_VALUE , but in some cases such as the one im about to show, nothing is returned. This is because the answer exists for those in an adjacent column called '' CONFIG. and to identify these special cases, it would be where another column called FIELD_TYPE its value is 'MultiChoice'. This is my current script: SELECT *, CASE WHEN ISJSON(FIELD_VALUE) = 1 AND JSON_VALUE(FIELD_VALUE, '.value') <> '' THEN JSON_VALUE(FIELD_VALUE, '.itemValues[0].status') IS NOT NULL THEN JSON_VALUE(FIELD_VALUE, '.url') IS NOT NULL THEN JSON_VALUE(FIELD_VALUE, '$.url') ELSE 'no response' END AS extracted_value FROM ProcessStreetFormFieldValueStaging;
- Assistant
To address this issue, you need to alter your current query to also handle cases where the is 'MultiChoice'. Specifically, if is 'MultiChoice', you need to join the and the column to extract the names of the selected items.