Hello, I'm a beginner at SQL
I would like to add this subset A
+---------------+
| ReferenceDate |
+---------------+
| RefDate1 |
+---------------+
| RefDate2 |
+---------------+
With subset B
+---------------+------------+-------------+
| ReferenceDate | EntityName | EntityState |
+---------------+------------+-------------+
| RefDate1 | EntityA | StateX |
+---------------+------------+-------------+
| RefDate2 | EntityA | StateX |
+---------------+------------+-------------+
| RefDate1 | EntityB | StateY |
+---------------+------------+-------------+
| RefDate2 | EntityC | StateX |
+---------------+------------+-------------+
Which should return this final set
+---------------+------------+-------------+
| ReferenceDate | EntityName | EntityState |
+---------------+------------+-------------+
| RefDate1 | EntityA | StateX |
+---------------+------------+-------------+
| RefDate2 | EntityA | StateX |
+---------------+------------+-------------+
| RefDate1 | EntityB | StateY |
+---------------+------------+-------------+
| RefDate2 | NULL | NULL |
+---------------+------------+-------------+
| RefDate1 | NULL | NULL |
+---------------+------------+-------------+
| RefDate2 | EntityC | StateX |
+---------------+------------+-------------+
So, basically It would do a cross JOIN for each entity and if a certain entity didn't have that RefDate it should only return the RefDate(subset A) and null for the other fields (subset B).
I'm trying to create this because I need to build a table with those records, the columns will be fixed (the RefDates) but since the rows are each entity, they can or cannot have both RefDates. So when they don't have one of them that specific cell should stay null.
I tried to LEFT JOIN the subset A, but since the subsetB will always have those two RefDates, it never returns null on the final set.
Is there a better way to tackle this problem?
Thank you!!