Вопрос

I have 2 columns string and Character. My requirement is to compare those 2, if the second column(char) is available in first column(string) the answer should be some value(say 1).

I tried using translate but it doesn't work.

Any functions available for above requirement.

Это было полезно?

Решение 2

select
    case when
            (select
                   STRPOS(
                          trim(lower('abc.com')),
                          trim(lower('xyz'))
                          )
             ) > 0
     then
            1
    else
            2
    end;

To test this code put your first string instead of 'abc.com' and second string at 'xyz'. If your second string present in first string it will output 1 else 2.

Hope this will help.

Другие советы

Netezza implements the usual ANSI standard position function.

TESTDB.ADMIN(ADMIN)=> select position('BC' in 'ABCDEF');
 STRPOS
--------
      2
(1 row)

TESTDB.ADMIN(ADMIN)=> select position('BZ' in 'ABCDEF');
 STRPOS
--------
      0
(1 row)

The translate function converts certain characters in a source string, so that won't do what you want at all.

TESTDB.ADMIN(ADMIN)=> select translate('ABCDE', 'BE', 'XYZ');
 TRANSLATE
-----------
 AXCDY
(1 row)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top