我使用Oracle,并希望将选择计数的结果转换为“二进制”0/1值.0=0.非零= 1。根据我在网上看到的,在MS中,您可以将其转换为“位”,但Oracle似乎不支持这一点。
下面是我的简单示例查询(真正的查询要复杂得多)。我希望MATCH_EXISTS总是0或1,这有可能吗?
select count(*) as MATCH_EXISTS
from MY_TABLE
where MY_COLUMN is not null;发布于 2015-10-23 19:47:46
不要做count()。为了提高性能,请使用exists
select (case when exists (select 1 as MATCH_EXISTS
from MY_TABLE
where MY_COLUMN is not null
)
then 1 else 0
end)
from dual;这可以大大加快速度。
https://stackoverflow.com/questions/33310150
复制相似问题