I have a column of data that contains a percentage range as a string that I’d like to convert to a number so I can do easy comparisons.
Possible values in the string:
'<5%' '5-10%' '10-15%' ... '95-100%'
I’d like to convert this in my select where clause to just the first number, 5, 10, 15, etc. so that I can compare that value to a passed in ‘at least this’ value.
I’ve tried a bunch of variations on substring, charindex, convert, and replace, but I still can’t seem to get something that works in all combinations.
Any ideas?
Try this,
Tested at my end and it works, it’s only my first try so you might be able to optimise it.