Given I have data like the following, how can I select and group by portions of a string?
Version Users
1.1.1 1
1.1.23 3
1.1.45 1
2.1.24 3
2.1.12 1
2.1.45 3
3.1.10 1
3.1.23 3
What I want is to sum up the users using version 1.1.x and 2.2.x and 3.3.x etc, but I'm not sure how I can group on a partial string in a select statement.
edit What the data should return like is this:
Version Users
1.1.XX 5
2.1.XX 7
3.1.XX 4
There is an infinite variable number of versions, some are in this format (major, minor, build) some are just major, minor and some are just major, the only time I want to "roll up" the versions is when there is a build.
select rtrim(Version, '0123456789') ||'XX', sum(users)
from Table
group by rtrim(Version, '0123456789')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With