Thanks, I managed to get what I want:
First I brought both tables together
Code:
SELECT *FROM allmailboxstats LEFT JOIN disconnectedmailboxes ON allmailboxstats.displayname=disconnectedmailboxes.displayname;
Then I did the working out:
Code:
SELECT FullQueryTest.allmailboxstats.ID, FullQueryTest.allmailboxstats.DisplayName, FullQueryTest.OU, OULookup.[Business Unit], FullQueryTest.maxsendsize, FullQueryTest.prohibitsendreceivequota, FullQueryTest.HiddenFromAddressListsEnabled, FullQueryTest.IsValid, FullQueryTest.DisconnectDate, FullQueryTest.DisconnectReason, IIf(IsNull(DisconnectDate) And ((maxsendsize)<>"0 B (0 bytes)") And ((HiddenFromAddressListsEnabled)=No),1,0) AS Active, IIf(IsNull(DisconnectDate) And ((maxsendsize)="0 B (0 bytes)"),1,0) AS Disabled, IIf(IsNull(DisconnectDate) And ((allmailboxstats.HiddenFromAddressListsEnabled)=Yes) And ((allmailboxstats.maxsendsize)<>"0 B (0 bytes)"),1,0) AS Suspended, IIf(Not IsNull(DisconnectDate) And (((DisconnectDate)>=Now()-210) AND ((IsValid)=Yes)),1,0) AS Deleted
FROM (FullQueryTest INNER JOIN MailboxSizes ON FullQueryTest.prohibitsendreceivequota=MailboxSizes.Mailboxes) INNER JOIN OULookup ON FullQueryTest.OU=OULookup.OU;
The only problem is that there are duplicates, but I assume that's because the displayname is duplicated in the second table so therefore shows up twice in the query?