0

Where salutation is >15 characters, the word ‘Hi’ is to be inserted in the field

thought about using a regex function, but not sure how to implement this

when regexp_like(salutation, > '^[0-9]{15}$') then 'Hi'

MR Nigel Humphreys  -> "hi"
Ms Montjoy          ->  "Ms Montjoy"
Mr Fitz-Lloyd Smith -> "hi"
Anna
  • 444
  • 1
  • 5
  • 23

1 Answers1

2

How about length() and case?

select (case when length(salutation) > 15 then 'hi'
             else salutation
        end) as new_salutation

If you want to actually overwrite the field, you need an update:

update t
    set salutation = 'hi'
    where length(salutation) > 15;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786