Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6177173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:13:40+00:00 2026-05-24T00:13:40+00:00

I have 2 temp tables that I am populating with a numeric value: CREATE

  • 0

I have 2 temp tables that I am populating with a numeric value:

CREATE TABLE #Initial
(
[SalesTax] NUMERIC (20,4),
[Unit] VARCHAR(10)
);

INSERT INTO #Initial ([SalesTax],[Unit])
(
SELECT SUM(SalesTax), Unit
FROM Billing
GROUP BY Unit
);

CREATE TABLE #End
(
[SalesTax] NUMERIC (20,4),
[Unit] VARCHAR(10)
);

INSERT INTO #End([SalesTax],[Unit])
(
SELECT SUM(SalesTax), Unit
FROM BillingEnd
GROUP BY Unit
);

Then I am trying to add these values together when I select them in another query(This query is a very simple example of a much bigger query. It has to be done like this):

SELECT 
u.Unit,
i.SalesTax,
e.SalesTax,
(i.SalesTax+ e.SalesTax) AS SalesTaxFeeTotal
FROM tblUnit u
LEFT JOIN #Initial i ON u.Unit = i.Unit
LEFT JOIN #End e ON u.Unit = e.Unit

For some reason the SalesTax column is coming back as NULL when the i.SalesTax and e.SalesTax column are returning values for those same records.

There is no NULL values in either temp table. If there is no fee, it is 0.00

Why are these retuning nulls?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:13:41+00:00Added an answer on May 24, 2026 at 12:13 am

    Change this

    (i.StateFee + e.StateFee) AS StateFeeTotal
    

    to

    (ISNULL(i.StateFee,0) + ISNULL(e.StateFee,0)) AS StateFeeTotal
    

    Or with maybe correct column name

    (ISNULL(i.StateFeeBegin,0) + ISNULL(e.StateFeeEnd,0)) AS StateFeeTotal
    

    With the LEFT JOIN, you can get NULLs for the values. NULL added to anything else will always be NULL. This answer uses ISNULL to replace NULL vales.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a temp table that has numeric integer values in one column. I
I have been wondering about temp tables in sp's and how all that can
I have a stored procedure that returns values from a temp table. In my
I have been reading about the differences between Table Variables and Temp Tables and
I have written a DB2 query to do the following: Create a temp table
I have a stored procedure inside which I create a temporary table that typically
I have a query that creates several temporary tables and then inserts data into
Two temp tables are created and then loaded...Here's the schema. Create table #SH ([date]
Say we have some poorly written SQL that does not release temp tables when
Our client's database admins have requested that we don't use temp tables within our

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.