Solved

Why are my SQL Server results NULL?

Posted on 2014-02-18
2
250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

830 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