Full outer join not displaying rows from right side table

2021-01-06T21:05:40.333+00:00

I have two tables like below.

Budget table

54154-image.png

forecast table

53990-image.png

when I joined both these queries using full outer join, I am not getting 2 rows from forecast table. so data is mismatching. how to fix this issue.

note

only selecting F.[Forecast $], F.[Forecast Qty] column from forecast table.

below is the query

54127-image.png

Developer technologies Transact-SQL
{count} votes

3 answers

Sort by: Most helpful
  1. EchoLiu-MSFT 14,621 Reputation points
    2021-01-07T07:41:07.42+00:00

    Hi @siva rama krishna reddy tangirala ,

    Welcome to the Microsoft TSQL Q&A Forum!

    The description of your problem is very clear, but you did not provide the corresponding table code and data code, we can not do the test and find the problem.

    In addition, when you post a question, please provide a minimal example for testing and the output you expect.

    Echo

    0 comments No comments

  2. Visakh 211 Reputation points Volunteer Moderator
    2021-01-07T07:52:50.877+00:00

    Can you please show the output of the FULL JOIN @siva rama krishna reddy tangirala ?
    Also I hope this is the actual complete query and you've not left out any part of it like correlated query, filter etc.

    0 comments No comments

  3. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2021-01-09T09:37:27.957+00:00

    This query is in a view and written by somebody. I applied where condition while testing

    When you apply a WHERE condition to a full-join query you need to be very careful. If you say

    SELECT ...
    FROM  A
    FULL JOIN B ON ...
    WHERE a.col = 23
    

    You have now filtered out all rows where there are only rows from B, since the condition says that you only want rows from a where col has a non-NULL value. If you want to retain the other rows, you need to say

    WHERE a.col = 23 OR a.col IS NULL
    

    The fact that the full-join is in a view does not change this. The view is just a stored macro which is pasted into the query.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.