Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 warning error

Author  Topic 

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-07 : 20:49:04
hi all..

i have this error and fail to resolve it :-
Warning: Null value is eliminated by an aggregate or other SET operation.
what does that means? my code :-

SELECT
@BookQtyIN = ISNULL(SUM(x.pickqty), 0),
@PickQtyIN = CASE WHEN ISNULL(SUM(x.pickqty), 0) >0 THEN
ISNULL(SUM(d.PickQty), 0) - ISNULL(SUM(x.pickqty), 0)
ELSE ISNULL(SUM(d.PickQty), 0)END,

FROM tblItemDetail d

LEFT JOIN (SELECT p.PickQty AS PickQty,
j.PickComplete AS PickComplete,
p.ItemStorageID AS ItemStorageID
FROM tblItempicked p
LEFT JOIn tblJobDocuments j
ON j.Docrefid=p.Docrefid AND j.JobID=p.JobID
WHERE j.PickComplete='N'
)AS x ON x.ItemStorageID=d.ItemStorageID

WHERE d.ItemID = @ItemID
AND d.Ownership = @ClientID
AND d.CustomLotNo = @CustomLotNo

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-05-07 : 22:57:10
basically, it means one of the value in x.pickqty in your SUM(x.pickqty) is NULL

when you use aggregate function like SUM(), MAX() etc, if any one of the value is NULL and at least one row is not null, the null value will be ignored. If all of the value are NULLs, then the SUM() will return NULL.

You can remove this warning using ISNULL. sum(isnull(x.pickqty, 0))

See this script

declare @t table
(
col int
)

delete @t
insert into @t select 1 union all select 2

select s = sum(col) from @t
/*
s
-----------
3
*/

delete @t
insert into @t select 1 union all select NULL

select s = sum(col) from @t
/*
s
-----------
1

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

delete @t
insert into @t select NULL union all select NULL

select s = sum(col) from @t
/*
s
-----------
NULL


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



KH

Go to Top of Page

maya_zakry
Constraint Violating Yak Guru

379 Posts

Posted - 2007-05-07 : 23:59:15
thanks.. but i still have problem with this .. ive just posted the full specs of what im trying to accomplish http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=83224


~~~Focus on problem, not solution ¯\(º_o)/¯ ~~~
Go to Top of Page
   

- Advertisement -