0

I have 2 fields code and house

code                                house 

01-001-0001-0001-0001                 6
01-001-0001-0001-0002                 6 
01-001-0001-0001-0003                 6
01-001-0001-0001-0004                 6
01-001-0001-0001-****                 6

01-001-0001-0002-0001                 8
01-001-0001-0002-0002                 8
01-001-0001-0002-0003                 8
01-001-0001-0002-****                 8

How can I update house = null to obtain

code                                house 

01-001-0001-0001-0001                 6
01-001-0001-0001-0002                  
01-001-0001-0001-0003                 
01-001-0001-0001-0004                 
01-001-0001-0001-****

01-001-0001-0002-0001                 8
01-001-0001-0002-0002                 
01-001-0001-0002-0003
01-001-0001-0002-****

1 Answer 1

4

How about this:

update t
    set house = NULL
    where code not like '%-0001';

If you just want this as the result of a select query:

select code,
       (case when code like '%-0001' then house end) as house
from t;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.