当前位置: 代码迷 >> SQL >> T-SQL 数目字位位数求和
  详细解决方案

T-SQL 数目字位位数求和

热度:105   发布时间:2016-05-05 14:13:35.0
T-SQL 数字位位数求和

数字 123456, 求和 =1+2+3+4+5+6 =21

 

declare @i intset @i=123456select 	sum(substring(ltrim(@i),number,1)*1)from 	master..spt_values where 	type='p' and number between 1 and len(@i)


 

1楼hanxuemin123453天前 14:56
学习了。加油!!
  相关解决方案