CASE status WHEN'ENABLED'THEN'<div class="Healthy">Yes</div>' WHEN'SLAVESIDE_DISABLED'THEN'<div class="Healthy">No</div>' ELSE'<div class="Warning">No</div>' END,
CASE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME and errno isnullandstart>= subdate(now(), @NumDays)) WHEN0THEN CONCAT('<div class="Warning">', (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME and errno isnullandstart>= subdate(now(), @NumDays)), '</div>') ELSE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME and errno isnullandstart>= subdate(now(), @NumDays)) END,
CASE (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME and errno isnot nullandstart>= subdate(now(), @NumDays)) WHEN0THEN'<div class="Healthy">0</div>' ELSE CONCAT('<div class="Critical">', (selectcount(*) from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME and errno isnot nullandstart>= subdate(now(), @NumDays)),'</div>') END,
case interval_field when "YEAR" then date_add(last_executed, interval interval_value YEAR) when "QUARTER" then date_add(last_executed, interval interval_value QUARTER) when "MONTH" then date_add(last_executed, interval interval_value MONTH) when "DAY" then date_add(last_executed, interval interval_value DAY) when "HOUR" then date_add(last_executed, interval interval_value HOUR) when "MINUTE" then date_add(last_executed, interval interval_value MINUTE) when "WEEK" then date_add(last_executed, interval interval_value WEEK) when "SECOND" then date_add(last_executed, interval interval_value SECOND) end,
(selectCASE WHEN errno isnullTHEN CONCAT('<span class="Healthy">', message_text, '</span>') ELSE CONCAT('<span class="Critical">', message_text, '</span>') END from master.event_history where db = ev.EVENT_SCHEMA and name = ev.EVENT_NAME orderbystart limit 1),