Expand my Community achievements bar.

Join us January 15th for an AMA with Champion Achaia Walton, who will be talking about her article on Event-Based Reporting and Measuring Content Groups!
SOLVED

SQL query to read Array values of a Order Value column

Avatar

Level 3

Hi Team,  

In Data feed raw data, Order_value column has multiple values inside the Array.  Can you please help me with Query to sum up array. 

 

for instance:  

DineshRkumar_0-1730106506478.png

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

There might be an easier way to do this, but it's been a while since I've had to do SQL regularly.

If you want to sum up the values in an array, you need to split out the values of that array, you can do that with the "SPLIT" function, which will put each value on it's own line using a delimiter. But you also have the brackets at the start/end of the array, so you need to get rid of those, I did that with the "REPLACE" function. Just replaced the bracket with an empty value.

 

split(replace(replace(rev_values, "[", ""), "]", ""), ",")

 

MandyGeorge_0-1730398285126.png

 

Once all of the values are on their own row, you can do your normal aggregations to sum.

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor and Adobe Champion

There might be an easier way to do this, but it's been a while since I've had to do SQL regularly.

If you want to sum up the values in an array, you need to split out the values of that array, you can do that with the "SPLIT" function, which will put each value on it's own line using a delimiter. But you also have the brackets at the start/end of the array, so you need to get rid of those, I did that with the "REPLACE" function. Just replaced the bracket with an empty value.

 

split(replace(replace(rev_values, "[", ""), "]", ""), ",")

 

MandyGeorge_0-1730398285126.png

 

Once all of the values are on their own row, you can do your normal aggregations to sum.