'Joining two tables by date when all dates don't match
I have two tables, one with dates and revenue predictions and another table with dates and revenue predictions. I would like to join the tables together on the dates however, when i do that the join deletes the records that don't match. I would like to keep the records that don't match. Here's an example of the table. I'm okay with there being duplications.
Table A
Date Rev
01-01-2021 30,000
01-02-2021 26,000
01-03-2021 28,000
Table B
Date Rev
01-01-2021 30,000
01-02-2021 26,000
01-03-2021 28,000
03-05-2021 31,000
Solution 1:[1]
Use FULL OUTER JOIN to keep both sides:
select TA.*, TB.*
from TableA as TA
FULL OUTER JOIN
TableB as TB
on TA.Date=TB.Date
I don't know your dbms product (SqlServer, Oracle, etc..) so I can't tell if it allows full outer join, and if Date is a reserved word.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
