当前位置:首页 » 编程语言 » 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 表名;


-----

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

热点内容
kindeditor上传图片绝对路径 发布:2025-05-14 01:06:27 浏览:275
广数g96编程实例 发布:2025-05-14 01:01:56 浏览:911
安卓手机如何做一个小程序 发布:2025-05-14 01:01:51 浏览:968
linux怎么访问外网 发布:2025-05-14 01:00:24 浏览:952
玩dnf什么配置不卡卡 发布:2025-05-14 00:57:02 浏览:806
android优秀项目源码 发布:2025-05-14 00:54:58 浏览:205
dell服务器怎么装系统 发布:2025-05-14 00:50:52 浏览:593
csgo怎么进日本服务器 发布:2025-05-14 00:39:18 浏览:747
ip查服务器商家 发布:2025-05-14 00:33:37 浏览:212
云服务器布 发布:2025-05-14 00:27:55 浏览:78