Hi I have two dasets and I need to combine them both even though dates for the both tables do not match
A:
Site |
DTM |
measure1 |
measure2 |
ABC |
2/2/2020 9:53 |
32.1 |
20.5 |
ABC |
2/2/2020 10:31 |
12.1 |
12.6 |
DEF |
2/3/2020 9:33 |
42.1 |
44.1 |
DEF |
2/4/2020 14:23 |
31.1 |
41.4 |
B:
Site |
DTM |
measure1 |
ABC |
2/2/2020 9:53 |
32.1 |
ABC |
2/2/2020 10:31 |
12.1 |
ABC |
2/3/2020 9:33 |
42.1 |
DEF |
2/2/2020 9:53 |
41.1 |
DEF |
2/2/2020 10:31 |
12.2 |
DEF |
2/3/2020 9:33 |
42.1 |
DEF |
2/4/2020 14:23 |
31.1 |
Want:
Site |
DTM |
measure1 |
measure2 |
ABC |
2/2/2020 9:53 |
32.1 |
20.5 |
ABC |
2/2/2020 10:31 |
12.1 |
12.6 |
ABC |
2/3/2020 9:33 |
42.1 |
|
DEF |
2/2/2020 9:53 |
41.1 |
|
DEF |
2/2/2020 10:31 |
12.2 |
|
DEF |
2/3/2020 9:33 |
42.1 |
44.1 |
DEF |
2/4/2020 14:23 |
31.1 |
41.4 |
Here's my attempt thus far:
select b.site, b.measure1, b.measure2, b.dtm, a.measure1
from dataset_a a
left outer join dataset_b on a.site = b.site