Search code examples
oracle-databasedecodesql-like

Using Decode as a like statement in oracle


I need to write a sql statement like this:

 SELECT id_segmento AS Segmento, Decode (id_segmento ,  '1' , 'a', 'b' )

 FROM mapchile.segmento

but in this case I will obtain an 'a' when id_segmento is equal to '1', I need it to be 'a' even when the string id_Segmento contains the '1', kind of like and like statment.

There is any other command like Decode that works this way?

Thanks.


Solution

  • I'd use a case statement. Something like

    case
       when id_segmento like '%1%' then 'a'
       else 'b'
    end