Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error: Null value is eliminated by an aggregate

Status
Not open for further replies.

michelleqw

Programmer
Jan 4, 2004
120
DE
Dear sql-server users,

We got an error:

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

Can someone explain what kind of error this is?

Nice regards,

Michelle.
 
This is not an error as such - it is just an informational message. All it means is that when you have used some aggregate function (SUM, COUNT etc) the calculation has ignored any NULL values that may have been in the column.

--James
 
You could eliminate this warning message by excluding NULLs in the query, eg

select sum(col1)
from tbl1
where col1 is not null
 
Use Count(*) if you want to count everything; the number of rows in a table, regardless of what they contain.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
However if for example you are doing an average and you would like the nulls to be counted as 0's (therefore not affecting the result you can do:
Code:
select avg(isnull(yourfield,0))
from yourtable

what this will do is replace any yourfield values that are null with a 0 this then means that the row will still be included in calculating the average.

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top