Solved

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

Posted on 2015-02-03
6
81 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Suggested Solutions

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how the fundamental information of how to create a table.

747 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

11 Experts available now in Live!

Get 1:1 Help Now