I'm trying to solve task for last hours...
I have four tables:
Users (ID INT, Fullname VARCHAR(255))
Segments (Value VARCHAR(255))
Report_1 (ID INT, UserID INT, Segment VARCHAR(255), Total INT)
Report_2 (ID INT, UserID INT, Segment VARCHAR(255), Total INT)
...and I need to get reports by all users with all possible segments.
But reports from "Report_1", "Report_2" may not have records for some users or segments.
The result query must have this columns:
UserID, Segment, Report_1.Total(OR NULL), Report_2.Total(OR NULL)
Could I use CROSS JOIN / APPLY or something?