當前位置:首頁 » 編程語言 » 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 表名;


-----

希望可以幫到題主,歡迎追問.

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:566
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:855
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:555
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:733
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:656
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:975
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:227
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:87
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:777
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:683