我有这个问题:
select colA, colB
from tableA
where colB in ('catA','catB')
AND
colA in ('value1', 'value2', ..., 'value999')
现在,此查询显示记录值X满足第一个where条件。
如何修改此设置,以便查询在满足colB in ('catA','catB')
要求时显示所有999 valueX和是/否列?
答案 0 :(得分:1)
这听起来像你想要的
select colA,
colB,
case when colB in ('catA','catB')
then 'Yes'
else 'No'
end your_column_name
from tableA
where colA in ('value1', 'value2', ..., 'value999')
order by (case colA
when 'value1' then 1
when 'value2' then 2
...
when 'value999' then 999
end)