当查询时候 有null相减就会出现以上情况
SELECT NULL - SYSDATE FROM dual;
处理为 select 0 - nvl(SYSDATE,0) FROM dual;
实际例子:
(nvl(t11.begin_time,to_date('1990/1/1 00:00:00','yyyy/mm/dd hh24:mi:ss')) - nvl(t22.begin_time,to_date('1990/1/1 00:00:00','yyyy/mm/dd hh24:mi:ss'))) * 24 * 60 as dif
SELECT NULL - SYSDATE FROM dual;
处理为 select 0 - nvl(SYSDATE,0) FROM dual;
实际例子:
(nvl(t11.begin_time,to_date('1990/1/1 00:00:00','yyyy/mm/dd hh24:mi:ss')) - nvl(t22.begin_time,to_date('1990/1/1 00:00:00','yyyy/mm/dd hh24:mi:ss'))) * 24 * 60 as dif
本文深入探讨了在SQL查询中遇到NULL值与日期运算时的问题及解决方案,通过实例展示了如何使用NVL函数来避免错误,并确保计算结果的准确性。
3083

被折叠的 条评论
为什么被折叠?



