我需要在井位上拆分lsd。 通常这就是它看起来像100 / 1-27-94-7w4m 我需要抓住任何w4,w5,w6的数量 这将是艾伯塔 什么是w3,w2,w1或任何东西,然后另一个将是sask。
如何解析字符串以获得该计数... 从tblWell中选择count(*) substring,charindex ......?例子很不错
答案 0 :(得分:0)
我建议你做这样的事情:
select which, count(*)
from (select 'w4' as code, 'alberta' as which union all
select 'w5' as code, 'alberta' as which union all
select 'w6' as code, 'alberta' as which union all
select 'w1' as code, 'sask' as which union all
select 'w2' as code, 'sask' as which union all
select 'w3' as code, 'sask' as which
) lookup join
table t
on t.column = '%'+lookup.which+'%'
group by which;