查询1天内的Top

点击(此处)折叠或打开

SELECT h.`name`, t.`description`, COUNT(*) num
FROM `events` e
JOIN `triggers` t ON e.`objectid`=t.`triggerid` AND t.`priority`>=2
JOIN functions f ON f.`triggerid`=t.`triggerid`
JOIN items i ON f.`itemid`=i.`itemid`
JOIN `hosts` h ON i.`hostid`=h.`hostid`
WHERE e.object=0ANDe.source=0 ande.`clock`>=UNIX_TIMESTAMP(DATE_SUB(NOW(),INTERVAL 1 DAY)) GROUP BY h.`name`, t.`description`
ORDER BY num DESC,t.`priority` DESClimit 100