我有一个表T1,其中包含以下列和行/行数据:
table T1 child_id | childOne | ChildHired | ChildProgress 1 Yes No Good 2 No No Poor 3 Yes Yes Fair
我需要使用一个选择案例条件,以便只有满足条件的行出现在结果中,并且不符合条件的行不应出现在我的结果中。
执行时:
select (case when childOne='yes' then true else false end) from T1;
查询有效,但[childOne='No']
行也出现了。如何才能使不满足特定条件的行不显示在我的结果集中?
答案 0 :(得分:0)
使用下面的一个 -
select *
from T1
where childOne='yes';
案例:
select case when childOne='yes' then childProgress
when childOne='No' then childHired else childOne end
from T1 ;