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 8538979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:15:08+00:00 2026-06-11T11:15:08+00:00

I have 2 tables I’m trying to join in SQL Server . Table one

  • 0

I have 2 tables I’m trying to join in SQL Server. Table one is a list of salesId‘s and table two is a list of average sales per month by salesId.

Table1 :

SalesId
 0001
 0004
 0345
 1009
 2290
 ....

Table2:

SalesId    AvgMnthSales
 0001       22253.34
 0002        8970.28
 0003       15377.45
 0004         349.03
 0005        3498.44
 ....         ...

So I do a join like this:

Select t1.SalesId, t2.AvgMnthSales
from table1 t1
left join
table2 t2
on t1.SalesId = t2.SalesId

and get something like this:

   SalesId      AvgMnthSales
     0001        22253.34
     0004          349.03
     0345         NULL
     1009         NULL
     2290         8846.56
     ....          ....

What I’d prefer is to have any NULL converted to 0. I’ve seen some examples where this was done in a two step process of sending the results to a temp table and then converting NULL‘s to 0‘s, but was curious if there’s a single step way to do this.

The reason is largely due to ignorance. I’m not sure how temp tables are handled (in RAM or on disk) and how much space they take up as this is a large data set and it would likely take up several GB‘s of RAM or disk space.

Any suggestions would be appreciated.

  • 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-06-11T11:15:10+00:00Added an answer on June 11, 2026 at 11:15 am
    Select t1.SalesId, COALESCE(t2.AvgMnthSales,0) as AvgMnthSales
    from table1 t1
    left join
    table2 t2
    on t1.SalesId = t2.SalesId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have tables A and B in SQL Server, and columns a and
I have two tables with like below codes: Table: Accounts id | username |
I have two tables, say Table A and Table B. I want to have
I have tables Products, Sales and ProductsInStores. ProductsInStores table keeps track of how many
I have tables like these two test_table date student test 2012-05-31 Alice Math 2012-05-31
I have tables linked by FK, I query on the first table using entity
Hi i have tables like this : table entry : id | total_comments _____________________
I have tables: Teachers and Students. We have a SpecialProjects Table where Teachers and
I have tables item and store (it's a store management system). item table has
I have tables with listings, categories and one that maps them to each other.

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.