Jim
Jim

Reputation: 23

Redshift View Column Reassignment

I have an existing view with a column A that has values 'Y' or 'N'

I need to create another column B that is just the inverse of column A. So when A = 'Y' B = 'N'

Seems really simple but I cannot think of a way to do this within a view. I am trying to find a way to do it with a case that just says If column A = 'Y' then column B = 'N' and the other way around but am having issues

Anyone know of a good way to accomplish this?

Upvotes: 0

Views: 39

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270011

You have the right idea. Assuming A only takes on 'Y' and 'N':

create view invert_a as
    select (case when A = 'Y' then 'N' else 'Y' end) as B, . . .
    from t;

Upvotes: 1

Related Questions