Solved

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

Posted on 2015-02-03
6
85 Views
Last Modified: 2015-02-04
How do I show the NULL values and not eliminate them when aggregating.
I'm joining on a lookup table and want to show all the lookup table values even though their are not values associated with that value.

Any ideas?
0
Comment
Question by:JElster
6 Comments
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40587679
If you do not have where clause add it:

Where CustName ='ABC' or CustName Is Null

BTW, null value is not correct us. We could say either null or null mark.

This is because null is null because it has no value and it is never going to get one.

This is not my pinion or interpretation. It comes from a book I am studying now.
0
 
LVL 1

Author Comment

by:JElster
ID: 40587687
I want to show ZERO'S where the value is null... for the sum of the values with no corresponding lookup value
0
 
LVL 33

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 150 total points
ID: 40587692
That should be handled in SELECT portion:

Select Sum(IsNull(Amount,0))
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 10

Assisted Solution

by:HuaMinChen
HuaMinChen earned 50 total points
ID: 40587711
Put like
...
sum(isnull(column1,0))
...

Open in new window

0
 
LVL 33

Expert Comment

by:Mike Eghtebas
ID: 40587713
HuaMinChen,

Is this different than my post is some way?

Mike
0
 
LVL 48

Accepted Solution

by:
PortletPaul earned 300 total points
ID: 40587909
Your question is quite broad.  
While I believe eghtebas has correctly pointed to the ISNULL() function this might not be all you need.

How do I show the NULL values and not eliminate them when aggregating.
I'm joining on a lookup table and want to show all the lookup table values

You might need an outer join to "show" information that would be ignored if using an INNER JOIN

select lookup.name, COALESCE(count(d.id),0) as times_used
from lookup
LEFT OUTER JOIN your_data_table d on lookup.id = d.lookupid
group by lookup.name

This would list ALL lookup names even if they haven't been used in the data table.

Notes:
When using COUNT() it can be very important that NULLs do exist (because NULL is ignored in the count)

As an alternative to ISNULL()  you can use COALESCE().
These are not exactly the same; COALESCE can do more than ISNULL()
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now