orcl max函数

来源:互联网 发布:aria2 windows懒人包 编辑:程序博客网 时间:2024/06/14 02:37

实际应用中碰到的一个小问题,之前从没发现过,用max(count)获取一个字段的最大值

1这段sql在不为空的表中执行没有报错,以为是正确的,但是实际测试时,清空了表数据,然后发现max(count)出来的不是0而是空,啥都没有。

2为正确修改方式,即使空表也会出来0,不报错

1、select max(count) from execution t where t.id=
2、select NVL( max(count),0) from execution t where t.id=