Reputation: 99
I need to list last_name
and pseudonym
from a table but where the pseudonym
is null, the result should show "" and where the pseudonym
is ending with "nen", the result should show "NEN". How can i make this into one statement?
I've come forward to this code:
select last_name, COALESCE(pseudonym,'') from authors
But I can't find out how i can make an AND statement to change the second part of the exercise. I think i need to use the LIKE statement with "nen" but I'm not sure how.
Upvotes: 0
Views: 31
Reputation: 1269603
You seem to be looking for a case
expression:
(case when pseudonym like '%nen' then 'NEN'
when pseudonym is not null then pseudonym
else ''
end) as pseudonym
Upvotes: 2