How to get this in decimal value instead of null

后端 未结 4 1940
萌比男神i
萌比男神i 2021-01-29 10:13

i am trying to get value in Decimal in this query but unable to get i am getting NULL Value

SELECT CAST(CAST(CAST(SUM(CAST(0 AS INT)) AS DECIMAL(10, 2)) * 100 
         


        
4条回答
  •  隐瞒了意图╮
    2021-01-29 10:43

    Use ISNULL built in function:

    ISNULL(CAST(CAST(CAST(SUM(CAST(0 AS INT)) AS DECIMAL(10, 2)) * 100 / CAST(NULLIF(SUM(CAST(0 AS INT)) + SUM(CAST(0 AS INT)) + SUM(CAST(0 AS INT)), 0) AS DECIMAL(10, 2)) AS DECIMAL(10, 2)) AS DECIMAL), 0) 
    

    http://technet.microsoft.com/es-es/library/ms184325.aspx

提交回复
热议问题