除以零错误遇到简单的select语句

时间:2019-03-04 01:39:42

标签: sql-server dividebyzeroexception

我正在尝试运行简单的选择查询,但返回“遇到零除错误”

select * from RL1

这将返回遇到零除错误

有人可以帮我解决吗?

视图架构如下:

GO
CREATE VIEW pms.RL1 AS
    SELECT        rv2.ID, rv2.DS, CASE WHEN rv2.LR / ISNULL(NULLIF (rv2.LR, 0), 1) > 4 THEN 1000 * rv4.LR ELSE 1000 * rv2.LR END AS LR, CASE WHEN rv2.RR / ISNULL(NULLIF (rv2.RR, 0),
                              1) > 4 THEN 1000 * rv4.RR ELSE 1000 * rv2.RR END AS RR
    FROM            (SELECT        IDRV, ID, DS, IDRC, LR, LO, RR, RO, LW, LO
                              FROM            dbo.RV
                              WHERE        (IDRC = 2)) AS rv2 LEFT OUTER JOIN
                                 (SELECT        IDRutValue, ID, DS, IDRC, LR, LO, RR, RO, LW, LO
                                   FROM            dbo.RV
                                   WHERE        (IDRC = 4)) AS rv4 ON rv2.ID = rv4.ID AND rv2.DS = rv4.DS

0 个答案:

没有答案