Let's suppose I created this table:
CREATE TABLE T (
NAME VARCHAR(10),
A INT NOT NULL,
B INT NOT NULL
)
I want to create a view that has two attributes, T.Name and a char that is 'Y' if A >= B or 'N' otherwise
.
How can I build this second attribute? Thank you
Just use a case
statement:
create view v as
select t.name, (case when t.a >= t.b then 'Y' else 'N' end) as attribute
from table t;