Solved

Why are my SQL Server results NULL?

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
need help in sql 4 67
Permissions on Database 11 38
Sql Query: need to find records in table_a with no matches in table_b 14 29
T-SQL: Nested CASE Statements 4 24
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…
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

867 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

15 Experts available now in Live!

Get 1:1 Help Now