Select ID from costumers that do not have contacts last 7 days and 2 times in the month I have 2 tables: custumer, c_contact. 
c_contact is all the e-mails I send to my custumers.
From now on I need to put a new rule that the costumer can't receive a new e-mail if: 
1) It received an e-mail in the last 7 days
2) Have 2 or more e-mails sent in the current month

I thought something like that:

SELECT * 
from costumer c inner join c_contact cc on cc.ID = c.ID 
WHERE ID not in (select ID 
                 from c_contact c1 
                 where c1.ID = cc.ID 
                   and c1.CONTDATE &gt;= getdate()-7)   
  AND ID not in (select count(ID) 
                 from c_contact 
                 where MONTH(contdate) = MONTH(getdate()) 
                   and YEAR(contdate) = YEAR(getdate()) 
                 HAVING count(ID) &gt;= 2)


But the table c_contact is huge and it taking ages to run this.
Is there a way to do these 2 conditions in 1 "ID not in"? I thing it will run a lot faster.
These are the customers that have not received an e-mail in the last 7 days AND have received less than two e-mails this month:

SELECT *
FROM customer AS c
WHERE c.ID NOT IN (
    SELECT ID        --- the customer ID
    FROM c_contact
    WHERE contdate&gt;=DATEADD(day, -31, SYSDATETIME()) -- for optimization
    GROUP BY ID
    HAVING MAX(contdate)&gt;=DATEADD(day, -7, SYSDATETIME()) OR
           SUM((CASE WHEN contdate&gt;=DATEFROMPARTS(
               YEAR(SYSDATETIME()),
               MONTH(SYSDATETIME()),
               1) THEN 1 ELSE 0 END))&gt;=2);


Conversely, here are customers that have receive an e-mail in the last 7 days OR have received two or more e-mails this month:

SELECT *
FROM customer AS c
WHERE c.ID IN (
    SELECT ID        --- the customer ID
    FROM c_contact
    WHERE contdate&gt;=DATEADD(day, -31, SYSDATETIME()) -- for optimization
    GROUP BY ID
    HAVING MAX(contdate)&gt;=DATEADD(day, -7, SYSDATETIME()) OR
           SUM((CASE WHEN contdate&gt;=DATEFROMPARTS(
               YEAR(SYSDATETIME()),
               MONTH(SYSDATETIME()),
               1) THEN 1 ELSE 0 END))&gt;=2);


Because I've put the two conditions in a single HAVING clause, the two queries only scan the c_contact table once, making them much more efficient. In particular, an optimal index for this type of query would probably look something like this:

CREATE INDEX indexName ON c_contact (ID, contdate);