Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2015-02-03
6
Medium Priority
?
127 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 34

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 34

Assisted Solution

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

Select Sum(IsNull(Amount,0))
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Assisted Solution

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

Open in new window

0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40587713
HuaMinChen,

Is this different than my post is some way?

Mike
0
 
LVL 49

Accepted Solution

by:
PortletPaul earned 1200 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

618 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