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


-----

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

热点内容
电信无线路由器官方密码是什么 发布:2025-07-03 16:25:00 浏览:772
空间只能申请访问 发布:2025-07-03 16:23:27 浏览:734
华硕天选2air配置如何选择 发布:2025-07-03 16:10:09 浏览:571
asp搜索源码 发布:2025-07-03 15:49:55 浏览:235
医美大数据库 发布:2025-07-03 15:47:07 浏览:357
c语言将二进制转化为十进制 发布:2025-07-03 15:32:47 浏览:988
c语言帮助文档 发布:2025-07-03 15:22:43 浏览:320
双端口存储器在情况下会发生读写冲突 发布:2025-07-03 15:12:54 浏览:271
快站数据库 发布:2025-07-03 14:45:44 浏览:40
jsp获取上传文件路径 发布:2025-07-03 14:44:46 浏览:569