July 11, 2008 at 9:56 am
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!
July 11, 2008 at 7:22 pm
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
Change is inevitable... Change for the better is not.
July 14, 2008 at 1:05 am
or ...
just replace your code to
MIN(isnull(u.ITEM,0)) AS UnitItem
karthik
July 14, 2008 at 8:06 am
July 15, 2008 at 2:35 pm
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
July 15, 2008 at 3:00 pm
July 26, 2012 at 1:42 am
But we want use in view .is that possible ??
August 15, 2012 at 10:21 pm
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.
_____________
Code for TallyGenerator
January 22, 2013 at 4:27 am
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
January 22, 2013 at 4:29 am
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
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply