0

Good day,

I am attempting to pull 3 characters from a string [datatype nvarchar(25)], then compare those 3 characters to an 'in', and if the result is true, it should return a string.

Here is the code:

,case
when [column1] = 'this' 
and [column2] is null
and substring([column3], 1, 3) in ('that','those','things') 
then 'different_thing'
else [column1] end as [column4]
4

1 回答 1

0

请注意,您没有使用静态比较器的子字符串,因此如果它们的长度不完全是三个字符,那么您将度过一段糟糕的时光。我相信这就是 Nikola 想说的,但我不确定它是否传达得足够清楚。

于 2013-08-13T19:33:46.407 回答