, .
: , , - . , - , .
, " ".
, : (.. , ); LEFT JOIN Officer, , null. , , (, , ).
, ( , ):
SELECT
Officer.id as OfficerID,
Officer.name,
MAX(Report.id) as ReportID,
MAX(performanceDate) AS performanceDate
FROM Officer
LEFT JOIN report_officer ON (Officer.id = report_officer.officer_id)
LEFT JOIN Report ON (Report.id = report_officer.report_id
AND performanceDate BETWEEN 20140323 AND 20140401)
GROUP BY Officer.id, Officer.name
HAVING ReportID IS NULL;
HAVING. HAVING, , , :
SELECT
Officer.id as OfficerID,
Officer.name,
COUNT(Report.id) as reports
FROM Officer
LEFT JOIN report_officer ON (Officer.id = report_officer.officer_id)
LEFT JOIN Report ON (Report.id = report_officer.report_id
AND performanceDate BETWEEN 20140323000000 AND 20140401235959)
GROUP BY Officer.id, Officer.name;
, reports 0, . MAX(performanceDate) AS performanceDate, MAX(Report.id) AS ReportID, (, ) , . , .
, YYYYMMDD YYYYMMDD000000, . BETWEEN performanceDate >= '2014-03-23 00:00:00' AND performanceDate <= '2014-04-01 23:59:59'.