SELECT
HOUR (`Timestamp`) AS HOUR,
COUNT(*) AS Alarms
FROM
`alarms`
WHERE
`Siteindex` IN ('4, 5, 8, 10, 11, 15')
AND `Datestamp` = '2012-11-07'
GROUP BY
HOUR (`Timestamp`);
此代码仅在每个 id 来自IN ('4, 5, 8, 10, 11, 15')
have时才有效Datestamp = '2012-11-07'
,但如何仅计算那些拥有它的人?
例如上面的代码返回NULL
是因为 2012-11-07 中只有 15 行有一些行,但我需要它不理会其他行并返回所有