Solved

Why are my SQL Server results NULL?

Posted on 2014-02-18
2
240 Views
Last Modified: 2014-05-19
I built a view that simply sums up columns for each record. Why are my results NULL? My query is below and all my columns are set to Data Type: Decimal. I have also tried setting the data type to numeric with the same results.

SELECT        QUOTETRK, OTHERFEE2 + OTHERFEE1 + AOGTRANFEE + PACKFEE + QOTAMT AS QOTTOTAL
FROM            dbo.AS400DATA

Open in new window

0
Comment
Question by:maximus1974
2 Comments
 
LVL 18

Accepted Solution

by:
lludden earned 500 total points
Comment Utility
If any of the values are null, the result is null.  If you don't want that, then you can wrap each value in an ISNULL(<field>,0)

SELECT        QUOTETRK, ISNULL(OTHERFEE2,0) + ISNULL(OTHERFEE1,0) + ISNULL(AOGTRANFEE,0) + ISNULL(PACKFEE,0) + ISNULL(QOTAMT,0) AS QOTTOTAL
FROM            dbo.AS400DATA

Open in new window

0
 

Author Closing Comment

by:maximus1974
Comment Utility
Excellent. Should have thought of that. Thank you.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

772 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

9 Experts available now in Live!

Get 1:1 Help Now