如何在 sql 中获取 123456 个数字的前 3 位数字? [英] How I can get the first 3 digits in 123456 Numbers in sql?
本文介绍了如何在 sql 中获取 123456 个数字的前 3 位数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 CDR 表中有名为 CallingParty 的字段,它包含如下数据:
I have field called CallingParty in My CDR table it contains data like this:
CallingParty
------------
267672668788
我想选择每个数字的前 3 个数字,例如
I want to select the first 3 number of each of those numbers like
CallingParty
------------
267
推荐答案
如果 CallingParty
是 int 类型:
if CallingParty
is of type int:
SELECT CAST(LEFT(CallingParty, 3) AS INT)
From CDR
这篇关于如何在 sql 中获取 123456 个数字的前 3 位数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文