Keeping it clean and legible,
CASE
WHEN tsysOS.OSname = 'Win 7' THEN Replace(tblOperatingsystem.Caption, 'Microsoft Windows 7 ', '')
WHEN tsysOS.OSname = 'Win 8' THEN Replace(tblOperatingsystem.Caption, 'Microsoft Windows 8 ', '')
WHEN tsysOS.OSname = 'Win 8.1' THEN Replace(tblOperatingsystem.Caption, 'Microsoft Windows 8.1 ', '')
WHEN tsysOS.OSname = 'Win 10' THEN Replace(tblOperatingsystem.Caption, 'Microsoft Windows 10 ', '')
ELSE tblOperatingsystem.Caption
END AS [OS Version],
If you don't care so much about legibility, you could nest Replace():
Replace(Replace(Replace(Replace(Replace(tblOperatingsystem.Caption, 'Microsoft Windows ', ''), '10 ', ''), '7 ', ''), '8 ', ''), '8.1 ', '') As [OS Version],
As one who has to come back to code and modify things later, I am
not suggesting doing this, but because you don't seem to have used Replace() before, I'm throwing it out there just to show that it can be done.
Unpacking it for illustration:
/* 5 */ Replace(
/* 4 */ Replace(
/* 3 */ Replace(
/* 2 */ Replace(
/* 1 */ Replace(tblOperatingsystem.Caption, 'Microsoft Windows ', '')
/* 2 */ , '10 ', '')
/* 3 */ , '7 ', '')
/* 4 */ , '8 ', '')
/* 5 */ , '8.1 ', '') As [OS Version],
First, because it's common to all of them, strip out "Microsoft Windows ".
Second, if there's a "10 ", remove that.
Third, if there's a "7 ", remove that.
Fourth, if there's an "8 ", remove that.
Fifth, if there's an "8.1 ", remove that.
Again,
do not do this. It does work. There's a time and a place for it. This isn't it.