我的议席上有2个领域,我需要说明。
Col1 Col2 Col3 abc.txt Y 0 def.txt N 0 bbck.txt Y 1
The Col3
values are based on the Col1
and Col2
values in the following manner.
Y = 1
and N = 0
. So all the values in Col2
that are Y
shall become 1
in col3
, and N
in Col2
will become 0
in Col3
, UNLESS the col1
value ends with %c.txt
. As you can see since the abc.txt
ends with %c.txt
the value in col3
becomes 0
.
我知道,可以通过一份<代码>CASE的声明来做到这一点。 是否有任何人知道如何?
我的法典
SELECT
CASE Col2
WHEN Y THEN 1
WHEN N THEN 0
ELSE
(CASE WHEN [Col1] LIKE %c.txt THEN 0
END)
END
AS Col3,
*
FROM Tabl1
希望这一想法