SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
Angelindiego
Angelindiego
Mr or Mrs. 500
Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)

Group: General Forum Members
Points: 570 Visits: 445
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

Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85555 Visits: 41082
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 Row-By-Agonizing-Row.
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
karthik M
karthik M
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2917 Visits: 2584
or ...

just replace your code to

MIN(isnull(u.ITEM,0)) AS UnitItem

karthik
Angelindiego
Angelindiego
Mr or Mrs. 500
Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)

Group: General Forum Members
Points: 570 Visits: 445
thank you both!! I am off to fix the problem!! Have a great week! Hehe


Thank you!!,

Angelindiego

J-440512
J-440512
Right there with Babe
Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)Right there with Babe (721 reputation)

Group: General Forum Members
Points: 721 Visits: 949
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
Angelindiego
Angelindiego
Mr or Mrs. 500
Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)Mr or Mrs. 500 (570 reputation)

Group: General Forum Members
Points: 570 Visits: 445
thank you for the clarification, I appreciate it!


Thank you!!,

Angelindiego

dineshvishe
dineshvishe
SSC-Enthusiastic
SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)SSC-Enthusiastic (184 reputation)

Group: General Forum Members
Points: 184 Visits: 342
But we want use in view .is that possible ??
Sergiy
Sergiy
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10304 Visits: 11960
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.
neethu payal
neethu payal
SSC-Enthusiastic
SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)

Group: General Forum Members
Points: 107 Visits: 94
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
neethu payal
neethu payal
SSC-Enthusiastic
SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)SSC-Enthusiastic (107 reputation)

Group: General Forum Members
Points: 107 Visits: 94
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search