0

您好,我的存储过程有一个问题,我在这里使用了 2 个案例,第一个案例显示了正确的值并且没问题,第二个案例只显示了 TirType 字段中的 Null 值,我不明白是什么问题

CREATE VIEW dbo.YUITY
    SELECT     CAST(dbo.SC5116.CODE AS int) AS код, dbo.SC5116.DESCR AS Наименование,    
     CAST(dbo.SC3420.CODE AS int) AS TIR, dbo.SC3420.SP4947 AS Date, 
                  CASE WHEN SC3420.SP4949 <> '     0   ' THEN 'ПовышСтрах' ELSE 'ОснСтрах' END AS VID, 
                  CASE WHEN dbo.SC3420.SP9214 = '714' THEN '4v' END AS TirType
      FROM         dbo.SC3420 INNER JOIN
                  dbo.SC5116 ON dbo.SC3420.SP3422 = dbo.SC5116.ID
       WHERE     (dbo.SC3420.SP4947 <> '01.01.1753')
4

1 回答 1

1

END之后不要忘记CASE。如果没有指定 ELSE 并且值不是 '714',它将返回 NULL。

CREATE VIEW dbo.YUITY
AS
    SELECT     CAST(dbo.SC5116.CODE AS int) AS код, dbo.SC5116.DESCR AS Наименование,    
     CAST(dbo.SC3420.CODE AS int) AS TIR, dbo.SC3420.SP4947 AS Date, 
                  CASE WHEN SC3420.SP4949 <> '     0   ' THEN 'ПовышСтрах' ELSE 'ОснСтрах' END AS VID, 
                  CASE WHEN dbo.SC3420.SP9214 = '714' THEN '4v' ELSE '' END AS TirType
      FROM         dbo.SC3420 INNER JOIN
                  dbo.SC5116 ON dbo.SC3420.SP3422 = dbo.SC5116.ID
       WHERE     (dbo.SC3420.SP4947 <> '01.01.1753')
于 2013-09-18T10:55:56.890 回答