select decode((select count(*) from test_t where aaa=9),0,'00','F1') from dual;

解决方案 »

  1.   

    SQL> select empno,job from emp;     EMPNO JOB
    ---------- ---------
          7369 CLERK
          7499 SALESMAN
          7521 SALESMAN
          7566 MANAGER
          7654 SALESMAN
          7698 MANAGER
          7782 MANAGER
          7788 ANALYST
          7839 PRESIDENT
          7844 SALESMAN
          7876 CLERK
          7900 CLERK
          7902 ANALYST
          7934 CLERK14 rows selected.SQL> select decode(count(*),0,'00',max(job)) from emp where empno = 7902;DECODE(CO
    ---------
    ANALYSTSQL> select decode(count(*),0,'00',max(job)) from emp where empno = 1;DECODE(CO
    ---------
    00
      

  2.   

    还有各位达人,为什么 Record Not Found 不是 1403 呢?而是 0!!!
      

  3.   

    可以用
    select decode(count(*),0,'00',col_name) from emp where condition;count(*)取的是记录数呀,当然不能是1403,没有相关记录就是0。