首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

字符串分割有关问题

2012-03-11 
字符串分割问题有张表,里面有这样一些记录,如果找出其中的计量单位。0.4-4.6 pg/mL125 pg/mL15 ??ol/L0.8

字符串分割问题
有张表,里面有这样一些记录,如果找出其中的计量单位。
0.4-4.6 pg/mL
<125 pg/mL
<15 ??ol/L
0.8-2.0 ng/mL
5.1-14.1 ??/dL
2.0-4.4 pg/mL
0.93-1.7 ng/dL
0.27-4.2 ??U/mL
98 - 107 mmol/L
22 - 29 mmol/L
60-117 mg/dL-females
66-133 mg/dL males



找出,pg/ml,ng/ml,mg/dL and etc

[解决办法]
为什么不适应?
mg/dL-females取是要什么?mg/dL?

探讨
引用:
思路:取/前面第一个空格的位置,然后从那个位置到最后

取/前面第一个空格的位置,然后从那个位置到最后
60-117 mg/dL-females
66-133 mg/dL males

这两行记录不适应

[解决办法]
修正:
SQL code
create table tb(jldw nvarchar(20))insert into tb select '0.4-4.6 pg/mL'insert into tb select '<125 pg/mL'insert into tb select '<15 ??ol/L'insert into tb select '0.8-2.0 ng/mL'insert into tb select '5.1-14.1 ??/dL'insert into tb select '2.0-4.4 pg/mL'insert into tb select '0.93-1.7 ng/dL'insert into tb select '0.27-4.2 ??U/mL'insert into tb select '98 - 107 mmol/L'insert into tb select '22 - 29 mmol/L'insert into tb select '60-117 mg/dL-females'insert into tb select '66-133 mg/dL males'goselect distinct * from(select right(jldw,charindex(' ',REVERSE(jldw))-1)jldw from tb)t where charindex('?',jldw)=0 and charindex('-',jldw)=0 and charindex('/',jldw)>0/*jldw--------------------mmol/Lng/dLng/mLpg/mL(4 行受影响)*/godrop table tb 

热点排行