sql-server - 字符长度 SQL Server 2005

  显示原文与译文双语对照的内容
0 0

然而,我建立了一个查询( 请参见下面),而不是返回"大于 20或者 30",我希望查询实际上显示数据( 。 31.35.50等) 。 我似乎不清楚怎么做。 谢谢 帮忙.

select
cc_units_of_measure.description as UOM_Description, 
 case when LEN(cc_units_of_measure.description) <20 then 'OK' 
 else 'Greater than 20' 
 end as Results_UOM_description,
 cc_units_of_measure.company_abbreviation as UOM_Company_Abbreviation, 
 case when LEN(cc_units_of_measure.company_abbreviation) <20 then 'OK'
 else 'Greater than 20' 
 end as Results_UOM_company_abbreviation,
cc_frequencies.description as Freq_Description, 
 case when LEN(cc_frequencies.description) <30 then 'OK' 
else 'Greater than 30' 
end as Results_Frequency_description
from cc_units_of_measure, cc_frequencies
时间:原作者:6个回答

0 0

如果更改case语句的其他部分以返回长度,将获得你要查找的值:

SELECT cc_units_of_measure.description AS UOM_Description, 
 CASE WHEN LEN(cc_units_of_measure.description) <20 THEN 'OK'
 ELSE LEN(cc_units_of_measure.description)
 END AS Results_UOM_description, 
 cc_units_of_measure.company_abbreviation AS UOM_Company_Abbreviation, 
 CASE WHEN LEN(cc_units_of_measure.company_abbreviation) <20 THEN 'OK'
 ELSE LEN(cc_units_of_measure.company_abbreviation)
 END AS Results_UOM_company_abbreviation, 
 cc_frequencies.description AS Freq_Description, 
 CASE WHEN LEN(cc_frequencies.description) <30 THEN 'OK'
 ELSE LEN(cc_frequencies.description)
 END AS Results_Frequency_description
FROM cc_units_of_measure, 
 cc_frequencies
原作者:
...