| id | range | differences (inclusive | sum of Differences total |
|---|---|---|---|
| 1 | '01-08,24-32' | 8,9 | 17 |
| 2 | '38-70' | 33 | 33 |
| 3 | '01-25, 27-38' | 25,12 | 37 |
| 4 | '1-6,13-20,25-32' | 6,8,8 | 22 |
| 5 | '1-4, 7-8, 11-12' | 4,2,2 | 8 |
| 4 | NULL | NULL | NULL |
| 5 | '145-167, 169-214, 217-218, 247-254, 256-257, 382' | 13,46,2,8,2,1 | 72 |
I have been given a table which has a range of pages as a string as a field. I need to find the simplest coding method to get the differences (inclusive) of each string range and then sum those differences.
I am using GoogleSQL at work so there is some carry over from MySQL but some functions aren't carries over so I've been struggling. I'm looking for a solution which doesn't have too many functions which will be hard for me to map over to gSQL.
I thought maybe doing some REGEX matching or extracting would be the way to go but I'm not sure how to get the ranges isolated as INTS to do math on them.
TIA