Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Last active December 17, 2015 02:59
Show Gist options
  • Select an option

  • Save kylejohnson/5540229 to your computer and use it in GitHub Desktop.

Select an option

Save kylejohnson/5540229 to your computer and use it in GitHub Desktop.
mysql> SELECT IFNULL(COUNT(`Event`.`Id`), 0) AS count FROM `zm`.`Events` AS `Event` LEFT JOIN `zm`.`Monitors` AS `Monitor` ON (`Event`.`MonitorId` = `Monitor`.`Id`) WHERE `Event`.`StartTime` > DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY `Event`.`MonitorId`;
+-------+
| count |
+-------+
| 16 |
| 27 |
+-------+
2 rows in set (0.00 sec)
mysql> SELECT IFNULL(COUNT(`Event`.`Id`), 0) AS count FROM `zm`.`Events` AS `Event` LEFT JOIN `zm`.`Monitors` AS `Monitor` ON (`Event`.`MonitorId` = `Monitor`.`Id`) WHERE `Event`.`StartTime` > DATE_SUB(NOW(), INTERVAL 1 HOUR) GROUP BY `Event`.`MonitorId`;
Empty set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment