oracle聚合函数忽略空值

select count(*) from utp_stat_testplace u 

     where   u.statdate >( select nvl (max(statTime),to_date('2010-01-01 10:20:30','YYYY-MM-DD HH24:MI:SS')) from report_table_maxTime where type=1 group by type ) ;

返回结果为0

原因是  select nvl (max(statTime),to_date('2010-01-01 10:20:30','YYYY-MM-DD HH24:MI:SS')) from report_table_maxTime where type=1 group by type 返回值为null ,null无限大,因此得到结果为0;

返回null的原因是 oracle 聚合函数忽略空值

nvl (max(statTime),to_date('2010-01-01 10:20:30','YYYY-MM-DD HH24:MI:SS')) 返回结果为null,不是to_date('2010-01-01 10:20:30','YYYY-MM-DD HH24:MI:SS')

猜你喜欢

转载自yehandjava.iteye.com/blog/2074147