• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1416
  • Last Modified:

NULL Value eliminated in aggregate function

Hi Experts!
I was hoping someone could be abel to assist me with an SQL query for my Sybase database.

The query below gives me the warning
NULL Value eliminated in aggregate function

It seams like the query gives me correct result, but I cannot live with the warning
select
count(case when Programs.Level=1 then 1 else NULL end) as Level1,
count(case when Programs.Level=2 then 1 else NULL end) as Level2
from Programs key join Customers key join ProgramHead
*
*
*

Open in new window

0
gfk76
Asked:
gfk76
1 Solution
 
Jan FranekCommented:
Try this modified version (using sum instead of count)
select
sum(case when Programs.Level=1 then 1 else 0 end) as Level1,
sum(case when Programs.Level=2 then 1 else 0 end) as Level2
from Programs key join Customers key join ProgramHead

Open in new window

0
 
gfk76Author Commented:
Ahhh.....

Thank you very much!

That did the trick
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now