Null value is eliminated by an aggregate or other SET operation

  • When i do a group by statement like

    select client,productcode,modifiedlot,location,sku,count(*) ct,cast(sum(grosswgt) as decimal(18,4)) grosswgt,

      cast(sum(netwgt) as decimal(18,4)) netwgt, cast(sum(avail) as decimal(18,4)) avail,cast(sum(onhand) as decimal(18,4)) onhand

      from or51import group by client,productcode,modifiedlot,location,sku

    I got the message:

    Warning: Null value is eliminated by an aggregate or other SET operation.

    Add up all values in count(*), the sum is equal to total row in  the table, thus I have not missed a row. Is this a warning I need to worry about, or my aggregation result is good and nothing really to worry.

  • Are there any nulls hiding in the columns you are adding up?

    e.g. select * from or51import where grosswgt is null?

  • Assuming that you want any NULLs to be summed as zeroes, use the isnull() function to get rid of the worrying error:

    select client,productcode,modifiedlot,location,sku,count(*) ct,cast(sum(isnull(grosswgt,0)) as decimal(18,4)) grosswgt,

      cast(sum(isnull(netwgt,0)) as decimal(18,4)) netwgt, cast(sum(isnull(avail,0)) as decimal(18,4)) avail,cast(sum(isnull((onhand,0)) as decimal(18,4)) onhand

      from or51import group by client,productcode,modifiedlot,location,sku

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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