I have a table named [Mailbox Status] listing all email mailboxes that are to be migrated to O365. Mailboxes are migrated in batches (column BatchNumber) and when they are migrated, the column MailboxState is set to 'Client Migrated'.
For each BatchNumber, I need to count the number of migrated mailboxes (MailboxState = 'Client Migrated').
SELECT [Mailbox Status].BatchNumber,
DCount("MailboxState","[Mailbox Status]", "[MailboxState]='Client Migrated'") As MigratedCount
FROM [Mailbox Status]
WHERE [Mailbox Status].BatchNumber is not NULL
GROUP BY [Mailbox Status].BatchNumber ;
The above query is returning the count of migrated mailboxes across all BatchNumbers instead of returning the count for a given BatchNumber.
What am I doing wrong?