nrad
nrad

Reputation: 93

Use of Regexp_contains

I want to get the output "BR" and "CR" respectively for the following REGEXP_CONTAINS, but I'm getting 'BR' for both. How do i get "BR' for first one and 'CR' for second one.

CASE

 WHEN REGEXP_CONTAINS(Title, '(?i)saving') THEN 'BR'

 WHEN REGEXP_CONTAINS(Title, '(?i)Life Savings') THEN 'CR'

END;

Upvotes: 0

Views: 454

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172994

Simply change order of conditions as in below example

CASE
  WHEN REGEXP_CONTAINS(Title, '(?i)Life Savings') THEN 'CR'
  WHEN REGEXP_CONTAINS(Title, '(?i)saving') THEN 'BR'
END

Upvotes: 2

Related Questions