Solved

Why are my SQL Server results NULL?

Posted on 2014-02-18
2
244 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
ID: 39867627
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
ID: 39868286
Excellent. Should have thought of that. Thank you.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
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 …
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

831 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