Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
Null value is eliminated by an aggregate or...
Null value is eliminated by an aggregate or other SET operation.
Rate Topic
Display Mode
Topic Options
Author
Message
Angelindiego
Angelindiego
Posted Friday, July 11, 2008 9:56 AM
Old Hand
Group: General Forum Members
Last Login: Friday, April 12, 2013 11:22 AM
Points: 312,
Visits: 386
Hi all! Happy Friday!
ok, I came across a stored proc that is sending out this error when it runs:
"Null value is eliminated by an aggregate or other SET operation."
here is the existing code partial piece of code: MIN(u.ITEM) AS UnitItem
now the case here is that there is a NULL value in the column. What is the proper syntax for checking for nulls in this aggregate situation?? (I have tried a couple different ways and failed)
thank you in advance!
Thank you!!,
Angelindiego
Post #532612
Jeff Moden
Jeff Moden
Posted Friday, July 11, 2008 7:22 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:51 PM
Points: 32,923,
Visits: 26,811
You don't have to...
SET ANSI_WARNINGS OFF
... will eliminate this expected error message.
Just to be sure about a couple of things, you might want to post the proc for a look-see...
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #532921
karthik M
karthik M
Posted Monday, July 14, 2008 1:05 AM
SSCrazy
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 2:56 AM
Points: 2,008,
Visits: 2,469
or ...
just replace your code to
MIN(isnull(u.ITEM,0)) AS UnitItem
karthik
Post #533293
Angelindiego
Angelindiego
Posted Monday, July 14, 2008 8:06 AM
Old Hand
Group: General Forum Members
Last Login: Friday, April 12, 2013 11:22 AM
Points: 312,
Visits: 386
thank you both!! I am off to fix the problem!! Have a great week!
Thank you!!,
Angelindiego
Post #533533
J-440512
J-440512
Posted Tuesday, July 15, 2008 2:35 PM
SSC-Addicted
Group: General Forum Members
Last Login: Monday, September 14, 2009 5:22 AM
Points: 438,
Visits: 918
This is not an error message. SS2K is simply telling you that it ignore NULL values when performing an aggregate operation on records.
Such as
5, NULL, 7
SUM will produce the result 12 WITH the warning message.
Anything added, subtracted, etc. to NULL yields in NULL. 5 + NULL + 7 --> NULL.
You could filter out the NULL values before calling the aggregate.
Regards
Post #534757
Angelindiego
Angelindiego
Posted Tuesday, July 15, 2008 3:00 PM
Old Hand
Group: General Forum Members
Last Login: Friday, April 12, 2013 11:22 AM
Points: 312,
Visits: 386
thank you for the clarification, I appreciate it!
Thank you!!,
Angelindiego
Post #534772
dineshvishe
dineshvishe
Posted Thursday, July 26, 2012 1:42 AM
SSC Rookie
Group: General Forum Members
Last Login: Today @ 10:49 AM
Points: 46,
Visits: 238
But we want use in view .is that possible ??
Post #1335595
Sergiy
Sergiy
Posted Wednesday, August 15, 2012 10:21 PM
SSCarpal Tunnel
Group: General Forum Members
Last Login: Today @ 6:59 PM
Points: 4,557,
Visits: 8,215
dineshvishe (7/26/2012)
But we want use in view .is that possible ??
Yes, of course.
Just use SET ANSI_WARNINGS OFF in procedures which select from the view.
Post #1345650
nitha jen
nitha jen
Posted Tuesday, January 22, 2013 4:27 AM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 5:35 AM
Points: 36,
Visits: 23
hi everyone.....i am the beginner of sql......can anyone help me to find out the mistake where i made????ive tried many times bt again nd again i gt same result"null value is eliminated by an aggregate or other set operation'.....my code completed successfully bt which doesnt show the result bcz of this warning message....can anyone help me??????
declare getcur cursor
for select sd.roll_no
from student_details sd
where sd.degree_id = @degree_id
AND sd.branch_id = @branch_id
AND sd.course_id = @course_id
AND sd.batch = @batch
open getcur
FETCH NEXT FROM getcur INTO @roll_no
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #temp
SELECT sd.reg_no,
sd.student_name,
bd.branch_name,
cd.course_name,
r.noof_semester,
max(isnull(sm.sem_attended,0))as sem_attended,
@is_completed as is_completed,
rs.sub_code,
rs.sub_name,
case when sm.int_mark_obtained is null then 0 else @int_mark_obtained end,
case when sm.ext_mark_obtained is null then 0 else @ext_mark_obtained end,
isnull(sm.int_mark_obtained,0)+isnull(sm.ext_mark_obtained,0)as total_marks,
case when sm.exam_status='p' then 'PASS' when sm.exam_status= 'f' then 'fail' end exam_status
FROM student_details sd
INNER JOIN student_marks sm ON sd.roll_no = sm.roll_no
INNER JOIN regulation_subject rs ON rs.regulation_sub_id = sm.regulation_sub_id
INNER JOIN regulation r ON r.regulation_no= rs.regulation_no
INNER JOIN course_details cd ON cd.course_id = sm.course_id
INNER JOIN branch_details bd ON bd.branch_id=sd.branch_id
WHERE @noof_semester =(select max(@sem_attended) from student_marks sm
where sm.roll_no=@roll_no)
AND sd.roll_no = sm.roll_no
and @batch=2007 and @course_id=99
group by
sd.reg_no,
sd.student_name,
bd.branch_name,
cd.course_name,
r.noof_semester,
rs.sub_code,
rs.sub_name,
sm.int_mark_obtained,
sm.ext_mark_obtained,
sm.exam_status
if @noof_semester=max(@sem_attended)
begin
set @is_completed='yes'
end
else
begin
set @is_completed='no'
end
fetch next from getcur into @roll_no
end
select *from #temp
order by reg_no
close getcur
deallocate getcur
drop table #temp
Post #1409925
nitha jen
nitha jen
Posted Tuesday, January 22, 2013 4:29 AM
SSC Rookie
Group: General Forum Members
Last Login: Wednesday, April 03, 2013 5:35 AM
Points: 36,
Visits: 23
hi everyone.....i am the beginner of sql......can anyone help me to find out the mistake where i made????ive tried many times bt again nd again i gt same result"null value is eliminated by an aggregate or other set operation'.....my code completed successfully bt which doesnt show the result bcz of this warning message....can anyone help me??????
declare getcur cursor
for select sd.roll_no
from student_details sd
where sd.degree_id = @degree_id
AND sd.branch_id = @branch_id
open getcur
FETCH NEXT FROM getcur INTO @roll_no
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #temp
SELECT sd.reg_no,
sd.student_name,
bd.branch_name,
cd.course_name,
r.noof_semester,
max(isnull(sm.sem_attended,0))as sem_attended,
@is_completed as is_completed,
rs.sub_code,
rs.sub_name,
case when sm.int_mark_obtained is null then 0 else @int_mark_obtained end,
case when sm.ext_mark_obtained is null then 0 else @ext_mark_obtained end,
isnull(sm.int_mark_obtained,0)+isnull(sm.ext_mark_obtained,0)as total_marks,
case when sm.exam_status='p' then 'PASS' when sm.exam_status= 'f' then 'fail' end exam_status
FROM student_details sd
INNER JOIN student_marks sm ON sd.roll_no = sm.roll_no
INNER JOIN regulation_subject rs ON rs.regulation_sub_id = sm.regulation_sub_id
INNER JOIN regulation r ON r.regulation_no= rs.regulation_no
INNER JOIN course_details cd ON cd.course_id = sm.course_id
INNER JOIN branch_details bd ON bd.branch_id=sd.branch_id
WHERE @noof_semester =(select max(@sem_attended) from student_marks sm
where sm.roll_no=@roll_no)
AND sd.roll_no = sm.roll_no
and @batch=2007 and @course_id=99
group by
sd.reg_no,
sd.student_name,
bd.branch_name,
cd.course_name,
r.noof_semester,
rs.sub_code,
rs.sub_name,
sm.int_mark_obtained,
sm.ext_mark_obtained,
sm.exam_status
if @noof_semester=max(@sem_attended)
begin
set @is_completed='yes'
end
else
begin
set @is_completed='no'
end
fetch next from getcur into @roll_no
end
select *from #temp
order by reg_no
close getcur
deallocate getcur
drop table #temp
Post #1409929
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.