一种)
select decode(count(*), 0, 'N', 'Y') rec_exists from (select 'X' from dual where exists (select 'X' from sales where sales_type = 'Accessories'));
B)
select decode(count(*), 0, 'N', 'Y') rec_exists from (select 'X' from sales where sales_type = 'Accessories');
C)其他(请指定)
编辑:很难选择“正确的”答案,因为最佳方法取决于检查值是否存在之后要执行的操作,如APC所指出的那样。我最终选择了RedFilter作为答案,因为我最初将此项检查本身设想为一个功能。
select case when exists (select 1 from sales where sales_type = 'Accessories') then 'Y' else 'N' end as rec_exists from dual;