Changing a SUM returned NULL to zero

前端 未结 6 1740
旧巷少年郎
旧巷少年郎 2021-02-05 01:54

I have a stored procedure as follows:

CREATE PROC [dbo].[Incidents]
(@SiteName varchar(200))
AS
SELECT
(  
    SELECT SUM(i.Logged)  
    FROM tbl_Sites s  
             


        
6条回答
  •  醉话见心
    2021-02-05 02:39

    You'll have to use ISNULL like this -

    ISNULL(SUM(c.Logged), 0)      
    

    Or, as Michael said, you can use a Left Outer Join.

提交回复
热议问题