Archives of the TeradataForum
Message Posted: Fri, 12 May 2006 @ 08:59:50 GMT
Subj: | | Re: CASE with LIKE operator |
|
From: | | Victor Sokovin |
| The "valued" CASE syntax always implies a test for equality. If you want to use the LIKE operator you must use "searched" CASE: | |
> select case
> when a like '%app%' Then 'Apple'
> when a like '%mic%' Then 'Microsoft'
> end ...
If a has a "mixed" value, for example a='appmic', then the order of the WHEN clauses is important.
select case
when a like '%app%' Then 'Apple'
when a like '%mic%' Then 'Microsoft'
end
will return 'Apple', whereas
select case
when a like '%mic%' Then 'Microsoft'
when a like '%app%' Then 'Apple'
end
will return 'Microsoft'.
Perhaps something worth being aware of?
Regards,
Victor
|