计算列中的位数 [英] Counting the number of digits in column
本文介绍了计算列中的位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的代码
select len(cast(code as float)),code
from tbl1
where code is not null
这是输出:
我想在代码栏中输入数字。
我不明白为什么最后一个计数为12而不是8?
I want a count of digits in the code column. I don't understand why the last one is counted as 12 and not 8?
推荐答案
将其作为 int
代替:
select len(cast(code as int)), code
from tbl1
where code is not null;
大概是某种十进制值正在计数。
Presumably, some sort of decimal values are getting counted.
这篇关于计算列中的位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文