I have this query which does get the results I require but is incredibly slow and surely there must be a better way of doing this as I would need to run this regularly.
Each where clause has two variables which will always be the same number but I need to use this with 50+ BigIDs, the example shows 3 but I would do it for BigID 1 to 50+.
I am unsure how to make this shorter because of the two variables (one of which being in a subquery) and group by which is required. Any help or pointing in the right direction would be appreciated. Thanks.
SELECT BigID,count(LittleID)
FROM Table1
where ( (BigID=1 and LittleID not in (SELECT LittleID FROM Table2 where BigID=1)) or
(BigID=2 and LittleID not in (SELECT LittleID FROM Table2 where BigID=2)) or
(BigID=3 and LittleID not in (SELECT LittleID FROM Table2 where BigID=3)) )
group by BigID