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
but wish this, row values corresponding site '7' summed, etc
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
try patindex function, suggested here: sql server regular expressions in t-sql
Comments
Post a Comment