当前位置:首页 » 编程语言 » sql提取数字

sql提取数字

发布时间: 2023-07-05 06:51:34

1. sql怎样取出字符串中的数字

select
casewhenb.FModellike'%=%'thenSUBSTRING(b.FModel,CHARINDEX('=',b.FModel)+1,LEN(b.FModel)-CHARINDEX('=',b.FModel))
whenb.FModellike'%*%'thenSUBSTRING(b.FModel,0,LEN(b.FModel)-CHARINDEX('*',b.FModel))
endas长度

2. SQL怎么取字符串中的数字

select substring(所查询字符串,patindex('%[^0-9][0-9]%',所查询字符串)+1,patindex('%[0-9][^0-9]%',所查询字符串)-patindex('%[^0-9][0-9]%',所查询字符串))这个只能查询第一次在字符串出现的数字串,希望可帮到你你

3. SQL中怎样提取纯数字或者纯字母的字段

完全按照DB2语法设计:
drop function TEST
go
create function test(@input varchar(100))
returns int
begin atomic
declare @int int default 0;
declare @input_lenght int default 0;
set @input_lenght = length(@input);
while @input_lenght <> 0 do
if ( substr(@input,length(@input) - @input_lenght +1,1) in ('0','1','2','3','4','5','6','7','8','9') ) then
set @int = @int + 0;
elseif ( substr(@input,length(@input) - @input_lenght +1,1) in ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')) then
set @int = @int - 1;
end if;
set @input_lenght = @input_lenght -1;
end while;
if ( @int = 0 or @int = -1* length(@input)) then --- 如果累积为0全是数字;如果累积正好是-1乘以长度则正好全是字段
return 0;
else
return 1;
end if;
end
go
select test ('123456') from sysibm.al 结果是 0
select test ('123b456a') from sysibm.al 结果是 1
select test ('abcdefg') from sysibm.al 结果是 0

4. sql语句在一个字段中提取数字

select regexp_substr('水库新村332号','[0-9]+' ) from al;--用正则表达式取出数字
select regexp_substr('水库新村332号','[[:digit:]]+') from al;

5. SQL如何取数字 各个位上的个十百千万

先将整型转换成字符串,再来做截取:

用到函数:
用到cast转换
substring截取

selectid,SUBSTRING(cast(字段asvarchar(8)),1,1),SUBSTRING(cast(字段asvarchar(8)),2,1),SUBSTRING(cast(字段asvarchar(8)),3,1),SUBSTRING(cast(字段asvarchar(8)),4,1)from表

有问题追问

6. SQL-提取字符串中,两个不同字符中间的数字

题主你好,

试试:

select regexp_substr(字段名,"(?<=:).*(?=\})") from 表名;


-----

希望可以帮到题主,欢迎追问.

热点内容
scratch少儿编程课程 发布:2025-04-16 17:11:44 浏览:642
荣耀x10从哪里设置密码 发布:2025-04-16 17:11:43 浏览:368
java从入门到精通视频 发布:2025-04-16 17:11:43 浏览:89
php微信接口教程 发布:2025-04-16 17:07:30 浏览:311
android实现阴影 发布:2025-04-16 16:50:08 浏览:794
粉笔直播课缓存 发布:2025-04-16 16:31:21 浏览:346
机顶盒都有什么配置 发布:2025-04-16 16:24:37 浏览:213
编写手游反编译都需要学习什么 发布:2025-04-16 16:19:36 浏览:818
proteus编译文件位置 发布:2025-04-16 16:18:44 浏览:369
土压缩的本质 发布:2025-04-16 16:13:21 浏览:594