Quote Originally Posted by simply_dba
Making your case statement generic

Code:
SELECT CASE V1.Cnt
    WHEN 0 THEN (SELECT sometext FROM t WHERE adate = to_date ('2006/10/16','YYYY/MM/DD'))
    ELSE (SELECT sometext FROM t WHERE adate = to_date('2006/10/11','YYYY/MM/DD'))
    END Sometext
FROM
    (SELECT nvl(COUNT(*),0) Cnt FROM t WHERE adate = to_date('2006/10/11','YYYY/MM/DD')) V1;
You're right, it is more generic this way. Thanks for the improvement.

Are you sure you need the NVL on count(*) ? If there is no match the count will simply return 0, won't it ?

Regards,

rbaraer