Mysql
 sql >> Database >  >> RDS >> Mysql

SQL SELECT invertito:trova il personale che non ha effettuato chiamate a freddo tra un intervallo di date

usa LEFT JOIN

SELECT  a.name
FROM    staff a
        INNER JOIN staff_prospects b
            ON b.staff_id = a.id
        LEFT JOIN staff_prospect_activity c
            ON  c.prospect_id = b.id AND
                c.date_of_activity >= '2013-05-31' AND 
                c.date_of_activity < '2013-05-31' + INTERVAL 1 DAY
WHERE   c.prospect_id IS NULL
GROUP   BY a.name