Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 12 May 2006 @ 08:59:50 GMT


     
  <Prev Next>   <<First <Prev
Next>
Last>>
 


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



     
  <Prev Next>   <<First <Prev
Next>
Last>>
 
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023