对于您不想使用逐行方法的表中的列,请尝试以下一种方法:
with cte(n) as ( select 1 union all select n + 1 from cte where n < 9)select t.s1, t.s2, sum( case when substring(t.s1, c.n, 1) <> substring(t.s2, c.n, 1) then 1 else 0 end ) as difffrom test as t cross join cte as cgroup by t.s1, t.s2
= > SQL小提琴演示
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)