A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Below is a query for you.
At first you may not recognize anything, but the two CTEs (see Ronen's post above), are actually your original query. I have however reformatted the queries to make them more readable. I've changed the creepy formatting introduced by the Query Designer and introduced aliases to make the query more concise.
I've also commented out two of the tables, because I cannot see that they are actually used in the query, and possibly they could introduce incorrect results. Then again, I don't know your tables, so may be there is a point. But from where I sit, they do look suspicious.
The final query is a full outer join as Ronen discussed. The WHERE clause is a convenient way of finding all differences without having to list each and every column and with all various with NULL etc.
Disclaimer: since I don't have your tables, I have not been able to test.
WITH Query1 AS (
SELECT E.ID AS EventID, SUM(SB.StaffTotal) AS StaffTotal1, SUM(SB.Total) AS ClientTotal1
FROM Events1 E
-- JOIN Clients1 C ON E.Client = C.ID
JOIN StaffBookings1 SB ON E.ID = StaffBookings1.Event
-- JOIN Staff1 S ON SB.Staff = S.ID
GROUP BY E.ID
), Query2 AS (
SELECT E.ID AS EventID, SUM(SB.StaffTotal) AS StaffTotal2, SUM(SB.Total) AS ClientTotal2
FROM Events2 E
-- JOIN Clients2 C ON E.Client = C.ID
JOIN StaffBookings2 SB ON E.ID = SB2.Event
-- JOIN Staff2 S ON SB2.Staff = S.ID
GROUP BY Events2.ID
)
SELECT isnull(Q1.EventID, Q2.EventID) AS EventID,
Q1.StaffTotal1, Q2.StaffTotal2,
isnull(Q1.StaffTotal1, 0) - isnull(Q2.StaffTotal2, 0) AS DiffStaff,
Q1.ClientTotal1, Q2.ClientTotal2,
isnull(Q1.ClientTotal1, 0) - isnull(Q2.ClientTotal2, 0) AS DiffClient
FROM Query1 Q1
FULL JOIN Query2 Q2 ON Q1.EventID = Q2.EventID
WHERE NOT EXISTS (SELECT Q1.* INTERSECT SELECT Q2.*)