sql server - Simplify Row Values in SQL Output -


i have sql code (abridged)

select replace(replace(replace(replace(dbo.identity_map.name,'my company\',''),'-vlan2',''),'.vlan2\',''),'.instr\','') site,                    count (case                             when dbo.sem_agent.agent_version '11.%'                                 , dbo.sem_computer.operation_system 'windows%' 1             ............              group replace(replace(replace(replace(dbo.identity_map.name,'my company\',''),'-vlan2',''),'.vlan2\',''),'.instr\','')             order site 

my output looks this

enter image description here

but wish this, row values corresponding site '7' summed, etc

enter image description here

i believe regex help, because

^\w+(?:\s+\w+)?\\|[a-z].*$ 

would isolate number after '\'

but when attempt replace statement regex

select replace(replace(replace(replace(replace(dbo.identity_map.name,'my company\',''),'-vlan2',''),'.vlan2\',''),'.instr\',''), '^\w+(?:\s+\w+)?\\|[a-z].*$') site, 

i error

the replace function requires 3 argument(s). 

please guide

another update

i tried ms sql code (abridged)

select patindex('^\w+(?:\s+\w+)?\\|[a-z].*$',replace(replace(replace(replace(dbo.identity_map.name,'my company\',''),'-vlan2',''),'.vlan2\',''),'.instr\','')) site,                    count (case                             when dbo.sem_agent.agent_version '11.%'                                 , dbo.sem_computer.operation_system 'windows%' 1                           end) 'windows-sep-11',  ......             group patindex('^\w+(?:\s+\w+)?\\|[a-z].*$',replace(replace(replace(replace(dbo.identity_map.name,'my company\',''),'-vlan2',''),'.vlan2\',''),'.instr\',''))             order site 

and output

enter image description here

try patindex function, suggested here: sql server regular expressions in t-sql


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -