SELECT (select count(template_id) from os_eqm.devices where template_id <>0)+ (select count(def_monitoring_type)from devices_active where nvl(def_monitoring_type,0) <> 0) from dual