t-sql 2012 Warning: Null value is eliminated by an aggregate or other SET operation.

  • In a t-sql 2012 query that will be updated in a stored procedure I am getting the following warning message:

    Warning: Null value is eliminated by an aggregate or other SET operation. I would like to get rid of this warning missing without just turning off the warning messages.

    I would like to change the sql so that it does not occur. The following is my new sql that generates the warning:

    case when (coalesce(a.status,ae.status) = 'A') and (IsNull(ae.excuse, 'U') = 'U') and (IsNull(ae.code, 'DRC') = 'DRC') then

    sum(DATEDIFF(minute,pm.startTime,pm.endTime)-coalesce(pm.lunchTime,0)-coalesce(a.presentMinutes,0)) else 0 end as DRCMinutes,

    The sql is part of a select statement. Thus can you show me how to modify the sql that I just listed and explain why your change would make a difference?

  • sum(case when (coalesce(a.status,ae.status) = 'A')

    and (ae.excuse is null or ae.excuse = 'U')

    and (ae.code is null or ae.code = 'DRC')

    --and (pm.startTime is not null and pm.endTime is not null)

    then isnull(DATEDIFF(minute,pm.startTime,pm.endTime),0)-coalesce(pm.lunchTime,0)-coalesce(a.presentMinutes,0)

    else 0 end) as DRCMinutes,

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply